Class StringTokenMatcher2
- java.lang.Object
-
- com.singularsys.jep.configurableparser.matchers.StringTokenMatcher2
-
- All Implemented Interfaces:
TokenMatcher
,java.io.Serializable
public class StringTokenMatcher2 extends java.lang.Object implements TokenMatcher
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. UnlikeStringTokenMatcher
a hand built pattern matcher is used rather than regular expressions.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StringTokenMatcher2(char delim, boolean incQuotes)
Construct a string matcher.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringTokenMatcher2
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 StringTokenMatcher2
singleQuoteStringMatcher()
Factory for matching single line single quoted strings.static StringTokenMatcher2
singleQuoteStringMatcher(boolean incQuotes)
Factory for matching single line single quoted strings.
-
-
-
Method Detail
-
match
public Token match(java.lang.String s) throws ParseException
Description copied from interface:TokenMatcher
Attempts 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:
match
in 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
public static StringTokenMatcher2 doubleQuoteStringMatcher()
Factory for matching single line double quoted strings.- Returns:
- a TokenMatcher
-
singleQuoteStringMatcher
public static StringTokenMatcher2 singleQuoteStringMatcher()
Factory for matching single line single quoted strings.- Returns:
- a TokenMatcher
-
singleQuoteStringMatcher
public static StringTokenMatcher2 singleQuoteStringMatcher(boolean incQuotes)
Factory for matching single line single quoted strings.- Parameters:
incQuotes
- whether the quote character should be returned to the parser.- Returns:
- a TokenMatcher
-
init
public void init(Jep j)
Description copied from interface:TokenMatcher
Initialize the matcher when the Jep instance is known.- Specified by:
init
in interfaceTokenMatcher
- Parameters:
j
- Jep instance
-
-