Package org.jibx.extras
Class DomMapperBase
java.lang.Object
org.jibx.extras.DocumentModelMapperBase
org.jibx.extras.DomMapperBase
- Direct Known Subclasses:
DomElementMapper,DomFragmentMapper,DomListMapper
Base implementation for custom marshaller/unmarshallers to DOM representation. This provides the basic code used for both single element and content list handling.
- Author:
- Dennis M. Sosnoski
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intCurrent default namespace index.protected StringCurrent default namespace URI (nullif not determined).protected DocumentActual document instance (required by DOM).Fields inherited from class org.jibx.extras.DocumentModelMapperBase
m_unmarshalContext, m_xmlWriter, XML_NAMESPACE, XMLNS_NAMESPACE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddNamespace(String prefix, String uri, ArrayList nss) Add namespace information to list.private voidaddNamespaceUnique(String prefix, String uri, ArrayList nss) Add namespace information to list if not already present.private intfindNamespaceIndex(String prefix, String uri) Get index number for declared namespace.private booleanisEquivalent(String a, String b) Check if a pair of strings are equivalent, meaning either equal or one empty and the othernull.protected voidmarshalContent(NodeList content) Marshal node list.protected voidmarshalElement(Element element) Marshal element with all attributes and content.protected voidmarshalNode(Node node) Marshal node.protected voidunmarshalContent(Node parent) Unmarshal node content.protected ElementUnmarshal element with all attributes and content.protected NodeUnmarshal single node.Methods inherited from class org.jibx.extras.DocumentModelMapperBase
accumulateText, getNamespaceUri, getNextNamespaceIndex, isWhitespace
-
Field Details
-
m_document
Actual document instance (required by DOM). -
m_defaultNamespaceURI
Current default namespace URI (nullif not determined). -
m_defaultNamespaceIndex
protected int m_defaultNamespaceIndexCurrent default namespace index.
-
-
Constructor Details
-
DomMapperBase
Constructor. Initializes the document used by this marshaller/unmarshaller instance as the owner of all DOM components.- Throws:
JiBXException- on error creating document
-
-
Method Details
-
findNamespaceIndex
Get index number for declared namespace.- Parameters:
prefix- namespace prefix (nullif none)uri- namespace URI (empty string if none)- Returns:
- namespace index number, or
-1if not declared or masked
-
marshalNode
Marshal node.- Parameters:
node- node to be marshalled- Throws:
JiBXException- on error in marshallingIOException- on error writing to output
-
marshalContent
Marshal node list.- Parameters:
content- list of nodes to marshal- Throws:
JiBXException- on error in marshallingIOException- on error writing to output
-
addNamespace
Add namespace information to list.- Parameters:
prefix-uri-nss-
-
isEquivalent
Check if a pair of strings are equivalent, meaning either equal or one empty and the othernull.- Parameters:
a- non-nullvalueb- comparison value (may benull)- Returns:
trueif equivalent,falseif not
-
addNamespaceUnique
Add namespace information to list if not already present.- Parameters:
prefix-uri-nss-
-
marshalElement
Marshal element with all attributes and content.- Parameters:
element- element to be marshalled- Throws:
JiBXException- on error in marshallingIOException- on error writing to output
-
unmarshalNode
Unmarshal single node. This unmarshals the next node from the input stream, up to the close tag of the containing element.- Returns:
- unmarshalled node
- Throws:
JiBXException- on error in unmarshallingIOException- on error reading input
-
unmarshalContent
Unmarshal node content. This unmarshals everything up to the containing element close tag, adding each component to the content list supplied. On return, the parse position will always be at an END_TAG.- Parameters:
parent- node to which children are to be added- Throws:
JiBXException- on error in unmarshallingIOException- on error reading input
-
unmarshalElement
Unmarshal element with all attributes and content. This must be called with the unmarshalling context positioned at a START_TAG event.- Returns:
- unmarshalled element
- Throws:
JiBXException- on error in unmarshallingIOException- on error reading input
-