Class StringTokenMatcher
java.lang.Object
com.singularsys.jep.configurableparser.matchers.RegExpTokenMatcher
com.singularsys.jep.configurableparser.matchers.StringTokenMatcher
- All Implemented Interfaces:
TokenBuilder,TokenMatcher,Serializable
Base class for matching quoted strings.
This class uses regular expressions but does not work well with escaped character inside the string.
See
StringTokenMatcher2 for a matcher which works with escape character like \' \" and \n.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStringTokenMatcher(Pattern pattern, char delim) A StringTokenMatcher with a given regular expression pattern. -
Method Summary
Modifier and TypeMethodDescriptionbuildToken(String s) Builds a token following a successful match.static StringTokenMatcherFactory for matching single line double-quoted strings.voidInitialize the matcher when the Jep instance is known.Attempts to match the start of the string.static StringTokenMatcherFactory for matching single line single quoted strings.
-
Constructor Details
-
StringTokenMatcher
A StringTokenMatcher with a given regular expression pattern.- Parameters:
pattern- regular expression pattern to usedelim- the delimiter character marking start and end of the string.
-
-
Method Details
-
match
Description copied from class:RegExpTokenMatcherAttempts to match the start of the string.- Specified by:
matchin interfaceTokenMatcher- Overrides:
matchin classRegExpTokenMatcher- Parameters:
s- the string to match against- Returns:
- if successful returns the corresponding token, return null if failed to match
-
doubleQuoteStringMatcher
Factory for matching single line double-quoted strings.- Returns:
- a TokenMatcher
-
singleQuoteStringMatcher
Factory for matching single line single quoted strings.- Returns:
- a TokenMatcher
-
buildToken
Description copied from class:RegExpTokenMatcherBuilds 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:
buildTokenin interfaceTokenBuilder- Specified by:
buildTokenin classRegExpTokenMatcher- Parameters:
s- String representing the completed matched token- Returns:
- the appropriate type of token.
-
init
Description copied from interface:TokenMatcherInitialize the matcher when the Jep instance is known.- Parameters:
j- Jep instance
-