Class EndTag

    • Method Detail

      • getElement

        public Element getElement()
        Returns the element that is ended by this end tag.

        Returns null if this end tag is not properly matched to any start tag in the source document.

        This method is much less efficient than the StartTag.getElement() method.

        IMPLEMENTATION NOTE: The explanation for why this method is relatively inefficient lies in the fact that more than one start tag type can have the same corresponding end tag type, so it is not possible to know for certain which type of start tag this end tag is matched to (see EndTagType.getCorrespondingStartTagType() for more explanation). Because of this uncertainty, the implementation of this method must check every start tag preceding this end tag, calling its StartTag.getElement() method to see whether it is terminated by this end tag.

        Specified by:
        getElement in class Tag
        Returns:
        the element that is ended by this end tag.
      • getEndTagType

        public EndTagType getEndTagType()
        Returns the type of this end tag.

        This is equivalent to (EndTagType)getTagType().

        Returns:
        the type of this end tag.
      • getTagType

        public TagType getTagType()
        Description copied from class: Tag
        Returns the type of this tag.
        Specified by:
        getTagType in class Tag
        Returns:
        the type of this tag.
      • isUnregistered

        public boolean isUnregistered()
        Description copied from class: Tag
        Indicates whether this tag has a syntax that does not match any of the registered tag types.

        The only requirement of an unregistered tag type is that it starts with '<' and there is a closing '>' character at some position after it in the source document.

        The absence or presence of a '/' character after the initial '<' determines whether an unregistered tag is respectively a StartTag with a type of StartTagType.UNREGISTERED or an EndTag with a type of EndTagType.UNREGISTERED.

        There are no restrictions on the characters that might appear between these delimiters, including other '<' characters. This may result in a '>' character that is identified as the closing delimiter of two separate tags, one an unregistered tag, and the other a tag of any type that begins in the middle of the unregistered tag. As explained below, unregistered tags are usually only found when specifically looking for them, so it is up to the user to detect and deal with any such nonsensical results.

        Unregistered tags are only returned by the Source.getTagAt(int pos) method, named search methods, where the specified name matches the first characters inside the tag, and by tag type search methods, where the specified tagType is either StartTagType.UNREGISTERED or EndTagType.UNREGISTERED.

        Open tag searches and other searches always ignore unregistered tags, although every discovery of an unregistered tag is logged by the parser.

        The logic behind this design is that unregistered tag types are usually the result of a '<' character in the text that was mistakenly left unencoded, or a less-than operator inside a script, or some other occurrence which is of no interest to the user. By returning unregistered tags in named and tag type search methods, the library allows the user to specifically search for tags with a certain syntax that does not match any existing TagType. This expediency feature avoids the need for the user to create a custom tag type to define the syntax before searching for these tags. By not returning unregistered tags in the less specific search methods, it is providing only the information that most users are interested in.

        Specified by:
        isUnregistered in class Tag
        Returns:
        true if this tag has a syntax that does not match any of the registered tag types, otherwise false.
      • tidy

        public java.lang.String tidy()
        Returns an XML representation of this end tag.

        The tidying of the tag is carried out as follows:

        • if this end tag is a NORMAL end tag then any white space before the closing angle bracket is removed.
        • otherwise the original source text of the entire tag is returned.
        Specified by:
        tidy in class Tag
        Returns:
        an XML representation of this end tag.
        See Also:
        StartTag.tidy()
      • 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.