public class JSONStreamTokenizer extends Object
StreamTokenizer but it works
on a character by character basis, whereas the StreamTokenizer is based on
individual bytes so is not handling solidus nor unicode correctly. This class
is solely for parsing JSON content.| Modifier and Type | Field and Description |
|---|---|
double |
nval |
String |
sval |
static int |
TT_CR |
static int |
TT_EOF |
static int |
TT_EOL |
static int |
TT_NUMBER |
static int |
TT_WORD |
int |
ttype |
| Constructor and Description |
|---|
JSONStreamTokenizer(Reader r)
Constructs the JST from a
Reader. |
| Modifier and Type | Method and Description |
|---|---|
void |
eolIsSignificant(boolean flag)
Sets reporting when end of line is detected
|
int |
nextToken(Integer[] location)
Discovers the next token in the reader and returns its type (ttype).
|
void |
ordinaryChar(int ch)
Sets the supplied character as ordinary in the character lookup table
|
void |
ordinaryChars(int low,
int hi)
Sets the range of characters supplied (including the endpoints) as ordinary
in the character lookup table
|
void |
parseNumbers()
Initializes the character lookup table for known digits for numeric
characters, along with the decimal point and minus sign.
|
void |
pushBack()
Flags that a character has been returned after completing reading the next
token.
|
void |
quoteChar(int ch)
Sets the supplied character as a quote delimiter for quoted word
identification in the character lookup table
|
void |
resetSyntax()
Resets the character lookup table with single byte characters as ordinary,
and double byte characters as parts of words.
|
String |
toString()
Convenience method to see the state of the next token and its type (e.g.,
while debugging)
|
void |
whitespaceChars(int low,
int hi)
Sets the range of characters as whitespace in the character lookup table
|
void |
wordChars(int low,
int hi)
Flags the supplied range of characters as word characters in the lookup
table.
|
public static final int TT_EOF
public static final int TT_CR
public static final int TT_EOL
public static final int TT_NUMBER
public static final int TT_WORD
public double nval
public String sval
public int ttype
public JSONStreamTokenizer(Reader r)
Reader. There is no constructor for
an InputStream because it can be made into a reader. The same
is true for a String.r - the reader to be read containing JSON content.public void eolIsSignificant(boolean flag)
flag - whether or not to report when end of line is detectedpublic int nextToken(Integer[] location) throws IOException
location - where we are reading from the input streamIOException - if unable to read from the readerpublic void ordinaryChar(int ch)
ch - The character to be testedpublic void ordinaryChars(int low,
int hi)
low - starting, lower value characterhi - ending, higher value characterpublic void parseNumbers()
public void pushBack()
throws IOException
IOException - if unable to read from the readerpublic void quoteChar(int ch)
ch - The character defining a quote characterpublic void resetSyntax()
public String toString()
toString in class ObjectObject.toString()public void whitespaceChars(int low,
int hi)
low - starting, lower range of whitespace charactershi - ending, higher range of whitespace characterspublic void wordChars(int low,
int hi)
low - starting, lower character range of word charactershi - ending, higher character range of word charactersCopyright © 2020. All rights reserved.