com.singularsys.jep.configurableparser.matchers
Class SymbolTokenMatcher

java.lang.Object
  extended by 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
SymbolTokenMatcher()
           
 
Method Summary
 boolean add(SymbolToken t)
          Adds a new SymbolToken to be matched.
 SymbolToken getSymbolToken(java.lang.String s)
          Gets the root SymbolToken for this string.
 void init(Jep j)
          Initialize the matcher when the Jep instance is known.
 Token match(java.lang.String s)
          Match the start of the string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SymbolTokenMatcher

public SymbolTokenMatcher()
Method Detail

match

public Token match(java.lang.String s)
Match the start of the string.

Specified by:
match in interface TokenMatcher
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: TokenMatcher
Initialize the matcher when the Jep instance is known.

Specified by:
init in interface TokenMatcher

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


Copyright © 2010 Singular Systems http://www.singularsys.com/jep