jodd.lagarto
Interface Tag


public interface Tag

Tag information.


Method Summary
 void addAttribute(java.lang.String name, java.lang.String value)
          Adds new attribute without checking if it already exist thus allowing duplicate attributes.
 int getAttributeCount()
          Returns number of tag attributes.
 int getAttributeIndex(java.lang.String name, boolean caseSensitive)
          Returns attribute index or -1 if not found.
 java.lang.String getAttributeName(int index)
          Returns attribute name.
 java.lang.String getAttributeValue(int index)
          Returns attribute value or null for an empty attribute,
 java.lang.String getAttributeValue(java.lang.String name, boolean caseSensitive)
          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.String getId()
          Returns id attribute value of a tag.
 java.lang.String getName()
          Returns tags name.
 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. open, close, etc).
 boolean hasAttribute(java.lang.String name, boolean caseSensitive)
          Detects if an attribute is present.
 boolean isModified()
          Returns true if tag is modified.
 void removeAttribute(int index)
          Removes attribute.
 void removeAttribute(java.lang.String name, boolean caseSensitive)
          Removes attribute.
 void removeAttributes()
          Removes all attributes.
 void setAttribute(java.lang.String name, boolean caseSensitive, java.lang.String value)
          Sets new attribute value.
 void setAttributeName(int index, java.lang.String name)
          Changes attribute name on specific index.
 void setAttributeValue(int index, java.lang.String value)
          Sets value for attribute at specific index.
 void setAttributeValue(java.lang.String name, boolean caseSensitive, java.lang.String value)
          Sets value for attribute at specific index.
 void setModified()
          Force isModified() to be true.
 void setName(java.lang.String tagName)
          Sets new tag name.
 void setType(TagType type)
          Sets new tag type.
 java.lang.String toString()
          Get the complete tag.
 void writeTo(java.lang.Appendable out)
          Shortcut for writeTo(out, false).
 void writeTo(java.lang.Appendable out, boolean forceBuild)
          Write out the complete tag.
 

Method Detail

getName

java.lang.String getName()
Returns tags name.


getType

TagType getType()
Returns type of tag (e.g. open, close, etc).


getId

java.lang.String getId()
Returns id attribute value of a tag. Implementations may simply call getAttributeValue(String, boolean) or to cache this value for better performances.


getDeepLevel

int getDeepLevel()
Returns 1-based deep level of a tag from the root.


getAttributeCount

int getAttributeCount()
Returns number of tag attributes.


getAttributeName

java.lang.String getAttributeName(int index)
Returns attribute name.


getAttributeValue

java.lang.String getAttributeValue(int index)
Returns attribute value or null for an empty attribute,


getAttributeValue

java.lang.String getAttributeValue(java.lang.String name,
                                   boolean caseSensitive)
Returns attribute value or null for an empty attribute, Returns null also if attribute name does not exist.


getAttributeIndex

int getAttributeIndex(java.lang.String name,
                      boolean caseSensitive)
Returns attribute index or -1 if not found.


hasAttribute

boolean hasAttribute(java.lang.String name,
                     boolean caseSensitive)
Detects if an attribute is present.


getTagPosition

int getTagPosition()
Returns tag position in the input source.


getTagLength

int getTagLength()
Returns tag length in the input source.


setName

void setName(java.lang.String tagName)
Sets new tag name.


setType

void setType(TagType type)
Sets new tag type.


addAttribute

void addAttribute(java.lang.String name,
                  java.lang.String value)
Adds new attribute without checking if it already exist thus allowing duplicate attributes.


setAttribute

void setAttribute(java.lang.String name,
                  boolean caseSensitive,
                  java.lang.String value)
Sets new attribute value. If attribute already exist, it's value is changed. If attribute does not exist, it will be added to the list.


setAttributeValue

void setAttributeValue(int index,
                       java.lang.String value)
Sets value for attribute at specific index.


setAttributeValue

void setAttributeValue(java.lang.String name,
                       boolean caseSensitive,
                       java.lang.String value)
Sets value for attribute at specific index.


setAttributeName

void setAttributeName(int index,
                      java.lang.String name)
Changes attribute name on specific index.


removeAttribute

void removeAttribute(int index)
Removes attribute.


removeAttribute

void removeAttribute(java.lang.String name,
                     boolean caseSensitive)
Removes attribute.


removeAttributes

void removeAttributes()
Removes all attributes.


isModified

boolean isModified()
Returns true if tag is modified.


setModified

void setModified()
Force isModified() to be true. Used when tags needs to be regenerated.


writeTo

void writeTo(java.lang.Appendable out)
             throws java.io.IOException
Shortcut for writeTo(out, false).

Throws:
java.io.IOException

writeTo

void writeTo(java.lang.Appendable out,
             boolean forceBuild)
             throws java.io.IOException
Write out the complete tag. There are two modes how tag can be written.
  • optimized - if tag is not modified it will be written in its original form. otherwise it will be generated.
  • force build - tag will be always build from tag name and attributes. Resulting tag may be different than source.

    Throws:
    java.io.IOException

  • toString

    java.lang.String toString()
    Get the complete tag.

    This is a bit slower method in that it needs to construct a String and generates tag always. Use it for debugging purposes.

    Overrides:
    toString in class java.lang.Object


    Copyright © 2003-2012 Jodd Team