Skip to content

Commit 30c1bd1

Browse files
author
John J. Aylward
committed
fix javadoc
1 parent bc347d2 commit 30c1bd1

2 files changed

Lines changed: 73 additions & 41 deletions

File tree

JSONArray.java

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,16 @@ public JSONArray(Collection<?> collection) {
180180
}
181181

182182
/**
183-
* Construct a JSONArray from an array
183+
* Construct a JSONArray from an array.
184+
*
185+
* @param array
186+
* Array. If the parameter passed is null, or not an array, an
187+
* exception will be thrown.
184188
*
185189
* @throws JSONException
186-
* If not an array or if an array value is non-finite number.
190+
* If not an array or if an array value is non-finite number.
191+
* @throws NullPointerException
192+
* Thrown if the array parameter is null.
187193
*/
188194
public JSONArray(Object array) throws JSONException {
189195
this();
@@ -310,17 +316,19 @@ public Number getNumber(int index) throws JSONException {
310316
}
311317

312318
/**
313-
* Get the enum value associated with an index.
314-
*
315-
* @param clazz
316-
* The type of enum to retrieve.
317-
* @param index
318-
* The index must be between 0 and length() - 1.
319-
* @return The enum value at the index location
320-
* @throws JSONException
321-
* if the key is not found or if the value cannot be converted
322-
* to an enum.
323-
*/
319+
* Get the enum value associated with an index.
320+
*
321+
* @param <E>
322+
* Enum Type
323+
* @param clazz
324+
* The type of enum to retrieve.
325+
* @param index
326+
* The index must be between 0 and length() - 1.
327+
* @return The enum value at the index location
328+
* @throws JSONException
329+
* if the key is not found or if the value cannot be converted
330+
* to an enum.
331+
*/
324332
public <E extends Enum<E>> E getEnum(Class<E> clazz, int index) throws JSONException {
325333
E val = optEnum(clazz, index);
326334
if(val==null) {
@@ -334,7 +342,10 @@ public <E extends Enum<E>> E getEnum(Class<E> clazz, int index) throws JSONExcep
334342
}
335343

336344
/**
337-
* Get the BigDecimal value associated with an index.
345+
* Get the BigDecimal value associated with an index. If the value is float
346+
* or double, the the {@link BigDecimal#BigDecimal(double)} constructor
347+
* will be used. See notes on the constructor for conversion issues that
348+
* may arise.
338349
*
339350
* @param index
340351
* The index must be between 0 and length() - 1.
@@ -683,6 +694,8 @@ public int optInt(int index, int defaultValue) {
683694
/**
684695
* Get the enum value associated with a key.
685696
*
697+
* @param <E>
698+
* Enum Type
686699
* @param clazz
687700
* The type of enum to retrieve.
688701
* @param index
@@ -696,6 +709,8 @@ public <E extends Enum<E>> E optEnum(Class<E> clazz, int index) {
696709
/**
697710
* Get the enum value associated with a key.
698711
*
712+
* @param <E>
713+
* Enum Type
699714
* @param clazz
700715
* The type of enum to retrieve.
701716
* @param index
@@ -725,7 +740,6 @@ public <E extends Enum<E>> E optEnum(Class<E> clazz, int index, E defaultValue)
725740
}
726741
}
727742

728-
729743
/**
730744
* Get the optional BigInteger value associated with an index. The
731745
* defaultValue is returned if there is no value for the index, or if the
@@ -745,7 +759,10 @@ public BigInteger optBigInteger(int index, BigInteger defaultValue) {
745759
/**
746760
* Get the optional BigDecimal value associated with an index. The
747761
* defaultValue is returned if there is no value for the index, or if the
748-
* value is not a number and cannot be converted to a number.
762+
* value is not a number and cannot be converted to a number. If the value
763+
* is float or double, the the {@link BigDecimal#BigDecimal(double)}
764+
* constructor will be used. See notes on the constructor for conversion
765+
* issues that may arise.
749766
*
750767
* @param index
751768
* The index must be between 0 and length() - 1.
@@ -1192,8 +1209,8 @@ public Object query(String jsonPointer) {
11921209
}
11931210

11941211
/**
1195-
* Uses a uaer initialized JSONPointer and tries to
1196-
* match it to an item whithin this JSONArray. For example, given a
1212+
* Uses a user initialized JSONPointer and tries to
1213+
* match it to an item within this JSONArray. For example, given a
11971214
* JSONArray initialized with this document:
11981215
* <pre>
11991216
* [

JSONObject.java

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -576,17 +576,19 @@ public Object get(String key) throws JSONException {
576576
}
577577

578578
/**
579-
* Get the enum value associated with a key.
580-
*
581-
* @param clazz
582-
* The type of enum to retrieve.
583-
* @param key
584-
* A key string.
585-
* @return The enum value associated with the key
586-
* @throws JSONException
587-
* if the key is not found or if the value cannot be converted
588-
* to an enum.
589-
*/
579+
* Get the enum value associated with a key.
580+
*
581+
* @param <E>
582+
* Enum Type
583+
* @param clazz
584+
* The type of enum to retrieve.
585+
* @param key
586+
* A key string.
587+
* @return The enum value associated with the key
588+
* @throws JSONException
589+
* if the key is not found or if the value cannot be converted
590+
* to an enum.
591+
*/
590592
public <E extends Enum<E>> E getEnum(Class<E> clazz, String key) throws JSONException {
591593
E val = optEnum(clazz, key);
592594
if(val==null) {
@@ -814,6 +816,8 @@ public long getLong(String key) throws JSONException {
814816
/**
815817
* Get an array of field names from a JSONObject.
816818
*
819+
* @param jo
820+
* JSON object
817821
* @return An array of field names, or null if there are no names.
818822
*/
819823
public static String[] getNames(JSONObject jo) {
@@ -824,8 +828,10 @@ public static String[] getNames(JSONObject jo) {
824828
}
825829

826830
/**
827-
* Get an array of field names from an Object.
831+
* Get an array of public field names from an Object.
828832
*
833+
* @param object
834+
* object to read
829835
* @return An array of field names, or null if there are no names.
830836
*/
831837
public static String[] getNames(Object object) {
@@ -1036,6 +1042,8 @@ public Object opt(String key) {
10361042
/**
10371043
* Get the enum value associated with a key.
10381044
*
1045+
* @param <E>
1046+
* Enum Type
10391047
* @param clazz
10401048
* The type of enum to retrieve.
10411049
* @param key
@@ -1049,6 +1057,8 @@ public <E extends Enum<E>> E optEnum(Class<E> clazz, String key) {
10491057
/**
10501058
* Get the enum value associated with a key.
10511059
*
1060+
* @param <E>
1061+
* Enum Type
10521062
* @param clazz
10531063
* The type of enum to retrieve.
10541064
* @param key
@@ -1137,9 +1147,10 @@ public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) {
11371147
}
11381148

11391149
/**
1140-
* @param defaultValue
1141-
* @param val
1142-
* @return
1150+
* @param val value to convert
1151+
* @param defaultValue default value to return is the conversion doesn't work or is null.
1152+
* @return BigDecimal conversion of the original value, or the defaultValue if unable
1153+
* to convert.
11431154
*/
11441155
static BigDecimal objectToBigDecimal(Object val, BigDecimal defaultValue) {
11451156
if (NULL.equals(val)) {
@@ -1187,9 +1198,10 @@ public BigInteger optBigInteger(String key, BigInteger defaultValue) {
11871198
}
11881199

11891200
/**
1190-
* @param defaultValue
1191-
* @param val
1192-
* @return
1201+
* @param val value to convert
1202+
* @param defaultValue default value to return is the conversion doesn't work or is null.
1203+
* @return BigInteger conversion of the original value, or the defaultValue if unable
1204+
* to convert.
11931205
*/
11941206
static BigInteger objectToBigInteger(Object val, BigInteger defaultValue) {
11951207
if (NULL.equals(val)) {
@@ -1859,8 +1871,10 @@ public JSONObject put(String key, Object value) throws JSONException {
18591871
* are both non-null, and only if there is not already a member with that
18601872
* name.
18611873
*
1862-
* @param key string
1863-
* @param value object
1874+
* @param key
1875+
* key to insert into
1876+
* @param value
1877+
* value to insert
18641878
* @return this.
18651879
* @throws JSONException
18661880
* if the key is a duplicate
@@ -1971,9 +1985,10 @@ public Object optQuery(JSONPointer jsonPointer) {
19711985

19721986
/**
19731987
* Produce a string in double quotes with backslash sequences in all the
1974-
* right places. A backslash will be inserted within </, producing <\/,
1975-
* allowing JSON text to be delivered in HTML. In JSON text, a string cannot
1976-
* contain a control character or an unescaped quote or backslash.
1988+
* right places. A backslash will be inserted within &lt;/, producing
1989+
* &lt;\/, allowing JSON text to be delivered in HTML. In JSON text, a
1990+
* string cannot contain a control character or an unescaped quote or
1991+
* backslash.
19771992
*
19781993
* @param string
19791994
* A String

0 commit comments

Comments
 (0)