Class SymbolTokenMatcher
- java.lang.Object
-
- com.singularsys.jep.configurableparser.matchers.SymbolTokenMatcher
-
- All Implemented Interfaces:
TokenMatcher,java.io.Serializable
public class SymbolTokenMatcher extends java.lang.Object implements TokenMatcher
Matches a fixed set of symbols, each represented by a SymbolToken. Each SymbolToken behaves like an singleton, only one instance is created and this is returned by the match method.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SymbolTokenMatcher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(SymbolToken t)Adds a new SymbolToken to be matched.SymbolTokengetSymbolToken(java.lang.String s)Gets the root SymbolToken for this string.voidinit(Jep j)Initialize the matcher when the Jep instance is known.Tokenmatch(java.lang.String s)Match the start of the string.
-
-
-
Method Detail
-
match
public Token match(java.lang.String s)
Match the start of the string.- Specified by:
matchin interfaceTokenMatcher- Parameters:
s- a string to be matched- Returns:
- a clone of the matching symbol
-
add
public boolean add(SymbolToken t)
Adds a new SymbolToken to be matched.- Parameters:
t- a SymbolToken- Returns:
- true (as specified by Collection.add)
-
init
public void init(Jep j)
Description copied from interface:TokenMatcherInitialize the matcher when the Jep instance is known.- Specified by:
initin interfaceTokenMatcher- Parameters:
j- Jep instance
-
getSymbolToken
public SymbolToken getSymbolToken(java.lang.String s)
Gets the root SymbolToken for this string. Unlike the match method which returns a clone of the token, this returns the base symbol.- Parameters:
s- a string to be matched exactly- Returns:
- the symbol token or null is no such symbol
-
-