org.sitemesh.tagprocessor
Interface Tag

All Known Implementing Classes:
CustomTag, TagTokenizer.ReusableToken

public interface Tag

Tag returned by TagTokenizer. Allows easy access to element name and attributes. This interface supports read-only operations on the tag. To change a tag, create a new CustomTag.

Author:
Joe Walnes

Nested Class Summary
static class Tag.Type
          Type of tag.
 
Method Summary
 int getAttributeCount()
          Number of attributes in tag.
 int getAttributeIndex(String name, boolean caseSensitive)
          Determine which attribute has the specified name.
 String getAttributeName(int index)
          Get name of attribute.
 String getAttributeValue(int index)
          Get value of an attribute.
 String getAttributeValue(String name, boolean caseSensitive)
          Get value of an attribute.
 String getName()
          Name of tag (ie.
 Tag.Type getType()
          Type of tag (e.g.
 boolean hasAttribute(String name, boolean caseSensitive)
          Determine if an attribute is present.
 String toString()
          Get the complete tag in its original form, preserving original formatting.
 void writeTo(Appendable out)
          Write out the complete tag in its original form, preserving original formatting.
 

Method Detail

writeTo

void writeTo(Appendable out)
             throws IOException
Write out the complete tag in its original form, preserving original formatting.

Throws:
IOException

getName

String getName()
Name of tag (ie. element name).


getType

Tag.Type getType()
Type of tag (e.g. open, close, etc).

See Also:
Tag.Type

getAttributeCount

int getAttributeCount()
Number of attributes in tag.


getAttributeIndex

int getAttributeIndex(String name,
                      boolean caseSensitive)
Determine which attribute has the specified name.


getAttributeName

String getAttributeName(int index)
Get name of attribute.


getAttributeValue

String getAttributeValue(int index)
Get value of an attribute. If this is an empty attribute (i.e. just a name, without a value), null is returned.


getAttributeValue

String getAttributeValue(String name,
                         boolean caseSensitive)
Get value of an attribute. If this is an empty attribute (i.e. just a name, without a value), null is returned.


hasAttribute

boolean hasAttribute(String name,
                     boolean caseSensitive)
Determine if an attribute is present.


toString

String toString()
Get the complete tag in its original form, preserving original formatting.

This has a slight overhead in that it needs to construct a String. For improved performance, use writeTo() instead.

Overrides:
toString in class Object
See Also:
writeTo(Appendable)


Copyright © 2011. All Rights Reserved.