Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 50369 invoked from network); 11 Dec 2007 12:59:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Dec 2007 12:59:06 -0000 Received: (qmail 28330 invoked by uid 500); 11 Dec 2007 12:58:55 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 28281 invoked by uid 500); 11 Dec 2007 12:58:55 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 28272 invoked by uid 99); 11 Dec 2007 12:58:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 04:58:55 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 12:58:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2B9921A9832; Tue, 11 Dec 2007 04:58:45 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r603232 - in /incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json: JSONArray.java JSONObject.java Date: Tue, 11 Dec 2007 12:58:44 -0000 To: sling-commits@incubator.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071211125845.2B9921A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cziegeler Date: Tue Dec 11 04:58:44 2007 New Revision: 603232 URL: http://svn.apache.org/viewvc?rev=603232&view=rev Log: Use java5 features and use linked hash map in order persist the order of properties inside the map. 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=603232&r1=603231&r2=603232&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 Tue Dec 11 04:58:44 2007 @@ -86,14 +86,14 @@ /** * The arrayList where the JSONArray's properties are kept. */ - private ArrayList myArrayList; + private ArrayList myArrayList; /** * Construct an empty JSONArray. */ public JSONArray() { - this.myArrayList = new ArrayList(); + this.myArrayList = new ArrayList(); } /** @@ -151,10 +151,10 @@ * Construct a JSONArray from a Collection. * @param collection A Collection. */ - public JSONArray(Collection collection) { + public JSONArray(Collection collection) { this.myArrayList = (collection == null) ? - new ArrayList() : - new ArrayList(collection); + new ArrayList() : + new ArrayList(collection); } @@ -210,7 +210,7 @@ Object o = get(index); try { return o instanceof Number ? - ((Number)o).doubleValue() : + ((Number)o).doubleValue() : Double.valueOf((String)o).doubleValue(); } catch (Exception e) { throw new JSONException("JSONArray[" + index + @@ -546,7 +546,7 @@ put(new JSONArray(value)); return this; } - + /** * Append a double value. This increases the array's length by one. @@ -597,8 +597,8 @@ put(new JSONObject(value)); return this; } - - + + /** * Append an object value. This increases the array's length by one. * @param value An object value. The value should be a @@ -626,7 +626,7 @@ return this; } - + /** * Put a value in the JSONArray, where the value will be a * JSONArray which is produced from a Collection. @@ -641,7 +641,7 @@ return this; } - + /** * Put or replace a double value. If the index is greater than the length of * the JSONArray, then null elements will be added as necessary to pad @@ -701,8 +701,8 @@ put(index, new JSONObject(value)); return this; } - - + + /** * Put or replace an object value in the JSONArray. If the index is greater * than the length of the JSONArray, then null elements will be added as 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=603232&r1=603231&r2=603232&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 Tue Dec 11 04:58:44 2007 @@ -28,8 +28,8 @@ import java.io.Writer; import java.lang.reflect.Field; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; /** @@ -128,7 +128,7 @@ /** * The hash map where the JSONObject's properties are kept. */ - private HashMap myHashMap; + private Map myHashMap; /** @@ -144,7 +144,7 @@ * Construct an empty JSONObject. */ public JSONObject() { - this.myHashMap = new HashMap(); + this.myHashMap = new LinkedHashMap(); } @@ -231,8 +231,8 @@ */ public JSONObject(Map map) { this.myHashMap = (map == null) ? - new HashMap() : - new HashMap(map); + new LinkedHashMap() : + new LinkedHashMap(map); }