Class StringTokenMatcher2
java.lang.Object
com.singularsys.jep.configurableparser.matchers.StringTokenMatcher2
- All Implemented Interfaces:
TokenMatcher,Serializable
Base class for matching quoted strings.
This class allows escape characters like \n inside the string,
As well as unicode ᨚ and latin \007 escape sequences.
Unlike
StringTokenMatcher a hand built pattern matcher
is used rather than regular expressions.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStringTokenMatcher2(char delim, boolean incQuotes) Construct a string matcher. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringTokenMatcher2Factory 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 StringTokenMatcher2Factory for matching single line single quoted strings.static StringTokenMatcher2singleQuoteStringMatcher(boolean incQuotes) Factory for matching single line single quoted strings.
-
Constructor Details
-
StringTokenMatcher2
public StringTokenMatcher2(char delim, boolean incQuotes) Construct a string matcher.- Parameters:
delim- The delimiter character typically " or ' or `.incQuotes- whether the quote character should be included.
-
-
Method Details
-
match
Description copied from interface:TokenMatcherAttempts to match the start of the string. Note new objects should be created each time as error reporting information is later attached to tokens.- Specified by:
matchin interfaceTokenMatcher- Parameters:
s- the string to match against- Returns:
- if successful returns the corresponding token, return null if failed to match
- Throws:
ParseException- on syntax error
-
doubleQuoteStringMatcher
Factory for matching single line double-quoted strings.- Returns:
- a TokenMatcher
-
singleQuoteStringMatcher
Factory for matching single line single quoted strings.- Returns:
- a TokenMatcher
-
singleQuoteStringMatcher
Factory for matching single line single quoted strings.- Parameters:
incQuotes- whether the quote character should be returned to the parser.- Returns:
- a TokenMatcher
-
init
Description copied from interface:TokenMatcherInitialize the matcher when the Jep instance is known.- Specified by:
initin interfaceTokenMatcher- Parameters:
j- Jep instance
-