WktToken nextToken() { WktToken token = inner(); // System.out.println("NEXT TOKEN: " + token); return token; }
protected WktToken readToken() { int endPos = this.currentPos; while (endPos < wkt.length() && isWordChar(wkt.charAt(endPos))) { endPos++; } WktToken nextToken = matchKeyword(currentPos, endPos); currentPos = endPos; return nextToken; }
/** * Advances the decoding to the next token. */ protected void nextToken() { currentToken = tokenizer.nextToken(); }
private WktToken inner() { if (!moreTokens()) { return variant.end(); } if (wkt.charAt(currentPos) == variant.getOpenListChar()) { currentPos++; return variant.getOpenList(); } else if (wkt.charAt(currentPos) == variant.getCloseListChar()) { currentPos++; return variant.getCloseList(); } else if (wkt.charAt(currentPos) == '"') { return readText(); } else if (Character.isLetter(wkt.charAt(currentPos))) { return readToken(); } else if (Character.isDigit(wkt.charAt(currentPos)) || wkt.charAt(currentPos) == '.' || wkt.charAt(currentPos) == '-') { return numericToken(); } else if (wkt.charAt(currentPos) == variant.getElemSepChar()) { currentPos++; return variant.getElementSeparator(); } else { throw new WktDecodeException(String.format("Illegal Character at pos %d in Wkt text: %s", currentPos, wkt)); } }
protected double readNumber() { skipWhitespace(); StringBuilder stb = new StringBuilder(); char c = wkt.charAt(currentPos); if (c == '-') { stb.append(c); c = wkt.charAt(++currentPos); } c = readDigits(stb, c); if (c == '.') { stb.append(c); c = wkt.charAt(++currentPos); readDigits(stb, c); } return Double.parseDouble(stb.toString()); }
/** * Reports the current position of the tokenizer. * * @return the current position of the tokenizer. */ protected int getTokenizerPosition() { return this.tokenizer.position(); } }
protected WktToken readNumberToken() { double d = readNumber(); return new WktNumberToken(d); }