|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.xml.XMLNestedMapConverter
public class XMLNestedMapConverter
The XMLNestedMapConverter allows to convert xml content into a nested Map hierarchy.
<?xml version="1.0" encoding="UTF-8"?>
<Books >
<header>
<metainfo>Some meta information</metainfo>
</header>
<Book>
<Title>Simple title</Title>
<author >
an author
</author>
</Book>
<Book>
<Title>Second<![CDATA[ simple]]>
title
</Title>
<Author >Second author</Author>
</Book>
</Books>
will be converted into following nested map hierarchy:
-+
|-+ Books
| |-+ header
| | |-- metainfo=Some meta information
| |
| |-- Book=[{Title=Simple title, author=
an author
}, {Title=Second simple
title
, Author=Second author}]
|
(All '+' nodes represents a new Map object)Map using a single shared key but
instead of simple primitive values the key points to a List of Objects.
newMapFromXML(CharSequence),
newNamespaceAwareMapFromXML(CharSequence),
setExceptionHandler(ExceptionHandler)| Field Summary | |
|---|---|
static String |
DEFAULT_ENCODING
|
static XMLInstanceContextFactory |
XML_INSTANCE_CONTEXT_FACTORY_JAVA_STAX_DEFAULT
|
| Constructor Summary | |
|---|---|
XMLNestedMapConverter()
|
|
| Method Summary | ||
|---|---|---|
Map<String,Object> |
newMapFromXML(CharSequence xmlContent)
Similar to newNamespaceAwareMapFromXML(CharSequence) but with non Namespace aware String values as
keys. |
|
protected
|
newMapFromXML(CharSequence xmlContent,
ElementConverter<QName,K> keyElementConverter)
Template method for newNamespaceAwareMapFromXML(CharSequence) and newMapFromXML(CharSequence) which allows
to convert the QName based key values to other representations. |
|
Map<QName,Object> |
newNamespaceAwareMapFromXML(CharSequence xmlContent)
Creates nested Map instances which contains all information from the given xml content as key value pairs. |
|
XMLNestedMapConverter |
setEncoding(String encoding)
Sets another encoding. |
|
XMLNestedMapConverter |
setExceptionHandler(ExceptionHandler exceptionHandler)
|
|
XMLNestedMapConverter |
setXmlInstanceContextFactory(XMLInstanceContextFactory xmlInstanceContextFactory)
Allows to set an alternative XMLInstanceContextFactory |
|
String |
toNamespaceAwareXML(Map<QName,Object> nestedMap)
Similar to toXML(Map) but for Map instances having a QName based key type |
|
void |
toNamespaceAwareXML(Map<QName,Object> nestedMap,
OutputStream outputStream)
Similar to toXML(Map, OutputStream) but for Maps having QNames as key type |
|
String |
toNamespaceAwareXMLDocument(Map<QName,Object> nestedMap)
Similar to toNamespaceAwareXML(Map, OutputStream) but returns a String instance instead of writing into an
OutputStream |
|
void |
toNamespaceAwareXMLDocument(Map<QName,Object> nestedMap,
OutputStream outputStream)
Similar to toXMLDocument(Map, OutputStream) but has full qualified QNames |
|
String |
toXML(Map<String,Object> nestedMap)
Returns the xml content equivalent to the given nested Map structure |
|
void |
toXML(Map<String,Object> nestedMap,
OutputStream outputStream)
Similar to toXML(Map) but writes the result to a given OutputStream directly instead of creating a
String. |
|
String |
toXMLDocument(Map<String,Object> nestedMap)
Similar to toXMLDocument(Map, OutputStream) but returns a String instance instead of writing into an
OutputStream |
|
void |
toXMLDocument(Map<String,Object> nestedMap,
OutputStream outputStream)
Similar to toXML(Map, OutputStream) but encloses the given nested Map into a xml document with a single root
tag |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_ENCODING
public static final XMLInstanceContextFactory XML_INSTANCE_CONTEXT_FACTORY_JAVA_STAX_DEFAULT
| Constructor Detail |
|---|
public XMLNestedMapConverter()
| Method Detail |
|---|
public Map<QName,Object> newNamespaceAwareMapFromXML(CharSequence xmlContent)
Map instances which contains all information from the given xml content as key value pairs.QNames of the tag elements do represent the keys of the returned Map. Strings, Lists or Maps.
xmlContent -
Map instanceXMLNestedMapConverter,
newMapFromXML(CharSequence)public Map<String,Object> newMapFromXML(CharSequence xmlContent)
newNamespaceAwareMapFromXML(CharSequence) but with non Namespace aware String values as
keys. Those keys will only contain the tag name without any Namespace information.
xmlContent -
Map instancenewNamespaceAwareMapFromXML(CharSequence)
protected <K> Map<K,Object> newMapFromXML(CharSequence xmlContent,
ElementConverter<QName,K> keyElementConverter)
newNamespaceAwareMapFromXML(CharSequence) and newMapFromXML(CharSequence) which allows
to convert the QName based key values to other representations.
xmlContent -
Map instancepublic String toXML(Map<String,Object> nestedMap)
Map structure
nestedMap - Map
XMLNestedMapConverter,
toNamespaceAwareXML(Map)public String toNamespaceAwareXML(Map<QName,Object> nestedMap)
toXML(Map) but for Map instances having a QName based key type
nestedMap - Map
XMLNestedMapConverter,
toXML(Map)public String toXMLDocument(Map<String,Object> nestedMap)
toXMLDocument(Map, OutputStream) but returns a String instance instead of writing into an
OutputStream
nestedMap - Map
XMLNestedMapConverter,
toNamespaceAwareXML(Map),
toXML(Map)
public void toXMLDocument(Map<String,Object> nestedMap,
OutputStream outputStream)
toXML(Map, OutputStream) but encloses the given nested Map into a xml document with a single root
tag
nestedMap - outputStream - toXML(Map, OutputStream),
toNamespaceAwareXMLDocument(Map, OutputStream)public String toNamespaceAwareXMLDocument(Map<QName,Object> nestedMap)
toNamespaceAwareXML(Map, OutputStream) but returns a String instance instead of writing into an
OutputStream
nestedMap - Map
XMLNestedMapConverter,
toNamespaceAwareXML(Map, OutputStream),
toNamespaceAwareXMLDocument(Map, OutputStream)
public void toNamespaceAwareXMLDocument(Map<QName,Object> nestedMap,
OutputStream outputStream)
toXMLDocument(Map, OutputStream) but has full qualified QNames
nestedMap - outputStream - toXML(Map, OutputStream),
toNamespaceAwareXMLDocument(Map)
public void toXML(Map<String,Object> nestedMap,
OutputStream outputStream)
toXML(Map) but writes the result to a given OutputStream directly instead of creating a
String. OutputStream will not be closed by this method call.
nestedMap - MapoutputStream - OutputStreamtoNamespaceAwareXML(Map, OutputStream),
toXMLDocument(Map),
toNamespaceAwareXMLDocument(Map)
public void toNamespaceAwareXML(Map<QName,Object> nestedMap,
OutputStream outputStream)
toXML(Map, OutputStream) but for Maps having QNames as key type
nestedMap - MapoutputStream - OutputStreamtoXML(Map, OutputStream),
toNamespaceAwareXMLDocument(Map, OutputStream)public XMLNestedMapConverter setExceptionHandler(ExceptionHandler exceptionHandler)
exceptionHandler - ExceptionHandler
public XMLNestedMapConverter setEncoding(String encoding)
encoding - the encoding to set
public XMLNestedMapConverter setXmlInstanceContextFactory(XMLInstanceContextFactory xmlInstanceContextFactory)
XMLInstanceContextFactory
xmlInstanceContextFactory - XMLInstanceContextFactory
XML_INSTANCE_CONTEXT_FACTORY_JAVA_STAX_DEFAULT
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||