Package org.nineml.coffeegrinder.tokens
Class TokenString
- java.lang.Object
-
- org.nineml.coffeegrinder.util.Decoratable
-
- org.nineml.coffeegrinder.tokens.Token
-
- org.nineml.coffeegrinder.tokens.TokenString
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Test tokens for equality.static TokenStringget(java.lang.String value)Create a token for the specified string.static TokenStringget(java.lang.String value, java.util.Collection<ParserAttribute> attributes)Create a token for the specified string (with attributes)static TokenStringget(java.lang.String value, ParserAttribute attribute)Create a token for the specified string (with an attribute)java.lang.StringgetValue()Get the string.inthashCode()Assure that equal tokens return the same hash code.booleanmatches(char input)Does this toke match this character?booleanmatches(java.lang.String input)Does this token match this string?booleanmatches(Token input)Does this token match the input?java.lang.StringtoString()Pretty print a token.-
Methods inherited from class org.nineml.coffeegrinder.util.Decoratable
addAttribute, addAttributes, getAttribute, getAttributes, getAttributesMap, getAttributeValue, hasAttribute
-
-
-
-
Method Detail
-
get
public static TokenString get(java.lang.String value)
Create a token for the specified string.- Parameters:
value- the string- Returns:
- the token
-
get
public static TokenString get(java.lang.String value, ParserAttribute attribute)
Create a token for the specified string (with an attribute)- Parameters:
value- the stringattribute- the attribute- Returns:
- the token
-
get
public static TokenString get(java.lang.String value, java.util.Collection<ParserAttribute> attributes)
Create a token for the specified string (with attributes)- Parameters:
value- the stringattributes- the attributes- Returns:
- the token
-
getValue
public java.lang.String getValue()
Get the string.
-
matches
public boolean matches(Token input)
Does this token match the input?This token matches other
token stringsthat have the same underlying string. If this is a single character string, it will also matchTokenCharactersthat are defined with the same character.
-
matches
public boolean matches(char input)
Does this toke match this character?- Parameters:
input- the character.- Returns:
- true if this token matches.
-
matches
public boolean matches(java.lang.String input)
Does this token match this string?- Parameters:
input- the string.- Returns:
- true if the token matches.
-
equals
public boolean equals(java.lang.Object obj)
Test tokens for equality.Two tokens are equal if they represent the same string.
- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- An object.- Returns:
- true if
objis equal to this terminal character.
-
hashCode
public int hashCode()
Assure that equal tokens return the same hash code.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hash code.
-
toString
public java.lang.String toString()
Pretty print a token.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the object.
-
-