Class WKTReader.State

java.lang.Object
org.locationtech.spatial4j.io.WKTReader.State
Enclosing class:
WKTReader

public class WKTReader.State extends Object
The parse state.
  • Field Details

  • Constructor Details

    • State

      public State(String rawString)
  • Method Details

    • getCtx

      public SpatialContext getCtx()
    • getParser

      public WKTReader getParser()
    • nextWord

      public String nextWord() throws ParseException
      Reads the word starting at the current character position. The word terminates once Character.isJavaIdentifierPart(char) returns false (or EOF). offset is advanced past whitespace.
      Returns:
      Non-null non-empty String.
      Throws:
      ParseException
    • nextIfEmptyAndSkipZM

      public boolean nextIfEmptyAndSkipZM() throws ParseException
      Skips over a dimensionality token (e.g. 'Z' or 'M') if found, storing in dimension, and then looks for EMPTY, consuming that and whitespace.
         dimensionToken? 'EMPTY'?
       
      Returns:
      True if EMPTY was found.
      Throws:
      ParseException
    • nextDouble

      public double nextDouble() throws ParseException
      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

      public void nextExpect(char expected) throws ParseException
      Verifies that the current character is of the expected value. If the character is the expected value, then it is consumed and offset 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 is expected, 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

      public String nextSubShapeString() throws ParseException
      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