Package jodd.lagarto
Class ParsedTag
- java.lang.Object
-
- jodd.lagarto.ParsedTag
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.CharSequenceATTR_NAME_IDprivate intattributesCountprivate java.lang.CharSequence[]attrNamesprivate java.lang.CharSequence[]attrValuesprivate booleancaseSensitiveprivate intdeepLevelprivate intidNdxprivate booleanmodifiedprivate java.lang.CharSequencenameprivate java.lang.Stringpositionprivate booleanrawTagprivate inttagLengthprivate inttagStartIndexprivate TagTypetype
-
Constructor Summary
Constructors Constructor Description ParsedTag()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(java.lang.CharSequence name, java.lang.CharSequence value)Adds new attribute without checking if it already exist thus allowing duplicate attributes.private voidappendTo(java.lang.Appendable out)(package private) voiddecreaseDeepLevel()(package private) voidend(int endIndex)Defines tag end with index of last '>'.private voidensureLength()intgetAttributeCount()Returns number of tag attributes.intgetAttributeIndex(java.lang.CharSequence name)Returns attribute index or-1if not found.java.lang.CharSequencegetAttributeName(int index)Returns attribute name.java.lang.CharSequencegetAttributeValue(int index)Returns attribute value ornullfor an empty attribute,java.lang.CharSequencegetAttributeValue(java.lang.CharSequence name)Returns attribute value ornullfor an empty attribute, Returnsnullalso if attribute name does not exist.intgetDeepLevel()Returns 1-based deep level of a tag from the root.java.lang.CharSequencegetId()Returns id attribute value of a tag.java.lang.CharSequencegetName()Returns tags name.java.lang.StringgetPosition()Returns tag position string ornullif position is not calculated.intgetTagLength()Returns tag length in the input source.intgetTagPosition()Returns tag position in the input source.TagTypegetType()Returnstype of tag(e.g.booleanhasAttribute(java.lang.CharSequence name)Detects if an attribute is present.(package private) voidincreaseDeepLevel()voidinit(boolean caseSensitive)Initializes the instance.booleanisCaseSensitive()Returns case-sensitive flag for various name matching.booleanisModified()Returnstrueif tag is modified.booleanisRawTag()Returnstrueif tag should parse inner text content as RAWTEXT.booleannameEquals(java.lang.CharSequence charSequence)Returnstrueif name equals to given char sequence.voidremoveAttribute(int index)Removes attribute at given index.voidremoveAttribute(java.lang.CharSequence name)Removes attribute by given name.voidremoveAttributes()Removes all attributes.voidsetAttribute(java.lang.CharSequence name, java.lang.CharSequence value)Sets new attribute value.voidsetAttributeName(int index, java.lang.CharSequence name)Changes attribute name on specific index.voidsetAttributeValue(int index, java.lang.CharSequence value)Sets value for attribute at specific index.voidsetAttributeValue(java.lang.CharSequence name, java.lang.CharSequence value)Sets value for attribute with given name.private voidsetAttrVal(int index, java.lang.CharSequence value)private voidsetAttrVal(int index, java.lang.CharSequence name, java.lang.CharSequence value)voidsetName(java.lang.CharSequence tagName)Sets tag name.voidsetPosition(CharsInput.Position position)voidsetRawTag(boolean isRawTag)voidsetType(TagType type)Setstag type.voidstart(int startIndex)Starts the tag with the index of first '<'.java.lang.StringtoString()Get the complete tag as a string.voidwriteTo(java.lang.Appendable out)Writes the tag to the output.
-
-
-
Field Detail
-
ATTR_NAME_ID
private static final java.lang.CharSequence ATTR_NAME_ID
-
caseSensitive
private boolean caseSensitive
-
rawTag
private boolean rawTag
-
name
private java.lang.CharSequence name
-
idNdx
private int idNdx
-
type
private TagType type
-
attributesCount
private int attributesCount
-
attrNames
private java.lang.CharSequence[] attrNames
-
attrValues
private java.lang.CharSequence[] attrValues
-
tagStartIndex
private int tagStartIndex
-
tagLength
private int tagLength
-
position
private java.lang.String position
-
deepLevel
private int deepLevel
-
modified
private boolean modified
-
-
Method Detail
-
init
public void init(boolean caseSensitive)
Initializes the instance.
-
start
public void start(int startIndex)
Starts the tag with the index of first '<'. Resets all tag data.
-
end
void end(int endIndex)
Defines tag end with index of last '>'. Sets the modification flag tofalse.
-
increaseDeepLevel
void increaseDeepLevel()
-
decreaseDeepLevel
void decreaseDeepLevel()
-
isCaseSensitive
public boolean isCaseSensitive()
Description copied from interface:TagReturns case-sensitive flag for various name matching.- Specified by:
isCaseSensitivein interfaceTag
-
isRawTag
public boolean isRawTag()
Description copied from interface:TagReturnstrueif tag should parse inner text content as RAWTEXT.
-
setRawTag
public void setRawTag(boolean isRawTag)
-
getName
public java.lang.CharSequence getName()
Description copied from interface:TagReturns tags name.
-
getId
public java.lang.CharSequence getId()
Description copied from interface:TagReturns id attribute value of a tag. Implementations may simply callTag.getAttributeValue(java.lang.CharSequence)or to cache this value for better performances.
-
getType
public TagType getType()
Description copied from interface:TagReturnstype of tag(e.g. open, close, etc).
-
getDeepLevel
public int getDeepLevel()
Description copied from interface:TagReturns 1-based deep level of a tag from the root.- Specified by:
getDeepLevelin interfaceTag
-
getAttributeCount
public int getAttributeCount()
Description copied from interface:TagReturns number of tag attributes.- Specified by:
getAttributeCountin interfaceTag
-
getAttributeName
public java.lang.CharSequence getAttributeName(int index)
Description copied from interface:TagReturns attribute name.- Specified by:
getAttributeNamein interfaceTag
-
getAttributeValue
public java.lang.CharSequence getAttributeValue(int index)
Description copied from interface:TagReturns attribute value ornullfor an empty attribute,- Specified by:
getAttributeValuein interfaceTag
-
getAttributeValue
public java.lang.CharSequence getAttributeValue(java.lang.CharSequence name)
Description copied from interface:TagReturns attribute value ornullfor an empty attribute, Returnsnullalso if attribute name does not exist.- Specified by:
getAttributeValuein interfaceTag
-
getAttributeIndex
public int getAttributeIndex(java.lang.CharSequence name)
Description copied from interface:TagReturns attribute index or-1if not found.- Specified by:
getAttributeIndexin interfaceTag
-
hasAttribute
public boolean hasAttribute(java.lang.CharSequence name)
Description copied from interface:TagDetects if an attribute is present.- Specified by:
hasAttributein interfaceTag
-
getTagPosition
public int getTagPosition()
Description copied from interface:TagReturns tag position in the input source.- Specified by:
getTagPositionin interfaceTag
-
getTagLength
public int getTagLength()
Description copied from interface:TagReturns tag length in the input source.- Specified by:
getTagLengthin interfaceTag
-
getPosition
public java.lang.String getPosition()
Description copied from interface:TagReturns tag position string ornullif position is not calculated.- Specified by:
getPositionin interfaceTag
-
setPosition
public void setPosition(CharsInput.Position position)
-
setName
public void setName(java.lang.CharSequence tagName)
Description copied from interface:TagSets tag name.
-
addAttribute
public void addAttribute(java.lang.CharSequence name, java.lang.CharSequence value)Description copied from interface:TagAdds new attribute without checking if it already exist thus allowing duplicate attributes.- Specified by:
addAttributein interfaceTag
-
setAttribute
public void setAttribute(java.lang.CharSequence name, java.lang.CharSequence value)Description copied from interface:TagSets new attribute value. If attribute already exist, it's value is changed. If attribute does not exist, it will be added to the tag.- Specified by:
setAttributein interfaceTag
-
setAttributeValue
public void setAttributeValue(int index, java.lang.CharSequence value)Description copied from interface:TagSets value for attribute at specific index. Throws exception if index is invalid.- Specified by:
setAttributeValuein interfaceTag
-
setAttributeValue
public void setAttributeValue(java.lang.CharSequence name, java.lang.CharSequence value)Description copied from interface:TagSets value for attribute with given name. If attribute with given name doesn't exist, nothing changes.- Specified by:
setAttributeValuein interfaceTag
-
setAttributeName
public void setAttributeName(int index, java.lang.CharSequence name)Description copied from interface:TagChanges attribute name on specific index. Throws exception if index is invalid.- Specified by:
setAttributeNamein interfaceTag
-
removeAttribute
public void removeAttribute(int index)
Description copied from interface:TagRemoves attribute at given index. Throws exception if index is invalid.- Specified by:
removeAttributein interfaceTag
-
removeAttribute
public void removeAttribute(java.lang.CharSequence name)
Description copied from interface:TagRemoves attribute by given name.- Specified by:
removeAttributein interfaceTag
-
removeAttributes
public void removeAttributes()
Description copied from interface:TagRemoves all attributes.- Specified by:
removeAttributesin interfaceTag
-
isModified
public boolean isModified()
Description copied from interface:TagReturnstrueif tag is modified.- Specified by:
isModifiedin interfaceTag
-
nameEquals
public boolean nameEquals(java.lang.CharSequence charSequence)
Description copied from interface:TagReturnstrueif name equals to given char sequence.- Specified by:
nameEqualsin interfaceTag
-
ensureLength
private void ensureLength()
-
setAttrVal
private void setAttrVal(int index, java.lang.CharSequence name, java.lang.CharSequence value)
-
setAttrVal
private void setAttrVal(int index, java.lang.CharSequence value)
-
appendTo
private void appendTo(java.lang.Appendable out)
-
writeTo
public void writeTo(java.lang.Appendable out)
Description copied from interface:TagWrites the tag to the output.
-
-