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 void
close()
Close the text readerReader
getReader()
Get the readerboolean
isIncludeQuotes()
Is include quotes enabledstatic boolean
isQuoteCharacter(char c)
Check if the character is a quote characterstatic boolean
isTokenCharacter(char c)
Check if the character is a contiguous block token character: ( [a-z] | [A-Z] | [0-9] | - | .static boolean
isWhitespace(char c)
Check if the character is whitespace or a space characterString
peekExpectedToken()
Peek at the next expected token without reading past itString
peekExpectedToken(int num)
Peek at the next expected token without reading past itString
peekToken()
Peek at the next token without reading past itString
peekToken(int num)
Peek at a token without reading past itvoid
pushToken(String token)
Push a token back onto the read cacheString
readExpectedToken()
Read an expected tokenint
readInteger()
Read a signed integerdouble
readNumber()
Read a signed number as a doubleString
readToken()
Read the next token.int
readUnsignedInteger()
Read an unsigned integerdouble
readUnsignedNumber()
Read an unsigned number as a doublevoid
reset()
Reset the readervoid
setIncludeQuotes(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 IOException
Reset 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 IOException
Read a signed number as a double- Returns:
- signed double
- Throws:
IOException
- upon failure to read
-
readUnsignedNumber
public double readUnsignedNumber() throws IOException
Read an unsigned number as a double- Returns:
- unsigned double
- Throws:
IOException
- upon failure to read
-
readInteger
public int readInteger() throws IOException
Read a signed integer- Returns:
- signed integer
- Throws:
IOException
- upon failure to read
-
readUnsignedInteger
public int readUnsignedInteger() throws IOException
Read 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
-
-