Class StringTokenMatcher
- java.lang.Object
-
- com.singularsys.jep.configurableparser.matchers.RegExpTokenMatcher
-
- com.singularsys.jep.configurableparser.matchers.StringTokenMatcher
-
- All Implemented Interfaces:
TokenBuilder
,TokenMatcher
,java.io.Serializable
public class StringTokenMatcher extends RegExpTokenMatcher
Base class for matching quoted strings. This class uses regular expressions but does not work well with escaped character inside the string. SeeStringTokenMatcher2
for a matcher which works with escape character like \' \" and \n.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StringTokenMatcher(java.util.regex.Pattern pattern, char delim)
A StringTokenMatcher with a given regular expression pattern.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Token
buildToken(java.lang.String s)
Builds a token following a successful match.static StringTokenMatcher
doubleQuoteStringMatcher()
Factory for matching single line double quoted strings.void
init(Jep j)
Initialize the matcher when the Jep instance is known.Token
match(java.lang.String s)
Attempts to match the start of the string.static StringTokenMatcher
singleQuoteStringMatcher()
Factory for matching single line single quoted strings.
-
-
-
Method Detail
-
match
public Token match(java.lang.String s)
Description copied from class:RegExpTokenMatcher
Attempts to match the start of the string.- Specified by:
match
in interfaceTokenMatcher
- Overrides:
match
in classRegExpTokenMatcher
- Parameters:
s
- the string to match against- Returns:
- if successful returns the corresponding token, return null if failed to match
-
doubleQuoteStringMatcher
public static StringTokenMatcher doubleQuoteStringMatcher()
Factory for matching single line double quoted strings.- Returns:
- a TokenMatcher
-
singleQuoteStringMatcher
public static StringTokenMatcher singleQuoteStringMatcher()
Factory for matching single line single quoted strings.- Returns:
- a TokenMatcher
-
buildToken
public Token buildToken(java.lang.String s)
Description copied from class:RegExpTokenMatcher
Builds a token following a successful match. Note new objects should be created each time as error reporting information is later attached to tokens.- Specified by:
buildToken
in interfaceTokenBuilder
- Specified by:
buildToken
in classRegExpTokenMatcher
- Parameters:
s
- String representing the completed matched token- Returns:
- the appropriate type of token.
-
init
public void init(Jep j)
Description copied from interface:TokenMatcher
Initialize the matcher when the Jep instance is known.- Parameters:
j
- Jep instance
-
-