|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjodd.servlet.HtmlTag
public class HtmlTag
Very simple utility for working with HTML tag's names and attributes.
| Field Summary | |
|---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
attributes
|
protected int |
attrStartIndex
|
protected boolean |
changed
|
protected int |
firstIndex
|
protected boolean |
isClosedTag
|
protected boolean |
isEndTag
|
protected int |
lastIndex
|
protected int |
nextIndex
|
protected int |
startIndex
|
protected java.lang.String |
suffix
|
protected java.lang.String |
tag
|
static char |
TAG_END
|
static char |
TAG_START
|
protected java.lang.String |
tagName
|
| Constructor Summary | |
|---|---|
|
HtmlTag(java.lang.String tag)
|
protected |
HtmlTag(java.lang.String tag,
int startIndex,
int nextIndex)
|
| Method Summary | |
|---|---|
java.lang.String |
getAttribute(java.lang.String attrName)
Returns attribute value or null if
attribute value doesn't exist. |
int |
getNextIndex()
Returns next index for location start. |
int |
getStartIndex()
Returns start index of the tag. |
java.lang.String |
getTag()
Returns unchanged tag content. |
java.lang.String |
getTagName()
Returns tag's name. |
boolean |
hasAttribute(java.lang.String attrName)
Returns true if attribute is included in the tag. |
boolean |
isClosedTag()
Returns true if tag is closed (ends with '/>'). |
boolean |
isEndTag()
Returns true if tag is closing tag. |
static HtmlTag |
locateNextTag(java.lang.String html,
int start)
Locates HTML tag in specified source. |
void |
removeAttribute(java.lang.String attrName)
Removes attribute from the tag. |
protected void |
resolveAttributes()
Resolves attributes from tag's body. |
java.lang.String |
resolveTag()
Resolves tag. |
protected java.lang.String |
resolveTagName()
Resolves tag name from tag's body. |
void |
setAttribute(java.lang.String name)
Adds single attribute without value to a tag. |
void |
setAttribute(java.lang.String name,
java.lang.String value)
Adds attribute and its value to a tag. |
void |
setSuffixText(java.lang.String suffix)
Adds suffix text that will be appended after the tags end. |
java.lang.String |
toString()
|
int |
totalAttributes()
Returns total number of attributes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final char TAG_START
public static final char TAG_END
protected final java.lang.String tag
protected final int nextIndex
protected final int firstIndex
protected final int lastIndex
protected final boolean isClosedTag
protected final boolean isEndTag
protected final int startIndex
protected java.lang.String tagName
protected int attrStartIndex
protected java.util.Map<java.lang.String,java.lang.String> attributes
protected boolean changed
protected java.lang.String suffix
| Constructor Detail |
|---|
public HtmlTag(java.lang.String tag)
protected HtmlTag(java.lang.String tag,
int startIndex,
int nextIndex)
| Method Detail |
|---|
public static HtmlTag locateNextTag(java.lang.String html,
int start)
public java.lang.String getTag()
public int getNextIndex()
public int getStartIndex()
public boolean isClosedTag()
true if tag is closed (ends with '/>').
public boolean isEndTag()
true if tag is closing tag.
public java.lang.String getTagName()
protected java.lang.String resolveTagName()
public java.lang.String getAttribute(java.lang.String attrName)
null if
attribute value doesn't exist.
public boolean hasAttribute(java.lang.String attrName)
true if attribute is included in the tag.
public void removeAttribute(java.lang.String attrName)
public void setAttribute(java.lang.String name,
java.lang.String value)
public void setAttribute(java.lang.String name)
public int totalAttributes()
protected void resolveAttributes()
public void setSuffixText(java.lang.String suffix)
public java.lang.String resolveTag()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||