harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r416540 - in /incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility: AccessibleRelationSet.java AccessibleStateSet.java
Date Fri, 23 Jun 2006 01:41:23 GMT
Author: ndbeyer
Date: Thu Jun 22 18:41:23 2006
New Revision: 416540

URL: http://svn.apache.org/viewvc?rev=416540&view=rev
Log:
Generification, cleanup

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility/AccessibleRelationSet.java
    incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility/AccessibleStateSet.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility/AccessibleRelationSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility/AccessibleRelationSet.java?rev=416540&r1=416539&r2=416540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility/AccessibleRelationSet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility/AccessibleRelationSet.java
Thu Jun 22 18:41:23 2006
@@ -25,10 +25,10 @@
 import java.util.Vector;
 
 public class AccessibleRelationSet {
-    protected Vector relations;
+    protected Vector<AccessibleRelation> relations;
 
     public AccessibleRelationSet() {
-        initStorage();
+        initStorage(0);
     }
 
     public AccessibleRelationSet(final AccessibleRelation[] relations) {
@@ -37,7 +37,7 @@
     }
 
     public boolean add(final AccessibleRelation relation) {
-        initStorage();
+        initStorage(1);
         if (contains(relation.key)) {
             return false;
         }
@@ -51,6 +51,12 @@
             add(relations[i]);
         }
     }
+    
+    private void initStorage(final int capacity) {
+        if(relations == null) {
+            relations = new Vector<AccessibleRelation>(capacity);
+        }
+    }
 
     public boolean remove(final AccessibleRelation relation) {
         return relations != null && relations.remove(relation);
@@ -74,8 +80,8 @@
         if (relations == null) {
             return null;
         }
-        for (Iterator i = relations.iterator(); i.hasNext();) {
-            AccessibleRelation rel = (AccessibleRelation)i.next();
+        for (Iterator<AccessibleRelation> i = relations.iterator(); i.hasNext();) {
+            AccessibleRelation rel = i.next();
             if(key.equals(rel.key)) {
                 return rel;
             }
@@ -92,26 +98,13 @@
         if (relations == null) {
             return "";
         }
-        StringBuffer result = new StringBuffer();
-        for (Iterator it = relations.iterator(); it.hasNext(); ) {
+        StringBuilder result = new StringBuilder();
+        for (Iterator<AccessibleRelation> it = relations.iterator(); it.hasNext();
) {
             result.append(it.next());
             if (it.hasNext()) {
                 result.append(",");
             }
         }
         return result.toString();
-    }
-
-
-    private void initStorage(final int capacity) {
-        if(relations == null) {
-            relations = new Vector(capacity);
-        }
-    }
-
-    private void initStorage() {
-        if(relations == null) {
-            relations = new Vector();
-        }
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility/AccessibleStateSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility/AccessibleStateSet.java?rev=416540&r1=416539&r2=416540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility/AccessibleStateSet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/accessibility/src/main/java/javax/accessibility/AccessibleStateSet.java
Thu Jun 22 18:41:23 2006
@@ -25,10 +25,10 @@
 import java.util.Vector;
 
 public class AccessibleStateSet {
-    protected Vector states;
+    protected Vector<AccessibleState> states;
 
     public AccessibleStateSet() {
-        initStorage();
+        initStorage(0);
     }
 
     public AccessibleStateSet(final AccessibleState[] states) {
@@ -37,7 +37,7 @@
     }
 
     public boolean add(final AccessibleState state) {
-        initStorage();
+        initStorage(1);
         if (states.contains(state)) {
             return false;
         }
@@ -51,6 +51,12 @@
             add(states[i]);
         }
     }
+    
+    private void initStorage(final int capacity) {
+        if (states == null) {
+            states = new Vector<AccessibleState>(capacity);
+        }
+    }
 
     public boolean contains(final AccessibleState state) {
         return states == null ? false : states.contains(state);
@@ -72,27 +78,17 @@
     }
 
     public String toString() {
-        if (states == null) return "";
-        StringBuffer str = new StringBuffer();
-        for (Iterator it = states.iterator(); it.hasNext(); ) {
+        if (states == null) {
+            return "";
+        }
+        StringBuilder str = new StringBuilder();
+        for (Iterator<AccessibleState> it = states.iterator(); it.hasNext(); ) {
             str.append(it.next());
             if (it.hasNext()) {
                 str.append(",");
             }
         }
         return str.toString();
-    }
-
-    private void initStorage(final int capacity) {
-        if (states == null) {
-            states = new Vector(capacity);
-        }
-    }
-
-    private void initStorage() {
-        if (states == null) {
-            states = new Vector();
-        }
     }
 }
 



Mime
View raw message