Interface DOMWrapper

  • All Known Implementing Classes:
    W3CDOMWrapper

    public interface DOMWrapper
    DOMWrapper implements a Wrapper around the Element class from any DOM-style XML parser. The wrapper is used to isolate ElementParser, ElementDef, and all ElementDef subclasses from the specifics of the underlying XML parser.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int CDATA
      CDATA is a type of DOM Element representing a piece of text embedded in a CDATA section, for example, <![CDATA[Some text]]>.
      static int COMMENT
      COMMENT is a type of DOM Element representing an XML comment.
      static int ELEMENT
      ELEMENT is a type of DOM Element representing a named tag, possibly containing attributes, child elements, and text.
      static int FREETEXT
      FREETEXT is a type of DOM Element representing a piece of text (but not a CDATA section).
      static int UNKNOWN
      UNKNOWN is used for DOM Element types unsupported by the wrapper.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getAttribute​(java.lang.String attrName)
      Returns the value of the attribute with the given attrName.
      java.lang.String[] getAttributeNames()
      Returns a list of attribute names.
      DOMWrapper[] getChildren()
      Returns all children of this element, including TEXT elements, as an array of DOMWrappers.
      DOMWrapper[] getElementChildren()
      Returns all element children of this element as an array of DOMWrappers.
      Location getLocation()
      Returns the location of this element.
      java.lang.String getTagName()
      Returns the tag name of this element, or null for TEXT elements.
      java.lang.String getText()
      Returns a flattened representation of the text inside thie element.
      int getType()
      Returns the type of this element/node.
      java.lang.String toXML()
      Returns this node serialized as XML.
    • Field Detail

      • UNKNOWN

        static final int UNKNOWN
        UNKNOWN is used for DOM Element types unsupported by the wrapper.
        See Also:
        Constant Field Values
      • FREETEXT

        static final int FREETEXT
        FREETEXT is a type of DOM Element representing a piece of text (but not a CDATA section). For example, Some text. FREETEXT elements always have a tag name of NULL and have no children. It maps to a TextDef.
        See Also:
        Constant Field Values
      • ELEMENT

        static final int ELEMENT
        ELEMENT is a type of DOM Element representing a named tag, possibly containing attributes, child elements, and text. It maps to a ElementDef (or a generated class derived from it), or a GenericDef.
        See Also:
        Constant Field Values
      • CDATA

        static final int CDATA
        CDATA is a type of DOM Element representing a piece of text embedded in a CDATA section, for example, <![CDATA[Some text]]>. CDATA elements always have a tag name of NULL and have no children. It maps to a CdataDef.
        See Also:
        Constant Field Values
    • Method Detail

      • getType

        int getType()
        Returns the type of this element/node. DOMWrapper supports only four possibilities: FREETEXT, ELEMENT, COMMENT, CDATA.
      • getTagName

        java.lang.String getTagName()
        Returns the tag name of this element, or null for TEXT elements.
      • getAttribute

        java.lang.String getAttribute​(java.lang.String attrName)
        Returns the value of the attribute with the given attrName. If the attribute is not defined, this method returns null.
      • getAttributeNames

        java.lang.String[] getAttributeNames()
        Returns a list of attribute names.
      • getText

        java.lang.String getText()
        Returns a flattened representation of the text inside thie element. For a TEXT element, this returns the text itself. For an ELEMENT element, this returns all pieces of text within the element, with all markup removed.
      • toXML

        java.lang.String toXML()
        Returns this node serialized as XML.
      • getChildren

        DOMWrapper[] getChildren()
        Returns all children of this element, including TEXT elements, as an array of DOMWrappers.
      • getElementChildren

        DOMWrapper[] getElementChildren()
        Returns all element children of this element as an array of DOMWrappers.
      • getLocation

        Location getLocation()
        Returns the location of this element.