Node Director
|
A JSONTokener takes a source string and extracts characters and tokens from it. More...
Public Member Functions | |
JSONTokener (String s) | |
Construct a JSONTokener from a string. | |
void | back () |
Back up one character. | |
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) throws ParseException |
Consume the next character, and check that it matches a specified character. | |
String | next (int n) throws ParseException |
Get the next n characters. | |
char | nextClean () throws java.text.ParseException |
Get the next char in the string, skipping whitespace and comments (slashslash, slashstar, and hash). | |
String | nextString (char quote) throws ParseException |
Return the characters up to the next close quote character. | |
String | nextTo (char d) |
Get the text up but not including the specified character or the end of line, whichever comes first. | |
String | nextTo (String delimiters) |
Get the text up but not including one of the specified delimeter characters or the end of line, whichever comes first. | |
Date | nextDate () throws ParseException |
Object | nextValue () throws ParseException |
Get the next value. | |
char | skipTo (char to) |
Skip characters until the next character is the requested character. | |
void | skipPast (String to) |
Skip characters until past the requested string. | |
ParseException | syntaxError (String message) |
Make a ParseException to signal a syntax error. | |
String | toString () |
Make a printable string of this JSONTokener. |
Static Public Member Functions | |
static int | dehexchar (char c) |
Get the hex value of a character (base16). | |
static String | unescape (String s) |
Convert % hh sequences to single characters, and convert plus to space. |
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.
org.json.JSONTokener.JSONTokener | ( | String | s | ) |
Construct a JSONTokener from a string.
s | A source string. |
void org.json.JSONTokener.back | ( | ) |
Back up one character.
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.
Referenced by org.json.JSONTokener.nextClean(), org.json.XMLTokener.nextContent(), org.json.XMLTokener.nextMeta(), org.json.JSONTokener.nextTo(), org.json.XMLTokener.nextToken(), org.json.JSONTokener.nextValue(), and org.json.JSONTokener.skipTo().
|
static |
Get the hex value of a character (base16).
c | A character between '0' and '9' or between 'A' and 'F' or between 'a' and 'f'. |
Referenced by org.json.JSONTokener.unescape().
boolean org.json.JSONTokener.more | ( | ) |
Determine if the source string still contains characters that next() can consume.
Referenced by org.json.JSONTokener.next(), org.json.CookieList.toJSONObject(), org.json.HTTP.toJSONObject(), org.json.Cookie.toJSONObject(), and org.json.XML.toJSONObject().
char org.json.JSONTokener.next | ( | ) |
Get the next character in the source string.
References org.json.JSONTokener.more().
Referenced by org.json.JSONTokener.next(), org.json.JSONTokener.nextClean(), org.json.XMLTokener.nextContent(), org.json.JSONTokener.nextDate(), org.json.XMLTokener.nextEntity(), org.json.XMLTokener.nextMeta(), org.json.JSONTokener.nextString(), org.json.JSONTokener.nextTo(), org.json.HTTPTokener.nextToken(), org.json.XMLTokener.nextToken(), org.json.JSONTokener.nextValue(), org.json.CDL.rowToJSONArray(), org.json.JSONTokener.skipTo(), org.json.CookieList.toJSONObject(), org.json.HTTP.toJSONObject(), and org.json.Cookie.toJSONObject().
char org.json.JSONTokener.next | ( | char | c | ) | throws ParseException |
Consume the next character, and check that it matches a specified character.
c | The character to match. |
ParseException | if the character does not match. |
References org.json.JSONTokener.next(), and org.json.JSONTokener.syntaxError().
String org.json.JSONTokener.next | ( | int | n | ) | throws ParseException |
Get the next n characters.
n | The number of characters to take. |
ParseException | Substring bounds error if there are not n characters remaining in the source string. |
References org.json.JSONTokener.syntaxError().
char org.json.JSONTokener.nextClean | ( | ) | throws java.text.ParseException |
Get the next char in the string, skipping whitespace and comments (slashslash, slashstar, and hash).
ParseException |
References org.json.JSONTokener.back(), org.json.JSONTokener.next(), and org.json.JSONTokener.syntaxError().
Referenced by org.json.JSONTokener.nextDate(), and org.json.JSONTokener.nextValue().
Date org.json.JSONTokener.nextDate | ( | ) | throws ParseException |
String org.json.JSONTokener.nextString | ( | char | quote | ) | throws ParseException |
Return the characters up to the next close quote character.
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). |
ParseException | Unterminated string. |
References org.json.JSONTokener.next(), and org.json.JSONTokener.syntaxError().
Referenced by org.json.JSONTokener.nextValue().
String org.json.JSONTokener.nextTo | ( | char | d | ) |
Get the text up but not including the specified character or the end of line, whichever comes first.
d | A delimiter character. |
References org.json.JSONTokener.back(), and org.json.JSONTokener.next().
Referenced by org.json.JSONTokener.nextDate(), org.json.CookieList.toJSONObject(), org.json.HTTP.toJSONObject(), and org.json.Cookie.toJSONObject().
String org.json.JSONTokener.nextTo | ( | String | delimiters | ) |
Get the text up but not including one of the specified delimeter characters or the end of line, whichever comes first.
delimiters | A set of delimiter characters. |
References org.json.JSONTokener.back(), and org.json.JSONTokener.next().
Object org.json.JSONTokener.nextValue | ( | ) | throws ParseException |
Get the next value.
The value can be a Boolean, Double, Integer, JSONArray, JSONObject, or String, or the JSONObject.NULL object.
ParseException | The source does not conform to JSON syntax. |
References org.json.JSONTokener.back(), org.json.JSONTokener.next(), org.json.JSONTokener.nextClean(), org.json.JSONTokener.nextDate(), org.json.JSONTokener.nextString(), org.json.JSONObject.NULL, and org.json.JSONTokener.syntaxError().
void org.json.JSONTokener.skipPast | ( | String | to | ) |
Skip characters until past the requested string.
If it is not found, we are left at the end of the source.
to | A string to skip past. |
Referenced by org.json.XML.toJSONObject().
char org.json.JSONTokener.skipTo | ( | char | to | ) |
Skip characters until the next character is the requested character.
If the requested character is not found, no characters are skipped.
to | A character to skip to. |
References org.json.JSONTokener.back(), and org.json.JSONTokener.next().
Referenced by org.json.Test.main().
ParseException org.json.JSONTokener.syntaxError | ( | String | message | ) |
Make a ParseException to signal a syntax error.
message | The error message. |
References org.json.JSONTokener.toString().
Referenced by org.json.JSONTokener.next(), org.json.JSONTokener.nextClean(), org.json.JSONTokener.nextDate(), org.json.XMLTokener.nextEntity(), org.json.XMLTokener.nextMeta(), org.json.JSONTokener.nextString(), org.json.HTTPTokener.nextToken(), org.json.XMLTokener.nextToken(), org.json.JSONTokener.nextValue(), org.json.CDL.rowToJSONArray(), and org.json.Cookie.toJSONObject().
String org.json.JSONTokener.toString | ( | ) |
Make a printable string of this JSONTokener.
Referenced by org.json.JSONTokener.syntaxError().
|
static |
Convert %
hh sequences to single characters, and convert plus to space.
s | A string that may contain + (plus) and % hh sequences. |
References org.json.JSONTokener.dehexchar().
Referenced by org.json.CookieList.toJSONObject(), and org.json.Cookie.toJSONObject().