Class DomMapperBase

Direct Known Subclasses:
DomElementMapper, DomFragmentMapper, DomListMapper

public class DomMapperBase extends DocumentModelMapperBase

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 Details

    • m_document

      protected Document m_document
      Actual document instance (required by DOM).
    • m_defaultNamespaceURI

      protected String m_defaultNamespaceURI
      Current default namespace URI (null if not determined).
    • m_defaultNamespaceIndex

      protected int m_defaultNamespaceIndex
      Current default namespace index.
  • Constructor Details

    • DomMapperBase

      protected DomMapperBase() throws JiBXException
      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

      private int findNamespaceIndex(String prefix, String uri)
      Get index number for declared namespace.
      Parameters:
      prefix - namespace prefix (null if none)
      uri - namespace URI (empty string if none)
      Returns:
      namespace index number, or -1 if not declared or masked
    • marshalNode

      protected void marshalNode(Node node) throws JiBXException, IOException
      Marshal node.
      Parameters:
      node - node to be marshalled
      Throws:
      JiBXException - on error in marshalling
      IOException - on error writing to output
    • marshalContent

      protected void marshalContent(NodeList content) throws JiBXException, IOException
      Marshal node list.
      Parameters:
      content - list of nodes to marshal
      Throws:
      JiBXException - on error in marshalling
      IOException - on error writing to output
    • addNamespace

      private void addNamespace(String prefix, String uri, ArrayList nss)
      Add namespace information to list.
      Parameters:
      prefix -
      uri -
      nss -
    • isEquivalent

      private boolean isEquivalent(String a, String b)
      Check if a pair of strings are equivalent, meaning either equal or one empty and the other null.
      Parameters:
      a - non-null value
      b - comparison value (may be null)
      Returns:
      true if equivalent, false if not
    • addNamespaceUnique

      private void addNamespaceUnique(String prefix, String uri, ArrayList nss)
      Add namespace information to list if not already present.
      Parameters:
      prefix -
      uri -
      nss -
    • marshalElement

      protected void marshalElement(Element element) throws JiBXException, IOException
      Marshal element with all attributes and content.
      Parameters:
      element - element to be marshalled
      Throws:
      JiBXException - on error in marshalling
      IOException - on error writing to output
    • unmarshalNode

      protected Node unmarshalNode() throws JiBXException, IOException
      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 unmarshalling
      IOException - on error reading input
    • unmarshalContent

      protected void unmarshalContent(Node parent) throws JiBXException, IOException
      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 unmarshalling
      IOException - on error reading input
    • unmarshalElement

      protected Element unmarshalElement() throws JiBXException, IOException
      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 unmarshalling
      IOException - on error reading input