Class Element

    • Method Detail

      • getParentElement

        public Element getParentElement()
        Returns the parent of this element in the document element hierarchy.

        The Source.fullSequentialParse() method must be called (either explicitly or implicitly) immediately after construction of the Source object if this method is to be used. An IllegalStateException is thrown if a full sequential parse has not been performed or if it was performed after this element was found.

        This method returns null for a top-level element, as well as any element formed from a server tag, regardless of whether it is nested inside a normal element.

        See the Source.getChildElements() method for more details.

        Returns:
        the parent of this element in the document element hierarchy, or null if this element is a top-level element.
        Throws:
        java.lang.IllegalStateException - if a full sequential parse has not been performed or if it was performed after this element was found.
        See Also:
        getChildElements()
      • getChildElements

        public final java.util.List<Element> getChildElements()
        Returns a list of the immediate children of this element in the document element hierarchy.

        The objects in the list are all of type Element.

        See the Source.getChildElements() method for more details.

        Overrides:
        getChildElements in class Segment
        Returns:
        a list of the immediate children of this element in the document element hierarchy, guaranteed not null.
        See Also:
        getParentElement()
      • getDepth

        public int getDepth()
        Returns the nesting depth of this element in the document element hierarchy.

        The Source.fullSequentialParse() method must be called (either explicitly or implicitly) after construction of the Source object if this method is to be used. An IllegalStateException is thrown if a full sequential parse has not been performed or if it was performed after this element was found.

        A top-level element has a nesting depth of 0.

        An element formed from a server tag always have a nesting depth of 0, regardless of whether it is nested inside a normal element.

        See the Source.getChildElements() method for more details.

        Returns:
        the nesting depth of this element in the document element hierarchy.
        Throws:
        java.lang.IllegalStateException - if a full sequential parse has not been performed or if it was performed after this element was found.
        See Also:
        getParentElement()
      • getContent

        public Segment getContent()
        Returns the segment representing the content of the element.

        This segment spans between the end of the start tag and the start of the end tag. If the end tag is not present, the content reaches to the end of the element.

        A zero-length segment is returned if the element is empty,

        Returns:
        the segment representing the content of the element, guaranteed not null.
      • getStartTag

        public StartTag getStartTag()
        Returns the start tag of the element.
        Returns:
        the start tag of the element.
      • getEndTag

        public EndTag getEndTag()
        Returns the end tag of the element.

        If the element has no end tag this method returns null.

        Returns:
        the end tag of the element, or null if the element has no end tag.
      • getName

        public java.lang.String getName()
        Returns the name of the start tag of this element, always in lower case.

        This is equivalent to getStartTag().getName().

        See the Tag.getName() method for more information.

        Returns:
        the name of the start tag of this element, always in lower case.
      • getDebugInfo

        public java.lang.String getDebugInfo()
        Description copied from class: Segment
        Returns a string representation of this object useful for debugging purposes.
        Overrides:
        getDebugInfo in class Segment
        Returns:
        a string representation of this object useful for debugging purposes.