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

fix javadoc

This commit is contained in:
John J. Aylward 2018-10-02 13:38:19 -04:00
parent bc347d2c19
commit 30c1bd16ba
2 changed files with 73 additions and 41 deletions

View file

@ -180,10 +180,16 @@ public class JSONArray implements Iterable<Object> {
} }
/** /**
* Construct a JSONArray from an array * Construct a JSONArray from an array.
*
* @param array
* Array. If the parameter passed is null, or not an array, an
* exception will be thrown.
* *
* @throws JSONException * @throws JSONException
* If not an array or if an array value is non-finite number. * If not an array or if an array value is non-finite number.
* @throws NullPointerException
* Thrown if the array parameter is null.
*/ */
public JSONArray(Object array) throws JSONException { public JSONArray(Object array) throws JSONException {
this(); this();
@ -310,17 +316,19 @@ public class JSONArray implements Iterable<Object> {
} }
/** /**
* Get the enum value associated with an index. * Get the enum value associated with an index.
* *
* @param clazz * @param <E>
* The type of enum to retrieve. * Enum Type
* @param index * @param clazz
* The index must be between 0 and length() - 1. * The type of enum to retrieve.
* @return The enum value at the index location * @param index
* @throws JSONException * The index must be between 0 and length() - 1.
* if the key is not found or if the value cannot be converted * @return The enum value at the index location
* to an enum. * @throws JSONException
*/ * if the key is not found or if the value cannot be converted
* to an enum.
*/
public <E extends Enum<E>> E getEnum(Class<E> clazz, int index) throws JSONException { public <E extends Enum<E>> E getEnum(Class<E> clazz, int index) throws JSONException {
E val = optEnum(clazz, index); E val = optEnum(clazz, index);
if(val==null) { if(val==null) {
@ -334,7 +342,10 @@ public class JSONArray implements Iterable<Object> {
} }
/** /**
* Get the BigDecimal value associated with an index. * Get the BigDecimal value associated with an index. If the value is float
* or double, the the {@link BigDecimal#BigDecimal(double)} constructor
* will be used. See notes on the constructor for conversion issues that
* may arise.
* *
* @param index * @param index
* The index must be between 0 and length() - 1. * The index must be between 0 and length() - 1.
@ -683,6 +694,8 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Get the enum value associated with a key. * Get the enum value associated with a key.
* *
* @param <E>
* Enum Type
* @param clazz * @param clazz
* The type of enum to retrieve. * The type of enum to retrieve.
* @param index * @param index
@ -696,6 +709,8 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Get the enum value associated with a key. * Get the enum value associated with a key.
* *
* @param <E>
* Enum Type
* @param clazz * @param clazz
* The type of enum to retrieve. * The type of enum to retrieve.
* @param index * @param index
@ -725,7 +740,6 @@ public class JSONArray implements Iterable<Object> {
} }
} }
/** /**
* Get the optional BigInteger value associated with an index. The * Get the optional BigInteger value associated with an index. The
* defaultValue is returned if there is no value for the index, or if the * defaultValue is returned if there is no value for the index, or if the
@ -745,7 +759,10 @@ public class JSONArray implements Iterable<Object> {
/** /**
* Get the optional BigDecimal value associated with an index. The * Get the optional BigDecimal value associated with an index. The
* defaultValue is returned if there is no value for the index, or if the * defaultValue is returned if there is no value for the index, or if the
* value is not a number and cannot be converted to a number. * value is not a number and cannot be converted to a number. If the value
* is float or double, the the {@link BigDecimal#BigDecimal(double)}
* constructor will be used. See notes on the constructor for conversion
* issues that may arise.
* *
* @param index * @param index
* The index must be between 0 and length() - 1. * The index must be between 0 and length() - 1.
@ -1192,8 +1209,8 @@ public class JSONArray implements Iterable<Object> {
} }
/** /**
* Uses a uaer initialized JSONPointer and tries to * Uses a user initialized JSONPointer and tries to
* match it to an item whithin this JSONArray. For example, given a * match it to an item within this JSONArray. For example, given a
* JSONArray initialized with this document: * JSONArray initialized with this document:
* <pre> * <pre>
* [ * [

View file

@ -576,17 +576,19 @@ public class JSONObject {
} }
/** /**
* Get the enum value associated with a key. * Get the enum value associated with a key.
* *
* @param clazz * @param <E>
* The type of enum to retrieve. * Enum Type
* @param key * @param clazz
* A key string. * The type of enum to retrieve.
* @return The enum value associated with the key * @param key
* @throws JSONException * A key string.
* if the key is not found or if the value cannot be converted * @return The enum value associated with the key
* to an enum. * @throws JSONException
*/ * if the key is not found or if the value cannot be converted
* to an enum.
*/
public <E extends Enum<E>> E getEnum(Class<E> clazz, String key) throws JSONException { public <E extends Enum<E>> E getEnum(Class<E> clazz, String key) throws JSONException {
E val = optEnum(clazz, key); E val = optEnum(clazz, key);
if(val==null) { if(val==null) {
@ -814,6 +816,8 @@ public class JSONObject {
/** /**
* Get an array of field names from a JSONObject. * Get an array of field names from a JSONObject.
* *
* @param jo
* JSON object
* @return An array of field names, or null if there are no names. * @return An array of field names, or null if there are no names.
*/ */
public static String[] getNames(JSONObject jo) { public static String[] getNames(JSONObject jo) {
@ -824,8 +828,10 @@ public class JSONObject {
} }
/** /**
* Get an array of field names from an Object. * Get an array of public field names from an Object.
* *
* @param object
* object to read
* @return An array of field names, or null if there are no names. * @return An array of field names, or null if there are no names.
*/ */
public static String[] getNames(Object object) { public static String[] getNames(Object object) {
@ -1036,6 +1042,8 @@ public class JSONObject {
/** /**
* Get the enum value associated with a key. * Get the enum value associated with a key.
* *
* @param <E>
* Enum Type
* @param clazz * @param clazz
* The type of enum to retrieve. * The type of enum to retrieve.
* @param key * @param key
@ -1049,6 +1057,8 @@ public class JSONObject {
/** /**
* Get the enum value associated with a key. * Get the enum value associated with a key.
* *
* @param <E>
* Enum Type
* @param clazz * @param clazz
* The type of enum to retrieve. * The type of enum to retrieve.
* @param key * @param key
@ -1137,9 +1147,10 @@ public class JSONObject {
} }
/** /**
* @param defaultValue * @param val value to convert
* @param val * @param defaultValue default value to return is the conversion doesn't work or is null.
* @return * @return BigDecimal conversion of the original value, or the defaultValue if unable
* to convert.
*/ */
static BigDecimal objectToBigDecimal(Object val, BigDecimal defaultValue) { static BigDecimal objectToBigDecimal(Object val, BigDecimal defaultValue) {
if (NULL.equals(val)) { if (NULL.equals(val)) {
@ -1187,9 +1198,10 @@ public class JSONObject {
} }
/** /**
* @param defaultValue * @param val value to convert
* @param val * @param defaultValue default value to return is the conversion doesn't work or is null.
* @return * @return BigInteger conversion of the original value, or the defaultValue if unable
* to convert.
*/ */
static BigInteger objectToBigInteger(Object val, BigInteger defaultValue) { static BigInteger objectToBigInteger(Object val, BigInteger defaultValue) {
if (NULL.equals(val)) { if (NULL.equals(val)) {
@ -1859,8 +1871,10 @@ public class JSONObject {
* are both non-null, and only if there is not already a member with that * are both non-null, and only if there is not already a member with that
* name. * name.
* *
* @param key string * @param key
* @param value object * key to insert into
* @param value
* value to insert
* @return this. * @return this.
* @throws JSONException * @throws JSONException
* if the key is a duplicate * if the key is a duplicate
@ -1971,9 +1985,10 @@ public class JSONObject {
/** /**
* Produce a string in double quotes with backslash sequences in all the * Produce a string in double quotes with backslash sequences in all the
* right places. A backslash will be inserted within </, producing <\/, * right places. A backslash will be inserted within &lt;/, producing
* allowing JSON text to be delivered in HTML. In JSON text, a string cannot * &lt;\/, allowing JSON text to be delivered in HTML. In JSON text, a
* contain a control character or an unescaped quote or backslash. * string cannot contain a control character or an unescaped quote or
* backslash.
* *
* @param string * @param string
* A String * A String