/** * @nowebref */ public JSONArray(Reader reader) { this(new JSONTokener(reader)); }
if (x.nextClean() != '{') { throw new RuntimeException("A JSONObject text must begin with '{'"); c = x.nextClean(); switch (c) { case 0: return; default: x.back(); key = x.nextValue().toString(); c = x.nextClean(); if (c == '=') { if (x.next() != '>') { x.back(); this.putOnce(key, x.nextValue()); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == '}') { return; x.back(); break; case '}':
/** * Get the text up but not including the specified character or the * end of line, whichever comes first. * @param delimiter A delimiter character. * @return A string. */ public String nextTo(char delimiter) { StringBuilder sb = new StringBuilder(); for (;;) { char c = this.next(); if (c == delimiter || c == 0 || c == '\n' || c == '\r') { if (c != 0) { this.back(); } return sb.toString().trim(); } sb.append(c); } }
if (x.nextClean() != '[') { throw new RuntimeException("A JSONArray text must start with '['"); if (x.nextClean() != ']') { x.back(); for (;;) { if (x.nextClean() == ',') { x.back(); myArrayList.add(JSONObject.NULL); } else { x.back(); myArrayList.add(x.nextValue()); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == ']') { return; x.back(); break; case ']':
/** * Get the next n characters. * * @param n The number of characters to take. * @return A string of n characters. * @throws JSONException * Substring bounds error if there are not * n characters remaining in the source string. */ public String next(int n) { if (n == 0) { return ""; } char[] chars = new char[n]; int pos = 0; while (pos < n) { chars[pos] = this.next(); if (this.end()) { throw new RuntimeException("Substring bounds error"); } pos += 1; } return new String(chars); }
/** * Get the next char in the string, skipping whitespace. * @throws JSONException * @return A character, or 0 if there are no more characters. */ public char nextClean() { for (;;) { char c = this.next(); if (c == 0 || c > ' ') { return c; } } }
if (x.nextClean() != '{') { throw new RuntimeException("A JSONObject text must begin with '{'"); c = x.nextClean(); switch (c) { case 0: return; default: x.back(); key = x.nextValue().toString(); c = x.nextClean(); if (c == '=') { if (x.next() != '>') { x.back(); this.putOnce(key, x.nextValue()); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == '}') { return; x.back(); break; case '}':
/** * Get the text up but not including the specified character or the * end of line, whichever comes first. * @param delimiter A delimiter character. * @return A string. */ public String nextTo(char delimiter) { StringBuffer sb = new StringBuffer(); for (;;) { char c = this.next(); if (c == delimiter || c == 0 || c == '\n' || c == '\r') { if (c != 0) { this.back(); } return sb.toString().trim(); } sb.append(c); } }
if (x.nextClean() != '[') { throw new RuntimeException("A JSONArray text must start with '['"); if (x.nextClean() != ']') { x.back(); for (;;) { if (x.nextClean() == ',') { x.back(); myArrayList.add(JSONObject.NULL); } else { x.back(); myArrayList.add(x.nextValue()); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == ']') { return; x.back(); break; case ']':
/** * Get the next n characters. * * @param n The number of characters to take. * @return A string of n characters. * @throws JSONException * Substring bounds error if there are not * n characters remaining in the source string. */ public String next(int n) { if (n == 0) { return ""; } char[] chars = new char[n]; int pos = 0; while (pos < n) { chars[pos] = this.next(); if (this.end()) { throw new RuntimeException("Substring bounds error"); } pos += 1; } return new String(chars); }
/** * Get the next char in the string, skipping whitespace. * @throws JSONException * @return A character, or 0 if there are no more characters. */ public char nextClean() { for (;;) { char c = this.next(); if (c == 0 || c > ' ') { return c; } } }
/** * Get the text up but not including one of the specified delimiter * characters or the end of line, whichever comes first. * @param delimiters A set of delimiter characters. * @return A string, trimmed. */ public String nextTo(String delimiters) { char c; StringBuilder sb = new StringBuilder(); for (;;) { c = this.next(); if (delimiters.indexOf(c) >= 0 || c == 0 || c == '\n' || c == '\r') { if (c != 0) { this.back(); } return sb.toString().trim(); } sb.append(c); } }
/** * @nowebref */ public JSONObject(Reader reader) { this(new JSONTokener(reader)); }
/** * Consume the next character, and check that it matches a specified * character. * @param c The character to match. * @return The character. * @throws JSONException if the character does not match. */ public char next(char c) { char n = this.next(); if (n != c) { throw new RuntimeException("Expected '" + c + "' and instead saw '" + n + "'"); } return n; }
/** * Get the text up but not including one of the specified delimiter * characters or the end of line, whichever comes first. * @param delimiters A set of delimiter characters. * @return A string, trimmed. */ public String nextTo(String delimiters) { char c; StringBuffer sb = new StringBuffer(); for (;;) { c = this.next(); if (delimiters.indexOf(c) >= 0 || c == 0 || c == '\n' || c == '\r') { if (c != 0) { this.back(); } return sb.toString().trim(); } sb.append(c); } }
/** * @nowebref */ public JSONObject(Reader reader) { this(new JSONTokener(reader)); }