1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 16:00:51 -07:00

gradle support

This commit is contained in:
stleary 2020-05-22 11:17:44 -05:00
parent 1da2b984cd
commit 2b0a8838ef
32 changed files with 647 additions and 131 deletions

View file

@ -98,7 +98,7 @@ public class CDL {
* Produce a JSONArray of strings from a row of comma delimited values.
* @param x A JSONTokener of the source text.
* @return A JSONArray of strings.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException {
JSONArray ja = new JSONArray();
@ -134,7 +134,7 @@ public class CDL {
* method.
* @param x A JSONTokener of the source text.
* @return A JSONObject combining the names and values.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x)
throws JSONException {
@ -184,7 +184,7 @@ public class CDL {
* using the first row as a source of names.
* @param string The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static JSONArray toJSONArray(String string) throws JSONException {
return toJSONArray(new JSONTokener(string));
@ -195,7 +195,7 @@ public class CDL {
* using the first row as a source of names.
* @param x The JSONTokener containing the comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static JSONArray toJSONArray(JSONTokener x) throws JSONException {
return toJSONArray(rowToJSONArray(x), x);
@ -207,7 +207,7 @@ public class CDL {
* @param names A JSONArray of strings.
* @param string The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static JSONArray toJSONArray(JSONArray names, String string)
throws JSONException {
@ -220,7 +220,7 @@ public class CDL {
* @param names A JSONArray of strings.
* @param x A JSONTokener of the source text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static JSONArray toJSONArray(JSONArray names, JSONTokener x)
throws JSONException {
@ -248,7 +248,7 @@ public class CDL {
* JSONObject.
* @param ja A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static String toString(JSONArray ja) throws JSONException {
JSONObject jo = ja.optJSONObject(0);
@ -268,7 +268,7 @@ public class CDL {
* @param names A JSONArray of strings.
* @param ja A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static String toString(JSONArray names, JSONArray ja)
throws JSONException {

View file

@ -76,7 +76,7 @@ public class Cookie {
* @param string The cookie specification string.
* @return A JSONObject containing "name", "value", and possibly other
* members.
* @throws JSONException
* @throws JSONException if a called function fails or a syntax error
*/
public static JSONObject toJSONObject(String string) throws JSONException {
String name;
@ -113,7 +113,7 @@ public class Cookie {
* All other members are ignored.
* @param jo A JSONObject
* @return A cookie specification string
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static String toString(JSONObject jo) throws JSONException {
StringBuilder sb = new StringBuilder();

View file

@ -42,7 +42,7 @@ public class CookieList {
* cookieJSONObject.getString("value"));
* @param string A cookie list string
* @return A JSONObject
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static JSONObject toJSONObject(String string) throws JSONException {
JSONObject jo = new JSONObject();
@ -63,7 +63,7 @@ public class CookieList {
* in the names and values are replaced by "%hh".
* @param jo A JSONObject
* @return A cookie list string
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static String toString(JSONObject jo) throws JSONException {
boolean b = false;

View file

@ -51,12 +51,12 @@ public class HTTP {
* "Reason-Phrase": "OK" (for example)
* }</pre>
* In addition, the other parameters in the header will be captured, using
* the HTTP field names as JSON names, so that <pre>
* the HTTP field names as JSON names, so that <pre>{@code
* Date: Sun, 26 May 2002 18:06:04 GMT
* Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
* Cache-Control: no-cache</pre>
* Cache-Control: no-cache}</pre>
* become
* <pre>{...
* <pre>{@code
* Date: "Sun, 26 May 2002 18:06:04 GMT",
* Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s",
* "Cache-Control": "no-cache",
@ -66,7 +66,7 @@ public class HTTP {
* @param string An HTTP header string.
* @return A JSONObject containing the elements and attributes
* of the XML string.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public static JSONObject toJSONObject(String string) throws JSONException {
JSONObject jo = new JSONObject();

View file

@ -43,8 +43,8 @@ public class HTTPTokener extends JSONTokener {
/**
* Get the next token or string. This is used in parsing HTTP headers.
* @throws JSONException
* @return A String.
* @throws JSONException if a syntax error occurs
*/
public String nextToken() throws JSONException {
char c;

View file

@ -1333,7 +1333,7 @@ public class JSONArray implements Iterable<Object> {
/**
* Make a pretty-printed JSON text of this JSONArray.
*
* <p>If <code>indentFactor > 0</code> and the {@link JSONArray} has only
* <p>If <pre> {@code indentFactor > 0}</pre> and the {@link JSONArray} has only
* one element, then the array will be output on a single line:
* <pre>{@code [1]}</pre>
*
@ -1355,7 +1355,7 @@ public class JSONArray implements Iterable<Object> {
* object, beginning with <code>[</code>&nbsp;<small>(left
* bracket)</small> and ending with <code>]</code>
* &nbsp;<small>(right bracket)</small>.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public String toString(int indentFactor) throws JSONException {
StringWriter sw = new StringWriter();
@ -1370,9 +1370,9 @@ public class JSONArray implements Iterable<Object> {
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
*</b>
*
* @param writer the writer object
* @return The writer.
* @throws JSONException
* @throws JSONException if a called function fails
*/
public Writer write(Writer writer) throws JSONException {
return this.write(writer, 0, 0);
@ -1381,7 +1381,7 @@ public class JSONArray implements Iterable<Object> {
/**
* Write the contents of the JSONArray as JSON text to a writer.
*
* <p>If <code>indentFactor > 0</code> and the {@link JSONArray} has only
* <p>If <pre>{@code indentFactor > 0}</pre> and the {@link JSONArray} has only
* one element, then the array will be output on a single line:
* <pre>{@code [1]}</pre>
*
@ -1404,7 +1404,7 @@ public class JSONArray implements Iterable<Object> {
* @param indent
* The indentation of the top level.
* @return The writer.
* @throws JSONException
* @throws JSONException if a called function fails or unable to write
*/
public Writer write(Writer writer, int indentFactor, int indent)
throws JSONException {

View file

@ -41,7 +41,7 @@ public class JSONML {
* if we are at the outermost level.
* @param keepStrings Don't type-convert text nodes and attribute values
* @return A JSONArray if the value is the outermost tag, otherwise null.
* @throws JSONException
* @throws JSONException if a parsing error occurs
*/
private static Object parse(
XMLTokener x,
@ -238,7 +238,7 @@ public class JSONML {
* attributes, then the second element will be JSONObject containing the
* name/value pairs. If the tag contains children, then strings and
* JSONArrays will represent the child tags.
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
* Comments, prologs, DTDs, and <pre>{@code &lt;[ [ ]]>}</pre> are ignored.
* @param string The source string.
* @return A JSONArray containing the structured data from the XML string.
* @throws JSONException Thrown on error converting to a JSONArray
@ -258,7 +258,7 @@ public class JSONML {
* As opposed to toJSONArray this method does not attempt to convert
* any text node or attribute value to any type
* but just leaves it as a string.
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
* Comments, prologs, DTDs, and <pre>{@code &lt;[ [ ]]>}</pre> are ignored.
* @param string The source string.
* @param keepStrings If true, then values will not be coerced into boolean
* or numeric values and will instead be left as strings
@ -280,7 +280,7 @@ public class JSONML {
* As opposed to toJSONArray this method does not attempt to convert
* any text node or attribute value to any type
* but just leaves it as a string.
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
* Comments, prologs, DTDs, and <pre>{@code &lt;[ [ ]]>}</pre> are ignored.
* @param x An XMLTokener.
* @param keepStrings If true, then values will not be coerced into boolean
* or numeric values and will instead be left as strings
@ -299,7 +299,7 @@ public class JSONML {
* attributes, then the second element will be JSONObject containing the
* name/value pairs. If the tag contains children, then strings and
* JSONArrays will represent the child content and tags.
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
* Comments, prologs, DTDs, and <pre>{@code &lt;[ [ ]]>}</pre> are ignored.
* @param x An XMLTokener.
* @return A JSONArray containing the structured data from the XML string.
* @throws JSONException Thrown on error converting to a JSONArray
@ -317,7 +317,7 @@ public class JSONML {
* contains children, the object will have a "childNodes" property which
* will be an array of strings and JsonML JSONObjects.
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
* Comments, prologs, DTDs, and <pre>{@code &lt;[ [ ]]>}</pre> are ignored.
* @param string The XML source text.
* @return A JSONObject containing the structured data from the XML string.
* @throws JSONException Thrown on error converting to a JSONObject
@ -335,7 +335,7 @@ public class JSONML {
* contains children, the object will have a "childNodes" property which
* will be an array of strings and JsonML JSONObjects.
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
* Comments, prologs, DTDs, and <pre>{@code &lt;[ [ ]]>}</pre> are ignored.
* @param string The XML source text.
* @param keepStrings If true, then values will not be coerced into boolean
* or numeric values and will instead be left as strings
@ -355,7 +355,7 @@ public class JSONML {
* contains children, the object will have a "childNodes" property which
* will be an array of strings and JsonML JSONObjects.
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
* Comments, prologs, DTDs, and <pre>{@code &lt;[ [ ]]>}</pre> are ignored.
* @param x An XMLTokener of the XML source text.
* @return A JSONObject containing the structured data from the XML string.
* @throws JSONException Thrown on error converting to a JSONObject
@ -373,7 +373,7 @@ public class JSONML {
* contains children, the object will have a "childNodes" property which
* will be an array of strings and JsonML JSONObjects.
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
* Comments, prologs, DTDs, and <pre>{@code &lt;[ [ ]]>}</pre> are ignored.
* @param x An XMLTokener of the XML source text.
* @param keepStrings If true, then values will not be coerced into boolean
* or numeric values and will instead be left as strings

View file

@ -2288,16 +2288,16 @@ public class JSONObject {
/**
* Make a pretty-printed JSON text of this JSONObject.
*
* <p>If <code>indentFactor > 0</code> and the {@link JSONObject}
* <p>If <pre>{@code indentFactor > 0}</pre> and the {@link JSONObject}
* has only one key, then the object will be output on a single line:
* <pre>{@code {"key": 1}}</pre>
*
* <p>If an object has 2 or more keys, then it will be output across
* multiple lines: <code><pre>{
* multiple lines: <pre>{@code {
* "key1": 1,
* "key2": "value 2",
* "key3": 3
* }</pre></code>
* }}</pre>
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
* </b>
@ -2409,9 +2409,9 @@ public class JSONObject {
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
* </b>
*
* @param writer the writer object
* @return The writer.
* @throws JSONException
* @throws JSONException if a called function has an error
*/
public Writer write(Writer writer) throws JSONException {
return this.write(writer, 0, 0);
@ -2470,16 +2470,16 @@ public class JSONObject {
/**
* Write the contents of the JSONObject as JSON text to a writer.
*
* <p>If <code>indentFactor > 0</code> and the {@link JSONObject}
* <p>If <pre>{@code indentFactor > 0}</pre> and the {@link JSONObject}
* has only one key, then the object will be output on a single line:
* <pre>{@code {"key": 1}}</pre>
*
* <p>If an object has 2 or more keys, then it will be output across
* multiple lines: <code><pre>{
* multiple lines: <pre>{@code {
* "key1": 1,
* "key2": "value 2",
* "key3": 3
* }</pre></code>
* }}</pre>
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
* </b>
@ -2491,7 +2491,8 @@ public class JSONObject {
* @param indent
* The indentation of the top level.
* @return The writer.
* @throws JSONException
* @throws JSONException if a called function has an error or a write error
* occurs
*/
public Writer write(Writer writer, int indentFactor, int indent)
throws JSONException {

View file

@ -68,6 +68,7 @@ public class JSONPointer {
/**
* Creates a {@code JSONPointer} instance using the tokens previously set using the
* {@link #append(String)} method calls.
* @return a JSONPointer object
*/
public JSONPointer build() {
return new JSONPointer(this.refTokens);
@ -277,6 +278,7 @@ public class JSONPointer {
/**
* Returns a string representing the JSONPointer path value using URI
* fragment identifier representation
* @return a uri fragment string
*/
public String toURIFragment() {
try {

View file

@ -93,6 +93,7 @@ public class JSONWriter {
/**
* Make a fresh JSONWriter. It can be used to build one JSON text.
* @param w an appendable object
*/
public JSONWriter(Appendable w) {
this.comma = false;
@ -373,7 +374,7 @@ public class JSONWriter {
* <code>false</code>.
* @param b A boolean.
* @return this
* @throws JSONException
* @throws JSONException if a called function has an error
*/
public JSONWriter value(boolean b) throws JSONException {
return this.append(b ? "true" : "false");
@ -393,7 +394,7 @@ public class JSONWriter {
* Append a long value.
* @param l A long.
* @return this
* @throws JSONException
* @throws JSONException if a called function has an error
*/
public JSONWriter value(long l) throws JSONException {
return this.append(Long.toString(l));

View file

@ -37,7 +37,7 @@ public class Property {
* Converts a property file object into a JSONObject. The property file object is a table of name value pairs.
* @param properties java.util.Properties
* @return JSONObject
* @throws JSONException
* @throws JSONException if a called function has an error
*/
public static JSONObject toJSONObject(java.util.Properties properties) throws JSONException {
// can't use the new constructor for Android support
@ -57,7 +57,7 @@ public class Property {
* Converts the JSONObject into a property file object.
* @param jo JSONObject
* @return java.util.Properties
* @throws JSONException
* @throws JSONException if a called function has an error
*/
public static Properties toProperties(JSONObject jo) throws JSONException {
Properties properties = new Properties();

View file

@ -50,7 +50,7 @@ public class XML {
/** The Character '='. */
public static final Character EQ = '=';
/** The Character '>'. */
/** The Character <pre>{@code '>'. }</pre>*/
public static final Character GT = '>';
/** The Character '&lt;'. */
@ -113,13 +113,13 @@ public class XML {
/**
* Replace special characters with XML escapes:
*
* <pre>
* &amp; <small>(ampersand)</small> is replaced by &amp;amp;
* &lt; <small>(less than)</small> is replaced by &amp;lt;
* &gt; <small>(greater than)</small> is replaced by &amp;gt;
* &quot; <small>(double quote)</small> is replaced by &amp;quot;
* &apos; <small>(single quote / apostrophe)</small> is replaced by &amp;apos;
* </pre>
* <pre>{@code
* &amp; (ampersand) is replaced by &amp;amp;
* &lt; (less than) is replaced by &amp;lt;
* &gt; (greater than) is replaced by &amp;gt;
* &quot; (double quote) is replaced by &amp;quot;
* &apos; (single quote / apostrophe) is replaced by &amp;apos;
* }</pre>
*
* @param string
* The string to be escaped.
@ -477,7 +477,8 @@ public class XML {
* name/value pairs and arrays of values. JSON does not does not like to
* distinguish between elements and attributes. Sequences of similar
* elements are represented as JSONArrays. Content text may be placed in a
* "content" member. Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code>
* "content" member. Comments, prologs, DTDs, and <pre>{@code
* &lt;[ [ ]]>}</pre>
* are ignored.
*
* @param string
@ -497,7 +498,8 @@ public class XML {
* name/value pairs and arrays of values. JSON does not does not like to
* distinguish between elements and attributes. Sequences of similar
* elements are represented as JSONArrays. Content text may be placed in a
* "content" member. Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code>
* "content" member. Comments, prologs, DTDs, and <pre>{@code
* &lt;[ [ ]]>}</pre>
* are ignored.
*
* @param reader The XML source reader.
@ -516,7 +518,8 @@ public class XML {
* name/value pairs and arrays of values. JSON does not does not like to
* distinguish between elements and attributes. Sequences of similar
* elements are represented as JSONArrays. Content text may be placed in a
* "content" member. Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code>
* "content" member. Comments, prologs, DTDs, and <pre>{@code
* &lt;[ [ ]]>}</pre>
* are ignored.
*
* All values are converted as strings, for 1, 01, 29.0 will not be coerced to
@ -543,7 +546,8 @@ public class XML {
* name/value pairs and arrays of values. JSON does not does not like to
* distinguish between elements and attributes. Sequences of similar
* elements are represented as JSONArrays. Content text may be placed in a
* "content" member. Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code>
* "content" member. Comments, prologs, DTDs, and <pre>{@code
* &lt;[ [ ]]>}</pre>
* are ignored.
*
* All values are converted as strings, for 1, 01, 29.0 will not be coerced to
@ -574,7 +578,8 @@ public class XML {
* name/value pairs and arrays of values. JSON does not does not like to
* distinguish between elements and attributes. Sequences of similar
* elements are represented as JSONArrays. Content text may be placed in a
* "content" member. Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code>
* "content" member. Comments, prologs, DTDs, and <pre>{@code
* &lt;[ [ ]]>}</pre>
* are ignored.
*
* All values are converted as strings, for 1, 01, 29.0 will not be coerced to
@ -599,7 +604,8 @@ public class XML {
* name/value pairs and arrays of values. JSON does not does not like to
* distinguish between elements and attributes. Sequences of similar
* elements are represented as JSONArrays. Content text may be placed in a
* "content" member. Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code>
* "content" member. Comments, prologs, DTDs, and <pre>{@code
* &lt;[ [ ]]>}</pre>
* are ignored.
*
* All values are converted as strings, for 1, 01, 29.0 will not be coerced to

View file

@ -90,12 +90,13 @@ public class XMLTokener extends JSONTokener {
/**
* Get the next XML outer token, trimming whitespace. There are two kinds
* of tokens: the '<' character which begins a markup tag, and the content
* of tokens: the <pre>{@code '<' }</pre> character which begins a markup
* tag, and the content
* text between markup tags.
*
* @return A string, or a '<' Character, or null if there is no more
* source text.
* @throws JSONException
* @return A string, or a <pre>{@code '<' }</pre> Character, or null if
* there is no more source text.
* @throws JSONException if a called function has an error
*/
public Object nextContent() throws JSONException {
char c;
@ -129,8 +130,10 @@ public class XMLTokener extends JSONTokener {
/**
* <pre>{@code
* Return the next entity. These entities are translated to Characters:
* <code>&amp; &apos; &gt; &lt; &quot;</code>.
* &amp; &apos; &gt; &lt; &quot;.
* }</pre>
* @param ampersand An ampersand character.
* @return A Character or an entity String if the entity is not recognized.
* @throws JSONException If missing ';' in XML entity.
@ -183,11 +186,14 @@ public class XMLTokener extends JSONTokener {
/**
* <pre>{@code
* Returns the next XML meta token. This is used for skipping over <!...>
* and <?...?> structures.
* @return Syntax characters (<code>< > / = ! ?</code>) are returned as
* }</pre>
* @return <pre>{@code Syntax characters (< > / = ! ?) are returned as
* Character, and strings and names are returned as Boolean. We don't care
* what the values actually are.
* }</pre>
* @throws JSONException If a string is not properly closed or if the XML
* is badly structured.
*/
@ -250,10 +256,12 @@ public class XMLTokener extends JSONTokener {
/**
* <pre>{@code
* Get the next XML Token. These tokens are found inside of angle
* brackets. It may be one of these characters: <code>/ > = ! ?</code> or it
* brackets. It may be one of these characters: / > = ! ? or it
* may be a string wrapped in single quotes or double quotes, or it may be a
* name.
* }</pre>
* @return a String or a Character.
* @throws JSONException If the XML is not well formed.
*/