|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.json.JSONTokener
public class JSONTokener
A JSONTokener takes a source string and extracts characters and tokens from it.
It is used by the JSONObject and JSONArray constructors to parse JSON source strings.
Constructor Summary | |
---|---|
JSONTokener(java.io.Reader reader)
Construct a JSONTokener from a string. |
|
JSONTokener(java.lang.String s)
Construct a JSONTokener from a string. |
Method Summary | |
---|---|
void |
back()
Back up one character. |
static int |
dehexchar(char c)
Get the hex value of a character (base16). |
boolean |
more()
Determine if the source string still contains characters that next() can consume. |
char |
next()
Get the next character in the source string. |
char |
next(char c)
Consume the next character, and check that it matches a specified character. |
java.lang.String |
next(int n)
Get the next n characters. |
char |
nextClean()
Get the next char in the string, skipping whitespace and comments (slashslash, slashstar, and hash). |
java.lang.String |
nextString(char quote)
Return the characters up to the next close quote character. |
java.lang.String |
nextTo(char d)
Get the text up but not including the specified character or the end of line, whichever comes first. |
java.lang.String |
nextTo(java.lang.String delimiters)
Get the text up but not including one of the specified delimiter characters or the end of line, whichever comes first. |
java.lang.Object |
nextValue()
Get the next value. |
char |
skipTo(char to)
Skip characters until the next character is the requested character. |
JSONException |
syntaxError(java.lang.String message)
Make a JSONException to signal a syntax error. |
java.lang.String |
toString()
Make a printable string of this JSONTokener. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JSONTokener(java.io.Reader reader)
reader
- a reader.public JSONTokener(java.lang.String s)
s
- a source stringMethod Detail |
---|
public static int dehexchar(char c)
c
- a character between '0' and '9' or between 'A' and 'F' or
between 'a' and 'f'
public void back() throws JSONException
This provides a sort of lookahead capability, so that you can test for a digit or letter before attempting to parse the next number or identifier.
JSONException
- if something goes wrongpublic boolean more() throws JSONException
JSONException
- if something goes wrongpublic char next() throws JSONException
JSONException
- if something goes wrongpublic char next(char c) throws JSONException
c
- the character to match
JSONException
- if the character does not matchpublic java.lang.String next(int n) throws JSONException
n
- the number of characters to take
JSONException
- substring bounds error if there are not n characters remaining in the source stringpublic char nextClean() throws JSONException
JSONException
- if something goes wrongpublic java.lang.String nextString(char quote) throws JSONException
Backslash processing is done. The formal JSON format does not allow strings in single quotes, but an implementation is allowed to accept them.
quote
- The quoting character, either
"
(double quote) or
'
(single quote)
JSONException
- in case of an unterminated stringpublic java.lang.String nextTo(char d) throws JSONException
d
- a delimiter character
JSONException
- if something goes wrongpublic java.lang.String nextTo(java.lang.String delimiters) throws JSONException
delimiters
- a set of delimiter characters
JSONException
- if something goes wrongpublic java.lang.Object nextValue() throws JSONException
JSONException
- if something goes wrongpublic char skipTo(char to) throws JSONException
to
- a character to skip to
JSONException
- if something goes wrongpublic JSONException syntaxError(java.lang.String message)
message
- the error message
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |