Package org.nineml.coffeegrinder.util
Class Decoratable
- java.lang.Object
-
- org.nineml.coffeegrinder.util.Decoratable
-
-
Constructor Summary
Constructors Constructor Description Decoratable()A decoratable item with no attributes.Decoratable(java.util.Collection<ParserAttribute> attributes)A decoratable item with attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(ParserAttribute attribute)Add the specified attribute to the attributes collection.voidaddAttributes(java.util.Collection<ParserAttribute> attrcoll)Add the specified attributes to the attributes collection.ParserAttributegetAttribute(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.StringgetAttributeValue(java.lang.String name, java.lang.String defaultValue)Get a specific token attribute value.booleanhasAttribute(java.lang.String name)Check if a specific attribute is specified.
-
-
-
Constructor Detail
-
Decoratable
public Decoratable()
A decoratable item with no attributes.
-
Decoratable
public Decoratable(java.util.Collection<ParserAttribute> attributes)
A decoratable item with attributes.- Parameters:
attributes- the attributes- Throws:
GrammarException- if the attribute names are not uniqueAttributeException- if an attribute has an invalid value
-
-
Method Detail
-
hasAttribute
public final boolean hasAttribute(java.lang.String name)
Check if a specific attribute is specified.- Parameters:
name- the name of the attribute.- Returns:
- true if the attribute is associated with this token.
-
getAttribute
public final ParserAttribute getAttribute(java.lang.String name)
Get a specific token attribute.- Parameters:
name- the name of the attribute.- Returns:
- the associated attribute, or null if there is no attribute with that name.
-
getAttributeValue
public final java.lang.String getAttributeValue(java.lang.String name, java.lang.String defaultValue)Get a specific token attribute value.- Parameters:
name- the name of the attribute.defaultValue- the default value.- Returns:
- the associated attribute value, or the default if there is no attribute with that name.
-
getAttributes
public final java.util.List<ParserAttribute> getAttributes()
Get all the token's attributes.- Returns:
- the attributes.
-
getAttributesMap
public final java.util.Map<java.lang.String,java.lang.String> getAttributesMap()
Get all the token's attributes as a map.- Returns:
- the associated attribute, or null if there is no attribute with that name.
-
addAttribute
public final void addAttribute(ParserAttribute attribute)
Add the specified attribute to the attributes collection.Once added, an attribute cannot be removed, nor can its value be changed.
- Parameters:
attribute- the attribute- Throws:
AttributeException- if you attempt to change the value of an attributeAttributeException- if you pass an illegal attributejava.lang.NullPointerException- if the attribute is null
-
addAttributes
public final void addAttributes(java.util.Collection<ParserAttribute> attrcoll)
Add the specified attributes to the attributes collection.Once added, an attribute cannot be removed, nor can its value be changed.
- Parameters:
attrcoll- the attributes- Throws:
AttributeException- if you attempt to change the value of an attributeAttributeException- if you pass an illegal attribute
-
-