Package jodd.lagarto

Class ParsedTag

  • All Implemented Interfaces:
    Tag

    class ParsedTag
    extends java.lang.Object
    implements Tag
    Reusable, parsed tag implementation. Only one instance created and it is reused.
    • Constructor Summary

      Constructors 
      Constructor Description
      ParsedTag()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAttribute​(java.lang.CharSequence name, java.lang.CharSequence value)
      Adds new attribute without checking if it already exist thus allowing duplicate attributes.
      private void appendTo​(java.lang.Appendable out)  
      (package private) void decreaseDeepLevel()  
      (package private) void end​(int endIndex)
      Defines tag end with index of last '>'.
      private void ensureLength()  
      int getAttributeCount()
      Returns number of tag attributes.
      int getAttributeIndex​(java.lang.CharSequence name)
      Returns attribute index or -1 if not found.
      java.lang.CharSequence getAttributeName​(int index)
      Returns attribute name.
      java.lang.CharSequence getAttributeValue​(int index)
      Returns attribute value or null for an empty attribute,
      java.lang.CharSequence getAttributeValue​(java.lang.CharSequence name)
      Returns attribute value or null for an empty attribute, Returns null also if attribute name does not exist.
      int getDeepLevel()
      Returns 1-based deep level of a tag from the root.
      java.lang.CharSequence getId()
      Returns id attribute value of a tag.
      java.lang.CharSequence getName()
      Returns tags name.
      java.lang.String getPosition()
      Returns tag position string or null if position is not calculated.
      int getTagLength()
      Returns tag length in the input source.
      int getTagPosition()
      Returns tag position in the input source.
      TagType getType()
      Returns type of tag (e.g.
      boolean hasAttribute​(java.lang.CharSequence name)
      Detects if an attribute is present.
      (package private) void increaseDeepLevel()  
      void init​(boolean caseSensitive)
      Initializes the instance.
      boolean isCaseSensitive()
      Returns case-sensitive flag for various name matching.
      boolean isModified()
      Returns true if tag is modified.
      boolean isRawTag()
      Returns true if tag should parse inner text content as RAWTEXT.
      boolean nameEquals​(java.lang.CharSequence charSequence)
      Returns true if name equals to given char sequence.
      void removeAttribute​(int index)
      Removes attribute at given index.
      void removeAttribute​(java.lang.CharSequence name)
      Removes attribute by given name.
      void removeAttributes()
      Removes all attributes.
      void setAttribute​(java.lang.CharSequence name, java.lang.CharSequence value)
      Sets new attribute value.
      void setAttributeName​(int index, java.lang.CharSequence name)
      Changes attribute name on specific index.
      void setAttributeValue​(int index, java.lang.CharSequence value)
      Sets value for attribute at specific index.
      void setAttributeValue​(java.lang.CharSequence name, java.lang.CharSequence value)
      Sets value for attribute with given name.
      private void setAttrVal​(int index, java.lang.CharSequence value)  
      private void setAttrVal​(int index, java.lang.CharSequence name, java.lang.CharSequence value)  
      void setName​(java.lang.CharSequence tagName)
      Sets tag name.
      void setPosition​(CharsInput.Position position)  
      void setRawTag​(boolean isRawTag)  
      void setType​(TagType type)
      Sets tag type.
      void start​(int startIndex)
      Starts the tag with the index of first '<'.
      java.lang.String toString()
      Get the complete tag as a string.
      void writeTo​(java.lang.Appendable out)
      Writes the tag to the output.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ATTR_NAME_ID

        private static final java.lang.CharSequence ATTR_NAME_ID
      • caseSensitive

        private boolean caseSensitive
      • rawTag

        private boolean rawTag
      • name

        private java.lang.CharSequence name
      • idNdx

        private int idNdx
      • attributesCount

        private int attributesCount
      • attrNames

        private java.lang.CharSequence[] attrNames
      • attrValues

        private java.lang.CharSequence[] attrValues
      • tagStartIndex

        private int tagStartIndex
      • tagLength

        private int tagLength
      • position

        private java.lang.String position
      • deepLevel

        private int deepLevel
      • modified

        private boolean modified
    • Constructor Detail

      • ParsedTag

        ParsedTag()
    • Method Detail

      • init

        public void init​(boolean caseSensitive)
        Initializes the instance.
      • start

        public void start​(int startIndex)
        Starts the tag with the index of first '<'. Resets all tag data.
      • end

        void end​(int endIndex)
        Defines tag end with index of last '>'. Sets the modification flag to false.
      • increaseDeepLevel

        void increaseDeepLevel()
      • decreaseDeepLevel

        void decreaseDeepLevel()
      • isCaseSensitive

        public boolean isCaseSensitive()
        Description copied from interface: Tag
        Returns case-sensitive flag for various name matching.
        Specified by:
        isCaseSensitive in interface Tag
      • isRawTag

        public boolean isRawTag()
        Description copied from interface: Tag
        Returns true if tag should parse inner text content as RAWTEXT.
        Specified by:
        isRawTag in interface Tag
      • setRawTag

        public void setRawTag​(boolean isRawTag)
      • getName

        public java.lang.CharSequence getName()
        Description copied from interface: Tag
        Returns tags name.
        Specified by:
        getName in interface Tag
      • getId

        public java.lang.CharSequence getId()
        Description copied from interface: Tag
        Returns id attribute value of a tag. Implementations may simply call Tag.getAttributeValue(java.lang.CharSequence) or to cache this value for better performances.
        Specified by:
        getId in interface Tag
      • getType

        public TagType getType()
        Description copied from interface: Tag
        Returns type of tag (e.g. open, close, etc).
        Specified by:
        getType in interface Tag
      • getDeepLevel

        public int getDeepLevel()
        Description copied from interface: Tag
        Returns 1-based deep level of a tag from the root.
        Specified by:
        getDeepLevel in interface Tag
      • getAttributeCount

        public int getAttributeCount()
        Description copied from interface: Tag
        Returns number of tag attributes.
        Specified by:
        getAttributeCount in interface Tag
      • getAttributeName

        public java.lang.CharSequence getAttributeName​(int index)
        Description copied from interface: Tag
        Returns attribute name.
        Specified by:
        getAttributeName in interface Tag
      • getAttributeValue

        public java.lang.CharSequence getAttributeValue​(int index)
        Description copied from interface: Tag
        Returns attribute value or null for an empty attribute,
        Specified by:
        getAttributeValue in interface Tag
      • getAttributeValue

        public java.lang.CharSequence getAttributeValue​(java.lang.CharSequence name)
        Description copied from interface: Tag
        Returns attribute value or null for an empty attribute, Returns null also if attribute name does not exist.
        Specified by:
        getAttributeValue in interface Tag
      • getAttributeIndex

        public int getAttributeIndex​(java.lang.CharSequence name)
        Description copied from interface: Tag
        Returns attribute index or -1 if not found.
        Specified by:
        getAttributeIndex in interface Tag
      • hasAttribute

        public boolean hasAttribute​(java.lang.CharSequence name)
        Description copied from interface: Tag
        Detects if an attribute is present.
        Specified by:
        hasAttribute in interface Tag
      • getTagPosition

        public int getTagPosition()
        Description copied from interface: Tag
        Returns tag position in the input source.
        Specified by:
        getTagPosition in interface Tag
      • getTagLength

        public int getTagLength()
        Description copied from interface: Tag
        Returns tag length in the input source.
        Specified by:
        getTagLength in interface Tag
      • getPosition

        public java.lang.String getPosition()
        Description copied from interface: Tag
        Returns tag position string or null if position is not calculated.
        Specified by:
        getPosition in interface Tag
      • setName

        public void setName​(java.lang.CharSequence tagName)
        Description copied from interface: Tag
        Sets tag name.
        Specified by:
        setName in interface Tag
      • setType

        public void setType​(TagType type)
        Description copied from interface: Tag
        Sets tag type.
        Specified by:
        setType in interface Tag
      • addAttribute

        public void addAttribute​(java.lang.CharSequence name,
                                 java.lang.CharSequence value)
        Description copied from interface: Tag
        Adds new attribute without checking if it already exist thus allowing duplicate attributes.
        Specified by:
        addAttribute in interface Tag
      • setAttribute

        public void setAttribute​(java.lang.CharSequence name,
                                 java.lang.CharSequence value)
        Description copied from interface: Tag
        Sets new attribute value. If attribute already exist, it's value is changed. If attribute does not exist, it will be added to the tag.
        Specified by:
        setAttribute in interface Tag
      • setAttributeValue

        public void setAttributeValue​(int index,
                                      java.lang.CharSequence value)
        Description copied from interface: Tag
        Sets value for attribute at specific index. Throws exception if index is invalid.
        Specified by:
        setAttributeValue in interface Tag
      • setAttributeValue

        public void setAttributeValue​(java.lang.CharSequence name,
                                      java.lang.CharSequence value)
        Description copied from interface: Tag
        Sets value for attribute with given name. If attribute with given name doesn't exist, nothing changes.
        Specified by:
        setAttributeValue in interface Tag
      • setAttributeName

        public void setAttributeName​(int index,
                                     java.lang.CharSequence name)
        Description copied from interface: Tag
        Changes attribute name on specific index. Throws exception if index is invalid.
        Specified by:
        setAttributeName in interface Tag
      • removeAttribute

        public void removeAttribute​(int index)
        Description copied from interface: Tag
        Removes attribute at given index. Throws exception if index is invalid.
        Specified by:
        removeAttribute in interface Tag
      • removeAttribute

        public void removeAttribute​(java.lang.CharSequence name)
        Description copied from interface: Tag
        Removes attribute by given name.
        Specified by:
        removeAttribute in interface Tag
      • removeAttributes

        public void removeAttributes()
        Description copied from interface: Tag
        Removes all attributes.
        Specified by:
        removeAttributes in interface Tag
      • isModified

        public boolean isModified()
        Description copied from interface: Tag
        Returns true if tag is modified.
        Specified by:
        isModified in interface Tag
      • nameEquals

        public boolean nameEquals​(java.lang.CharSequence charSequence)
        Description copied from interface: Tag
        Returns true if name equals to given char sequence.
        Specified by:
        nameEquals in interface Tag
      • ensureLength

        private void ensureLength()
      • setAttrVal

        private void setAttrVal​(int index,
                                java.lang.CharSequence name,
                                java.lang.CharSequence value)
      • setAttrVal

        private void setAttrVal​(int index,
                                java.lang.CharSequence value)
      • appendTo

        private void appendTo​(java.lang.Appendable out)
      • writeTo

        public void writeTo​(java.lang.Appendable out)
        Description copied from interface: Tag
        Writes the tag to the output.
        Specified by:
        writeTo in interface Tag
      • toString

        public java.lang.String toString()
        Description copied from interface: Tag
        Get the complete tag as a string.
        Specified by:
        toString in interface Tag
        Overrides:
        toString in class java.lang.Object