Class ParsedTag

java.lang.Object
jodd.lagarto.ParsedTag
All Implemented Interfaces:
Tag

class ParsedTag extends Object implements Tag
Reusable, parsed tag implementation. Only one instance created and it is reused.
  • Field Details

    • ATTR_NAME_ID

      private static final CharSequence ATTR_NAME_ID
    • caseSensitive

      private boolean caseSensitive
    • rawTag

      private boolean rawTag
    • name

      private CharSequence name
    • idNdx

      private int idNdx
    • type

      private TagType type
    • attributesCount

      private int attributesCount
    • attrNames

      private CharSequence[] attrNames
    • attrValues

      private CharSequence[] attrValues
    • tagStartIndex

      private int tagStartIndex
    • tagLength

      private int tagLength
    • position

      private String position
    • deepLevel

      private int deepLevel
    • modified

      private boolean modified
  • Constructor Details

    • ParsedTag

      ParsedTag()
  • Method Details

    • init

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

      public void start(int startIndex)
      Starts the tag with the index of first 'invalid input: '<''. 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 CharSequence getName()
      Description copied from interface: Tag
      Returns tags name.
      Specified by:
      getName in interface Tag
    • getId

      public 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 CharSequence getAttributeName(int index)
      Description copied from interface: Tag
      Returns attribute name.
      Specified by:
      getAttributeName in interface Tag
    • getAttributeValue

      public 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 CharSequence getAttributeValue(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(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(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 String getPosition()
      Description copied from interface: Tag
      Returns tag position string or null if position is not calculated.
      Specified by:
      getPosition in interface Tag
    • setPosition

      public void setPosition(CharsInput.Position position)
    • setName

      public void setName(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(CharSequence name, 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(CharSequence name, 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, 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(CharSequence name, 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, 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(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(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, CharSequence name, CharSequence value)
    • setAttrVal

      private void setAttrVal(int index, CharSequence value)
    • appendTo

      private void appendTo(Appendable out)
    • writeTo

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

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