You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2007/12/17 18:21:57 UTC
svn commit: r604935 - in
/incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json:
JSONArray.java JSONObject.java
Author: cziegeler
Date: Mon Dec 17 09:21:57 2007
New Revision: 604935
URL: http://svn.apache.org/viewvc?rev=604935&view=rev
Log:
Use generics and clean up code.
Modified:
incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONArray.java
incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONObject.java
Modified: incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONArray.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONArray.java?rev=604935&r1=604934&r2=604935&view=diff
==============================================================================
--- incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONArray.java (original)
+++ incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONArray.java Mon Dec 17 09:21:57 2007
@@ -542,7 +542,7 @@
* @param value A Collection value.
* @return this.
*/
- public JSONArray put(Collection value) {
+ public JSONArray put(Collection<Object> value) {
put(new JSONArray(value));
return this;
}
@@ -593,7 +593,7 @@
* @param value A Map value.
* @return this.
*/
- public JSONArray put(Map value) {
+ public JSONArray put(Map<String, Object> value) {
put(new JSONObject(value));
return this;
}
@@ -636,7 +636,7 @@
* @throws JSONException If the index is negative or if the value is
* not finite.
*/
- public JSONArray put(int index, Collection value) throws JSONException {
+ public JSONArray put(int index, Collection<Object> value) throws JSONException {
put(index, new JSONArray(value));
return this;
}
@@ -697,7 +697,7 @@
* @throws JSONException If the index is negative or if the the value is
* an invalid number.
*/
- public JSONArray put(int index, Map value) throws JSONException {
+ public JSONArray put(int index, Map<String, Object> value) throws JSONException {
put(index, new JSONObject(value));
return this;
}
Modified: incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONObject.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONObject.java?rev=604935&r1=604934&r2=604935&view=diff
==============================================================================
--- incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONObject.java (original)
+++ incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONObject.java Mon Dec 17 09:21:57 2007
@@ -157,7 +157,6 @@
* @exception JSONException If a value is a non-finite number.
*/
public JSONObject(JSONObject jo, String[] sa) throws JSONException {
- this();
for (int i = 0; i < sa.length; i += 1) {
putOpt(sa[i], jo.opt(sa[i]));
}
@@ -170,7 +169,6 @@
* @throws JSONException If there is a syntax error in the source string.
*/
public JSONObject(JSONTokener x) throws JSONException {
- this();
char c;
String key;
@@ -248,8 +246,7 @@
* from the object.
*/
public JSONObject(Object object, String names[]) {
- this();
- Class c = object.getClass();
+ Class<? extends Object> c = object.getClass();
for (int i = 0; i < names.length; i += 1) {
try {
String name = names[i];
@@ -257,7 +254,7 @@
Object value = field.get(object);
this.put(name, value);
} catch (Exception e) {
- /* forget about it */
+ // forget about it
}
}
}
@@ -341,7 +338,7 @@
return "null";
}
-// Shave off trailing zeros and decimal point, if possible.
+ // Shave off trailing zeros and decimal point, if possible.
String s = Double.toString(d);
if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) {
@@ -567,7 +564,7 @@
}
testValidity(n);
-// Shave off trailing zeros and decimal point, if possible.
+ // Shave off trailing zeros and decimal point, if possible.
String s = n.toString();
if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) {
@@ -631,7 +628,7 @@
* @return this.
* @throws JSONException
*/
- public JSONObject put(String key, Collection value) throws JSONException {
+ public JSONObject put(String key, Collection<Object> value) throws JSONException {
put(key, new JSONArray(value));
return this;
}
@@ -857,7 +854,7 @@
* @return this.
* @throws JSONException
*/
- public JSONObject put(String key, Map value) throws JSONException {
+ public JSONObject put(String key, Map<String, Object> value) throws JSONException {
put(key, new JSONObject(value));
return this;
}