Class PushbackTokenizer
java.lang.Object
org.openstreetmap.josm.data.osm.search.PushbackTokenizer
This class is used to parse a search string and split it into tokens.
It provides methods to parse numbers and extract strings.
- Since:
- 12656 (moved from actions.search package)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA range of long numbers.static enumThe token types that may be read -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate Longprivate Longprivate Stringprivate PushbackTokenizer.Tokenprivate booleanprivate final Reader -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidgetChar()longGets the last number that was readprivate Stringprivate StringgetString(boolean quoted) getText()Gets the last text that was foundThe token returned isnullor starts with an identifier character: - for an '-'.booleanReads the next token if it is equal to the given, suggested tokenlongreadNumber(String errorMessage) Reads a numberReads a range of numbersReads the next token.
-
Field Details
-
search
-
currentToken
-
currentText
-
currentNumber
-
currentRange
-
c
-
isRange
-
SPECIAL_CHARS
-
SPECIAL_CHARS_QUOTED
-
-
Constructor Details
-
PushbackTokenizer
Creates a newPushbackTokenizer- Parameters:
search- The search string reader to read the tokens from
-
-
Method Details
-
getChar
-
getString
-
getString
-
nextToken
The token returned isnullor starts with an identifier character: - for an '-'. This will be the only character : for an key. The value is the next token | for "OR" ^ for "XOR" ' ' for anything else.- Returns:
- The next token in the stream.
-
readIfEqual
Reads the next token if it is equal to the given, suggested token- Parameters:
token- The token the next one should be equal to- Returns:
trueif it has been read
-
readTextOrNumber
Reads the next token. If it is a text, return that text. If not, advance- Returns:
- the text or
nullif the reader was advanced
-
readNumber
Reads a number- Parameters:
errorMessage- The error if the number cannot be read- Returns:
- The number that was found
- Throws:
SearchParseError- if there is no number
-
getReadNumber
Gets the last number that was read- Returns:
- The last number
-
readRange
Reads a range of numbers- Parameters:
errorMessage- The error if the input is malformed- Returns:
- The range that was found
- Throws:
SearchParseError- If the input is not as expected for a range
-
getText
Gets the last text that was found- Returns:
- The text
-