Class CustomTag
java.lang.Object
com.opensymphony.module.sitemesh.html.CustomTag
- All Implemented Interfaces:
Tag
A CustomTag provides a mechanism to manipulate the contents of a Tag. The standard Tag implementations
are immutable, however CustomTag allows a copy to be taken of an immutable Tag that can then be manipulated.
- Author:
- Joe Walnes
- See Also:
-
Field Summary
FieldsFields inherited from interface com.opensymphony.module.sitemesh.html.Tag
CLOSE, CLOSE_MAGIC_COMMENT, EMPTY, OPEN, OPEN_MAGIC_COMMENT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
addAttribute
(String name, String value) Add a new attribute.boolean
int
Number of attributes in tag.int
getAttributeIndex
(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.getName()
Name of tag (ie.int
getType()
Type of tag:
<blah> - Tag.OPEN
</blah> - Tag.CLOSE
<blah/> - Tag.EMPTYprivate void
boolean
hasAttribute
(String name, boolean caseSensitive) Determine if an attribute is present.int
hashCode()
void
removeAttribute
(int attributeIndex) Remove an attribute.void
removeAttribute
(String name, boolean caseSensitive) Change the value of an attribute, or add an attribute if it does not already exist.void
setAttributeName
(int attributeIndex, String name) Change the name of an existing attribute.void
setAttributeValue
(int attributeIndex, String value) Change the value of an existing attribute.void
setAttributeValue
(String name, boolean caseSensitive, String value) Change the value of an attribute, or add an attribute if it does not already exist.void
Change the name of the attribute.void
setType
(int type) Change the type of the tag.toString()
void
Write out the complete tag in its original form, preserving original formatting.
-
Field Details
-
attributes
-
attributeCount
private int attributeCount -
name
-
type
private int type
-
-
Constructor Details
-
CustomTag
Type of tag:
<blah> - Tag.OPEN
</blah> - Tag.CLOSE
<blah/> - Tag.EMPTY -
CustomTag
Create a CustomTag based on an existing Tag - this takes a copy of the Tag.
-
-
Method Details
-
getContents
Description copied from interface:Tag
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.- Specified by:
getContents
in interfaceTag
- See Also:
-
writeTo
Description copied from interface:Tag
Write out the complete tag in its original form, preserving original formatting. -
equals
-
hashCode
public int hashCode() -
toString
-
getAttributeCount
public int getAttributeCount()Description copied from interface:Tag
Number of attributes in tag.- Specified by:
getAttributeCount
in interfaceTag
-
getAttributeIndex
Description copied from interface:Tag
Determine which attribute has the specified name.- Specified by:
getAttributeIndex
in interfaceTag
-
getAttributeName
Description copied from interface:Tag
Get name of attribute.- Specified by:
getAttributeName
in interfaceTag
-
getAttributeValue
Description copied from interface:Tag
Get value of an attribute. If this is an empty attribute (i.e. just a name, without a value), null is returned.- Specified by:
getAttributeValue
in interfaceTag
-
getAttributeValue
Description copied from interface:Tag
Get value of an attribute. If this is an empty attribute (i.e. just a name, without a value), null is returned.- Specified by:
getAttributeValue
in interfaceTag
-
hasAttribute
Description copied from interface:Tag
Determine if an attribute is present.- Specified by:
hasAttribute
in interfaceTag
-
getName
Description copied from interface:Tag
Name of tag (ie. element name). -
getType
public int getType()Type of tag:
<blah> - Tag.OPEN
</blah> - Tag.CLOSE
<blah/> - Tag.EMPTY -
setName
Change the name of the attribute. -
setType
public void setType(int type) Change the type of the tag. Type of tag:
<blah> - Tag.OPEN
</blah> - Tag.CLOSE
<blah/> - Tag.EMPTY -
growAttributes
private void growAttributes() -
addAttribute
Add a new attribute. This does not check for the existence of an attribute with the same name, thus allowing duplicate attributes.- Parameters:
name
- Name of attribute to change.value
- New value of attribute or null for an HTML style empty attribute.- Returns:
- Index of new attribute.
-
setAttributeValue
Change the value of an attribute, or add an attribute if it does not already exist.- Parameters:
name
- Name of attribute to change.caseSensitive
- Whether the name should be treated as case sensitive when searching for an existing value.value
- New value of attribute or null for an HTML style empty attribute.
-
setAttributeName
Change the name of an existing attribute. -
setAttributeValue
Change the value of an existing attribute. The value may be null for an HTML style empty attribute. -
removeAttribute
public void removeAttribute(int attributeIndex) Remove an attribute. -
removeAttribute
Change the value of an attribute, or add an attribute if it does not already exist.- Parameters:
name
- Name of attribute to remove.caseSensitive
- Whether the name should be treated as case sensitive.
-