incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r603212 - in /incubator/sling/trunk: commons/json/src/main/java/org/apache/sling/commons/json/ commons/json/src/main/java/org/apache/sling/commons/json/http/ commons/json/src/main/java/org/apache/sling/commons/json/xml/ jcr/resource/src/mai...
Date Tue, 11 Dec 2007 11:33:00 GMT
Author: cziegeler
Date: Tue Dec 11 03:32:51 2007
New Revision: 603212

URL: http://svn.apache.org/viewvc?rev=603212&view=rev
Log:
Use java5 features.

Modified:
    incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/JSONObject.java
    incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/http/CookieList.java
    incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/http/HTTP.java
    incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/xml/XML.java
    incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/xml/XMLTokener.java
    incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java

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=603212&r1=603211&r2=603212&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 03:32:51 2007
@@ -128,7 +128,7 @@
     /**
      * The hash map where the JSONObject's properties are kept.
      */
-    private HashMap myHashMap;
+    private HashMap<String, Object> myHashMap;
 
 
     /**
@@ -144,7 +144,7 @@
      * Construct an empty JSONObject.
      */
     public JSONObject() {
-        this.myHashMap = new HashMap();
+        this.myHashMap = new HashMap<String, Object>();
     }
 
 
@@ -229,10 +229,10 @@
      * @param map A map object that can be used to initialize the contents of
      *  the JSONObject.
      */
-    public JSONObject(Map map) {
+    public JSONObject(Map<String, Object> map) {
         this.myHashMap = (map == null) ?
-        	new HashMap() :
-        	new HashMap(map);
+        	new HashMap<String, Object>() :
+        	new HashMap<String, Object>(map);
     }
 
 
@@ -524,7 +524,7 @@
      *
      * @return An iterator of the keys.
      */
-    public Iterator keys() {
+    public Iterator<String> keys() {
         return this.myHashMap.keySet().iterator();
     }
 
@@ -547,7 +547,7 @@
      */
     public JSONArray names() {
         JSONArray ja = new JSONArray();
-        Iterator  keys = keys();
+        Iterator<String>  keys = keys();
         while (keys.hasNext()) {
             ja.put(keys.next());
         }
@@ -1036,15 +1036,15 @@
      */
     public String toString() {
         try {
-            Iterator     keys = keys();
+            Iterator<String>     keys = keys();
             StringBuffer sb = new StringBuffer("{");
 
             while (keys.hasNext()) {
                 if (sb.length() > 1) {
                     sb.append(',');
                 }
-                Object o = keys.next();
-                sb.append(quote(o.toString()));
+                String o = keys.next();
+                sb.append(quote(o));
                 sb.append(':');
                 sb.append(valueToString(this.myHashMap.get(o)));
             }
@@ -1092,13 +1092,13 @@
         if (n == 0) {
             return "{}";
         }
-        Iterator     keys = keys();
+        Iterator<String>     keys = keys();
         StringBuffer sb = new StringBuffer("{");
         int          newindent = indent + indentFactor;
-        Object       o;
+        String       o;
         if (n == 1) {
             o = keys.next();
-            sb.append(quote(o.toString()));
+            sb.append(quote(o));
             sb.append(": ");
             sb.append(valueToString(this.myHashMap.get(o), indentFactor,
                     indent));
@@ -1230,15 +1230,15 @@
      public Writer write(Writer writer) throws JSONException {
         try {
             boolean  b = false;
-            Iterator keys = keys();
+            Iterator<String> keys = keys();
             writer.write('{');
 
             while (keys.hasNext()) {
                 if (b) {
                     writer.write(',');
                 }
-                Object k = keys.next();
-                writer.write(quote(k.toString()));
+                String k = keys.next();
+                writer.write(quote(k));
                 writer.write(':');
                 Object v = this.myHashMap.get(k);
                 if (v instanceof JSONObject) {

Modified: incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/http/CookieList.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/http/CookieList.java?rev=603212&r1=603211&r2=603212&view=diff
==============================================================================
--- incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/http/CookieList.java
(original)
+++ incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/http/CookieList.java
Tue Dec 11 03:32:51 2007
@@ -74,11 +74,11 @@
      */
     public static String toString(JSONObject o) throws JSONException {
         boolean      b = false;
-        Iterator     keys = o.keys();
+        Iterator<String>     keys = o.keys();
         String       s;
         StringBuffer sb = new StringBuffer();
         while (keys.hasNext()) {
-            s = keys.next().toString();
+            s = keys.next();
             if (!o.isNull(s)) {
                 if (b) {
                     sb.append(';');

Modified: incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/http/HTTP.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/http/HTTP.java?rev=603212&r1=603211&r2=603212&view=diff
==============================================================================
--- incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/http/HTTP.java
(original)
+++ incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/http/HTTP.java
Tue Dec 11 03:32:51 2007
@@ -128,7 +128,7 @@
      *  information.
      */
     public static String toString(JSONObject o) throws JSONException {
-        Iterator     keys = o.keys();
+        Iterator<String>     keys = o.keys();
         String       s;
         StringBuffer sb = new StringBuffer();
         if (o.has("Status-Code") && o.has("Reason-Phrase")) {
@@ -150,7 +150,7 @@
         }
         sb.append(CRLF);
         while (keys.hasNext()) {
-            s = keys.next().toString();
+            s = keys.next();
             if (!s.equals("HTTP-Version")      && !s.equals("Status-Code") &&
                     !s.equals("Reason-Phrase") && !s.equals("Method") &&
                     !s.equals("Request-URI")   && !o.isNull(s)) {

Modified: incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/xml/XML.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/xml/XML.java?rev=603212&r1=603211&r2=603212&view=diff
==============================================================================
--- incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/xml/XML.java
(original)
+++ incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/xml/XML.java
Tue Dec 11 03:32:51 2007
@@ -312,7 +312,7 @@
         JSONArray    ja;
         JSONObject   jo;
         String       k;
-        Iterator     keys;
+        Iterator<String>     keys;
         int          len;
         String       s;
         Object       v;
@@ -331,7 +331,7 @@
             jo = (JSONObject)o;
             keys = jo.keys();
             while (keys.hasNext()) {
-                k = keys.next().toString();
+                k = keys.next();
                 v = jo.get(k);
                 if (v instanceof String) {
                     s = (String)v;

Modified: incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/xml/XMLTokener.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/xml/XMLTokener.java?rev=603212&r1=603211&r2=603212&view=diff
==============================================================================
--- incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/xml/XMLTokener.java
(original)
+++ incubator/sling/trunk/commons/json/src/main/java/org/apache/sling/commons/json/xml/XMLTokener.java
Tue Dec 11 03:32:51 2007
@@ -39,10 +39,10 @@
    /** The table of entity values. It initially contains Character values for
     * amp, apos, gt, lt, quot.
     */
-   public static final java.util.HashMap entity;
+   public static final java.util.HashMap<String, Character> entity;
 
    static {
-       entity = new java.util.HashMap(8);
+       entity = new java.util.HashMap<String, Character>(8);
        entity.put("amp",  XML.AMP);
        entity.put("apos", XML.APOS);
        entity.put("gt",   XML.GT);

Modified: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java?rev=603212&r1=603211&r2=603212&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java
(original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java
Tue Dec 11 03:32:51 2007
@@ -71,8 +71,8 @@
         Object propertiesObject = nodeDescriptor.opt("properties");
         if (propertiesObject instanceof JSONObject) {
             JSONObject properties = (JSONObject) propertiesObject;
-            for (Iterator pi=properties.keys(); pi.hasNext(); ) {
-                String propName = (String) pi.next();
+            for (Iterator<String> pi=properties.keys(); pi.hasNext(); ) {
+                String propName = pi.next();
                 Property prop = this.createProperty(propName, properties.get(propName));
                 node.addProperty(prop);
             }



Mime
View raw message