Package mil.nga.crs.wkt
Class TextReader
- java.lang.Object
-
- mil.nga.crs.wkt.TextReader
-
public class TextReader extends Object
Read through text string- Author:
- osbornb
-
-
Constructor Summary
Constructors Constructor Description TextReader(Reader reader)ConstructorTextReader(Reader reader, boolean includeQuotes)ConstructorTextReader(String text)ConstructorTextReader(String text, boolean includeQuotes)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the text readerReadergetReader()Get the readerbooleanisIncludeQuotes()Is include quotes enabledstatic booleanisQuoteCharacter(char c)Check if the character is a quote characterstatic booleanisTokenCharacter(char c)Check if the character is a contiguous block token character: ( [a-z] | [A-Z] | [0-9] | - | .static booleanisWhitespace(char c)Check if the character is whitespace or a space characterStringpeekExpectedToken()Peek at the next expected token without reading past itStringpeekExpectedToken(int num)Peek at the next expected token without reading past itStringpeekToken()Peek at the next token without reading past itStringpeekToken(int num)Peek at a token without reading past itvoidpushToken(String token)Push a token back onto the read cacheStringreadExpectedToken()Read an expected tokenintreadInteger()Read a signed integerdoublereadNumber()Read a signed number as a doubleStringreadToken()Read the next token.intreadUnsignedInteger()Read an unsigned integerdoublereadUnsignedNumber()Read an unsigned number as a doublevoidreset()Reset the readervoidsetIncludeQuotes(boolean includeQuotes)Set the include quotes setting
-
-
-
Constructor Detail
-
TextReader
public TextReader(String text)
Constructor- Parameters:
text- text
-
TextReader
public TextReader(Reader reader)
Constructor- Parameters:
reader- reader
-
TextReader
public TextReader(String text, boolean includeQuotes)
Constructor- Parameters:
text- textincludeQuotes- include quotes
-
TextReader
public TextReader(Reader reader, boolean includeQuotes)
Constructor- Parameters:
reader- readerincludeQuotes- include quotes
-
-
Method Detail
-
getReader
public Reader getReader()
Get the reader- Returns:
- reader
-
isIncludeQuotes
public boolean isIncludeQuotes()
Is include quotes enabled- Returns:
- include quotes setting
-
setIncludeQuotes
public void setIncludeQuotes(boolean includeQuotes)
Set the include quotes setting- Parameters:
includeQuotes- true to include quotes
-
reset
public void reset() throws IOExceptionReset the reader- Throws:
IOException- upon reset error
-
close
public void close()
Close the text reader
-
readToken
public String readToken() throws IOException
Read the next token. Ignores whitespace until a non whitespace character is encountered. Returns a contiguous block of token characters ( [a-z] | [A-Z] | [0-9] | - | . | + | : | _ ) or a non whitespace single character.- Returns:
- token
- Throws:
IOException- upon read error
-
peekToken
public String peekToken() throws IOException
Peek at the next token without reading past it- Returns:
- next token
- Throws:
IOException- upon read error
-
peekToken
public String peekToken(int num) throws IOException
Peek at a token without reading past it- Parameters:
num- number of tokens out to peek at- Returns:
- token
- Throws:
IOException- upon read error
-
pushToken
public void pushToken(String token)
Push a token back onto the read cache- Parameters:
token- token
-
readExpectedToken
public String readExpectedToken() throws IOException
Read an expected token- Returns:
- token
- Throws:
IOException- upon read error
-
peekExpectedToken
public String peekExpectedToken() throws IOException
Peek at the next expected token without reading past it- Returns:
- next token
- Throws:
IOException- upon read error
-
peekExpectedToken
public String peekExpectedToken(int num) throws IOException
Peek at the next expected token without reading past it- Parameters:
num- number of tokens out to peek at- Returns:
- token
- Throws:
IOException- upon read error
-
readNumber
public double readNumber() throws IOExceptionRead a signed number as a double- Returns:
- signed double
- Throws:
IOException- upon failure to read
-
readUnsignedNumber
public double readUnsignedNumber() throws IOExceptionRead an unsigned number as a double- Returns:
- unsigned double
- Throws:
IOException- upon failure to read
-
readInteger
public int readInteger() throws IOExceptionRead a signed integer- Returns:
- signed integer
- Throws:
IOException- upon failure to read
-
readUnsignedInteger
public int readUnsignedInteger() throws IOExceptionRead an unsigned integer- Returns:
- unsigned integer
- Throws:
IOException- upon failure to read
-
isTokenCharacter
public static boolean isTokenCharacter(char c)
Check if the character is a contiguous block token character: ( [a-z] | [A-Z] | [0-9] | - | . | + | : | _ )- Parameters:
c- character- Returns:
- true if token character
- Since:
- 1.1.3
-
isQuoteCharacter
public static boolean isQuoteCharacter(char c)
Check if the character is a quote character- Parameters:
c- character- Returns:
- true if quote character
- Since:
- 1.1.3
-
isWhitespace
public static boolean isWhitespace(char c)
Check if the character is whitespace or a space character- Parameters:
c- character- Returns:
- true if whitespace
- Since:
- 1.1.3
-
-