Class WKTReader.State

  • Enclosing class:
    WKTReader

    public class WKTReader.State
    extends java.lang.Object
    The parse state.
    • Constructor Summary

      Constructors 
      Constructor Description
      State​(java.lang.String rawString)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean eof()
      If the string is consumed, i.e.
      SpatialContext getCtx()  
      WKTReader getParser()  
      double nextDouble()
      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 is expected, then offset is advanced after it and any subsequent whitespace.
      boolean nextIfEmptyAndSkipZM()
      Skips over a dimensionality token (e.g.
      void nextIfWhitespace()
      Moves offset to next non-whitespace character.
      java.lang.String nextSubShapeString()
      Returns the next chunk of text till the next ',' or ')' (non-inclusive) or EOF.
      java.lang.String nextWord()
      Reads the word starting at the current character position.
      void skipDouble()
      Advances offset forward until it points to a character that isn't part of a number.
      void skipNextDoubles()
      Advances past as many doubles as there are, with intervening whitespace.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • offset

        public int offset
        Offset of the next char in rawString to be read.
      • dimension

        public java.lang.String dimension
        Dimensionality specifier (e.g. 'Z', or 'M') following a shape type name.
    • Constructor Detail

      • State

        public State​(java.lang.String rawString)
    • Method Detail

      • nextWord

        public java.lang.String nextWord()
                                  throws java.text.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:
        java.text.ParseException
      • nextIfEmptyAndSkipZM

        public boolean nextIfEmptyAndSkipZM()
                                     throws java.text.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:
        java.text.ParseException
      • nextDouble

        public double nextDouble()
                          throws java.text.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:
        java.text.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 java.text.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:
        java.text.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 java.lang.String nextSubShapeString()
                                            throws java.text.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:
        java.text.ParseException