Constructor and Description |
---|
Decoratable()
A decoratable item with no attributes.
|
Decoratable(java.util.Collection<ParserAttribute> attributes)
A decoratable item with attributes.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(ParserAttribute attribute)
Add the specified attribute to the attributes collection.
|
void |
addAttributes(java.util.Collection<ParserAttribute> attrcoll)
Add the specified attributes to the attributes collection.
|
ParserAttribute |
getAttribute(java.lang.String name)
Get a specific token attribute.
|
java.util.List<ParserAttribute> |
getAttributes()
Get all the token's attributes.
|
java.util.Map<java.lang.String,java.lang.String> |
getAttributesMap()
Get all the token's attributes as a map.
|
java.lang.String |
getAttributeValue(java.lang.String name,
java.lang.String defaultValue)
Get a specific token attribute value.
|
boolean |
hasAttribute(java.lang.String name)
Check if a specific attribute is specified.
|
public Decoratable()
public Decoratable(java.util.Collection<ParserAttribute> attributes)
attributes
- the attributesGrammarException
- if the attribute names are not uniqueAttributeException
- if an attribute has an invalid valuepublic final boolean hasAttribute(java.lang.String name)
name
- the name of the attribute.public final ParserAttribute getAttribute(java.lang.String name)
name
- the name of the attribute.public final java.lang.String getAttributeValue(java.lang.String name, java.lang.String defaultValue)
name
- the name of the attribute.defaultValue
- the default value.public final java.util.List<ParserAttribute> getAttributes()
public final java.util.Map<java.lang.String,java.lang.String> getAttributesMap()
public final void addAttribute(ParserAttribute attribute)
Once added, an attribute cannot be removed, nor can its value be changed.
attribute
- the attributeAttributeException
- if you attempt to change the value of an attributeAttributeException
- if you pass an illegal attributejava.lang.NullPointerException
- if the attribute is nullpublic final void addAttributes(java.util.Collection<ParserAttribute> attrcoll)
Once added, an attribute cannot be removed, nor can its value be changed.
attrcoll
- the attributesAttributeException
- if you attempt to change the value of an attributeAttributeException
- if you pass an illegal attribute