Class PatternTokenReader
java.lang.Object
ch.andre601.expressionparser.tokens.readers.TokenReader
ch.andre601.expressionparser.tokens.readers.PatternTokenReader
TokenReader instance
that parses the provided text by looking for appearances of a provided
pattern and in such a case returns the provided Token instance
.-
Constructor Summary
ConstructorDescriptionPatternTokenReader
(Token token, String pattern) Creates a new PatternTokenReader instance with the providedToken instance
being used for the provided Pattern String.PatternTokenReader
(Token token, String pattern, boolean ignoreCase) Creates a new PatternTokenReader instance with the providedToken instance
being used for the provided Pattern String. -
Method Summary
Modifier and TypeMethodDescriptionread
(String text, ParsePosition position, ParseWarnCollector collector) Makes aregion matches check
to see if the String at the current position matches the provided pattern String.Methods inherited from class ch.andre601.expressionparser.tokens.readers.TokenReader
getPriority
-
Constructor Details
-
PatternTokenReader
Creates a new PatternTokenReader instance with the providedToken instance
being used for the provided Pattern String.
Calling this constructor creates a case-insensitive PatternTokenReader. Should you require a case-sensitive one, usePatternTokenReader(Token, String, false)
instead.- Parameters:
token
- The Token to use for this PatternTokenReader.pattern
- The pattern to use for this PatternTokenReader.- Throws:
IllegalArgumentException
- Should token be null, Pattern be null or Pattern be empty.- See Also:
-
PatternTokenReader
Creates a new PatternTokenReader instance with the providedToken instance
being used for the provided Pattern String. The Boolean option allows you to toggle, whether the lookup should ignore casing of the text.- Parameters:
token
- The Token to use for this PatternTokenReader.pattern
- The pattern to use for this PatternTokenReader.ignoreCase
- Whether the PatternTokenReader should ignore case when looking for the pattern.- Throws:
IllegalArgumentException
- Should token be null, Pattern be null or Pattern be empty.
-
-
Method Details
-
read
Makes aregion matches check
to see if the String at the current position matches the provided pattern String.
Should it match, returns theToken
set in this TokenReader, elsenull
.- Specified by:
read
in classTokenReader
- Parameters:
text
- The text to parse.position
- The current position within the text.collector
- Instance of theParseWarnCollector
used for the parsing.- Returns:
- Possibly-null
Token
.
-