Interface Tag
- All Known Implementing Classes:
CustomTag,Parser.ReusableToken
public interface Tag
Tag returned by HTMLTagTokenizer. Allows easy access to element name and attributes. This interface supports
read-only operations on the tag. To change a tag, use
CustomTag.- Author:
- Joe Walnes
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe close.static final intThe close magic comment.static final intThe empty.static final intThe open.static final intThe open magic comment. -
Method Summary
Modifier and TypeMethodDescriptionintNumber of attributes in tag.intgetAttributeIndex(String name, boolean caseSensitive) Determine which attribute has the specified name.getAttributeName(int index) Get name of attribute.getAttributeValue(int index) Get value of an attribute.getAttributeValue(String name, boolean caseSensitive) Get value of an attribute.Get the complete tag in its original form, preserving original formatting.intThe length of the tag.getName()Name of tag (ie.intThe position of the tag.intgetType()Type of tag:
<blah> - Tag.OPEN
</blah> - Tag.CLOSE
<blah/> - Tag.EMPTYbooleanhasAttribute(String name, boolean caseSensitive) Determine if an attribute is present.voidwriteTo(SitemeshBufferFragment.Builder fragment, int position) Write out the complete tag in its original form, preserving original formatting.
-
Field Details
-
OPEN
static final int OPENThe open.- See Also:
-
CLOSE
static final int CLOSEThe close.- See Also:
-
EMPTY
static final int EMPTYThe empty.- See Also:
-
OPEN_MAGIC_COMMENT
static final int OPEN_MAGIC_COMMENTThe open magic comment.- See Also:
-
CLOSE_MAGIC_COMMENT
static final int CLOSE_MAGIC_COMMENTThe close magic comment.- See Also:
-
-
Method Details
-
getContents
String getContents()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.- Returns:
- the contents
-
writeTo
Write out the complete tag in its original form, preserving original formatting.- Parameters:
fragment- the fragmentposition- the position
-
getName
String getName()Name of tag (ie. element name).- Returns:
- the name
-
getType
int getType()Type of tag:
<blah> - Tag.OPEN
</blah> - Tag.CLOSE
<blah/> - Tag.EMPTY- Returns:
- the type
-
getAttributeCount
int getAttributeCount()Number of attributes in tag.- Returns:
- the attribute count
-
getAttributeIndex
Determine which attribute has the specified name.- Parameters:
name- the namecaseSensitive- the case sensitive- Returns:
- the attribute index
-
getAttributeName
Get name of attribute.- Parameters:
index- the index- Returns:
- the attribute name
-
getAttributeValue
Get value of an attribute. If this is an empty attribute (i.e. just a name, without a value), null is returned.- Parameters:
index- the index- Returns:
- the attribute value
-
getAttributeValue
Get value of an attribute. If this is an empty attribute (i.e. just a name, without a value), null is returned.- Parameters:
name- the namecaseSensitive- the case sensitive- Returns:
- the attribute value
-
hasAttribute
Determine if an attribute is present.- Parameters:
name- the namecaseSensitive- the case sensitive- Returns:
- true, if successful
-
getPosition
int getPosition()The position of the tag.- Returns:
- the position
-
getLength
int getLength()The length of the tag.- Returns:
- the length
-