Package org.locationtech.spatial4j.io
Class WKTReader.State
java.lang.Object
org.locationtech.spatial4j.io.WKTReader.State
- Enclosing class:
WKTReader
The parse state.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
eof()
If the string is consumed, i.e.getCtx()
double
Reads in a double from the String.void
nextExpect
(char expected) Verifies that the current character is of the expected value.boolean
nextIf
(char expected) If the current character isexpected
, then offset is advanced after it and any subsequent whitespace.boolean
Skips over a dimensionality token (e.g.void
Moves offset to next non-whitespace character.Returns the next chunk of text till the next ',' or ')' (non-inclusive) or EOF.nextWord()
Reads the word starting at the current character position.void
Advances offset forward until it points to a character that isn't part of a number.void
Advances past as many doubles as there are, with intervening whitespace.
-
Field Details
-
rawString
-
offset
public int offsetOffset of the next char inrawString
to be read. -
dimension
Dimensionality specifier (e.g. 'Z', or 'M') following a shape type name.
-
-
Constructor Details
-
State
-
-
Method Details
-
getCtx
-
getParser
-
nextWord
Reads the word starting at the current character position. The word terminates onceCharacter.isJavaIdentifierPart(char)
returns false (or EOF).offset
is advanced past whitespace.- Returns:
- Non-null non-empty String.
- Throws:
ParseException
-
nextIfEmptyAndSkipZM
Skips over a dimensionality token (e.g. 'Z' or 'M') if found, storing indimension
, and then looks for EMPTY, consuming that and whitespace.dimensionToken? 'EMPTY'?
- Returns:
- True if EMPTY was found.
- Throws:
ParseException
-
nextDouble
Reads in a double from the String. Parses digits with an optional decimal, sign, or exponent. NaN and Infinity are not supported.offset
is advanced past whitespace.- Returns:
- Double value
- Throws:
ParseException
-
skipDouble
public void skipDouble()Advances offset forward until it points to a character that isn't part of a number. -
skipNextDoubles
public void skipNextDoubles()Advances past as many doubles as there are, with intervening whitespace. -
nextExpect
Verifies that the current character is of the expected value. If the character is the expected value, then it is consumed andoffset
is advanced past whitespace.- Parameters:
expected
- The expected char.- Throws:
ParseException
-
eof
public final boolean eof()If the string is consumed, i.e. at end-of-file. -
nextIf
public boolean nextIf(char expected) If the current character isexpected
, then offset is advanced after it and any subsequent whitespace. Otherwise, false is returned.- Parameters:
expected
- The expected char- Returns:
- true if consumed
-
nextIfWhitespace
public void nextIfWhitespace()Moves offset to next non-whitespace character. Doesn't move if the offset is already at non-whitespace. There is very little reason for subclasses to call this because most other parsing methods call it. -
nextSubShapeString
Returns the next chunk of text till the next ',' or ')' (non-inclusive) or EOF. If a '(' is encountered, then it looks past its matching ')', taking care to handle nested matching parenthesis too. It's designed to be of use to subclasses that wish to get the entire subshape at the current position as a string so that it might be passed to other software that will parse it.Example:
OUTER(INNER(3, 5))
If this is called when offset is at the first character, then it will return this whole string. If called at the "I" then it will return "INNER(3, 5)". If called at "3", then it will return "3". In all cases, offset will be positioned at the next position following the returned substring.- Returns:
- non-null substring.
- Throws:
ParseException
-