harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r414913 [2/2] - /incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/
Date Fri, 16 Jun 2006 21:11:02 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java?rev=414913&r1=414912&r2=414913&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
Fri Jun 16 14:11:01 2006
@@ -23,31 +23,31 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
-
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author Maxim V. Berkultsev
  * @version $Revision: 1.13.2.4 $
  */
-
 public class PropertyChangeSupport implements Serializable {
 
 	private static final long serialVersionUID = 6401253773779951803l;
 
 	private transient Object sourceBean;
 
-	private transient ArrayList<PropertyChangeListener> allPropertiesChangeListeners =
+	private transient List<PropertyChangeListener> allPropertiesChangeListeners =
 		new ArrayList<PropertyChangeListener>();
 
-	private transient HashMap<String, ArrayList<PropertyChangeListener>> selectedPropertiesChangeListeners
=
-		new HashMap<String, ArrayList<PropertyChangeListener>>();
+	private transient Map<String, List<PropertyChangeListener>> selectedPropertiesChangeListeners
=
+		new HashMap<String, List<PropertyChangeListener>>();
 
 	// fields for serialization compatibility
-	private Hashtable<String, ArrayList<PropertyChangeListener>> children;
+	private Hashtable<String, List<PropertyChangeListener>> children;
 
 	private Object source;
 
@@ -95,7 +95,7 @@
 	public synchronized void removePropertyChangeListener(String propertyName,
 			PropertyChangeListener listener) {
 		if ((propertyName != null) && (listener != null)) {
-			ArrayList listeners = selectedPropertiesChangeListeners
+			List<PropertyChangeListener> listeners = selectedPropertiesChangeListeners
 					.get(propertyName);
 
 			if (listeners != null) {
@@ -110,7 +110,7 @@
 	public synchronized void addPropertyChangeListener(String propertyName,
 			PropertyChangeListener listener) {
 		if ((listener != null) && (propertyName != null)) {
-			ArrayList<PropertyChangeListener> listeners = selectedPropertiesChangeListeners
+			List<PropertyChangeListener> listeners = selectedPropertiesChangeListeners
 					.get(propertyName);
 
 			if (listeners == null) {
@@ -127,7 +127,7 @@
 	 */
 	public synchronized PropertyChangeListener[] getPropertyChangeListeners(
 			String propertyName) {
-		ArrayList listeners = null;
+		List<PropertyChangeListener> listeners = null;
 
 		if (propertyName != null) {
 			listeners = selectedPropertiesChangeListeners.get(propertyName);
@@ -198,7 +198,7 @@
 	public synchronized boolean hasListeners(String propertyName) {
 		boolean result = allPropertiesChangeListeners.size() > 0;
 		if (!result && (propertyName != null)) {
-			ArrayList listeners = selectedPropertiesChangeListeners
+			List<PropertyChangeListener> listeners = selectedPropertiesChangeListeners
 					.get(propertyName);
 			if (listeners != null) {
 				result = listeners.size() > 0;
@@ -257,7 +257,7 @@
 		while (keysIterator.hasNext()) {
 			String propertyName = keysIterator.next();
 
-			ArrayList<PropertyChangeListener> selectedListeners = selectedPropertiesChangeListeners
+			List<PropertyChangeListener> selectedListeners = selectedPropertiesChangeListeners
 					.get(propertyName);
 			if (selectedListeners != null) {
 
@@ -280,9 +280,9 @@
 	 * @com.intel.drl.spec_ref
 	 */
 	private void writeObject(ObjectOutputStream oos) throws IOException {
-		ArrayList<PropertyChangeListener> allSerializedPropertiesChangeListeners =
+		List<PropertyChangeListener> allSerializedPropertiesChangeListeners =
 			new ArrayList<PropertyChangeListener>();
-		Iterator i = allPropertiesChangeListeners.iterator();
+		Iterator<PropertyChangeListener> i = allPropertiesChangeListeners.iterator();
 		while (i.hasNext()) {
 			PropertyChangeListener pcl = (PropertyChangeListener) i.next();
 			if (pcl instanceof Serializable) {
@@ -290,16 +290,16 @@
 			}
 		}
 
-		HashMap<String, ArrayList<PropertyChangeListener>> selectedSerializedPropertiesChangeListeners
=
-			new HashMap<String, ArrayList<PropertyChangeListener>>();
+		Map<String, List<PropertyChangeListener>> selectedSerializedPropertiesChangeListeners
=
+			new HashMap<String, List<PropertyChangeListener>>();
 		Iterator<String> keyIterator = selectedPropertiesChangeListeners
 				.keySet().iterator();
 		while (keyIterator.hasNext()) {
 			String propertyName = keyIterator.next();
-			ArrayList<PropertyChangeListener> keyValues = selectedPropertiesChangeListeners
+			List<PropertyChangeListener> keyValues = selectedPropertiesChangeListeners
 					.get(propertyName);
 			if (keyValues != null) {
-				ArrayList<PropertyChangeListener> serializedPropertiesChangeListeners =
+				List<PropertyChangeListener> serializedPropertiesChangeListeners =
 					new ArrayList<PropertyChangeListener>();
 
 				Iterator<PropertyChangeListener> j = keyValues.iterator();
@@ -318,7 +318,7 @@
 			}
 		}
 
-		children = new Hashtable<String, ArrayList<PropertyChangeListener>>(
+		children = new Hashtable<String, List<PropertyChangeListener>>(
 				selectedSerializedPropertiesChangeListeners);
 		children.put("", allSerializedPropertiesChangeListeners);
 		oos.writeObject(children);
@@ -337,10 +337,10 @@
 	 */
 	private void readObject(ObjectInputStream ois) throws IOException,
 			ClassNotFoundException {
-		children = (Hashtable<String, ArrayList<PropertyChangeListener>>) ois
+		children = (Hashtable<String, List<PropertyChangeListener>>)ois
 				.readObject();
 
-		selectedPropertiesChangeListeners = new HashMap<String, ArrayList<PropertyChangeListener>>(
+		selectedPropertiesChangeListeners = new HashMap<String, List<PropertyChangeListener>>(
 				children);
 		allPropertiesChangeListeners = selectedPropertiesChangeListeners
 				.remove("");
@@ -387,13 +387,13 @@
 			return;
 		}
 
-		Iterator iterator = allPropertiesChangeListeners.iterator();
+		Iterator<PropertyChangeListener> iterator = allPropertiesChangeListeners.iterator();
 		while (iterator.hasNext()) {
 			PropertyChangeListener listener = (PropertyChangeListener) iterator
 					.next();
 			listener.propertyChange(event);
 		}
-		ArrayList listeners = selectedPropertiesChangeListeners
+		List<PropertyChangeListener> listeners = selectedPropertiesChangeListeners
 				.get(propertyName);
 		if (listeners != null) {
 			iterator = listeners.iterator();
@@ -406,7 +406,7 @@
 	}
 
 	private static PropertyChangeListener[] getAsPropertyChangeListenerArray(
-			ArrayList listeners) {
+			List<PropertyChangeListener> listeners) {
 		Object[] objects = listeners.toArray();
 		PropertyChangeListener[] arrayResult = new PropertyChangeListener[objects.length];
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java?rev=414913&r1=414912&r2=414913&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
Fri Jun 16 14:11:01 2006
@@ -31,13 +31,13 @@
 
 public class PropertyDescriptor extends FeatureDescriptor {
 
-    Class beanClass = null;
+    Class<?> beanClass = null;
     String propertyName = null;
     
     Method getter = null;
     Method setter = null;
     
-    Class propertyEditorClass = null;
+    Class<?> propertyEditorClass = null;
     
     boolean constrained = false;
     boolean bound = false;
@@ -136,8 +136,8 @@
                         + "equal to 1.");
             }
             
-            Class parameterType = parameterTypes[0];
-            Class propertyType = getPropertyType();
+            Class<?> parameterType = parameterTypes[0];
+            Class<?> propertyType = getPropertyType();
             if(propertyType != null && !propertyType.equals(parameterType)) {
                 throw new IntrospectionException(
                         "Parameter type in setter method does not "
@@ -166,8 +166,8 @@
                         + "equal to 0.");
             }
             
-            Class returnType = getter.getReturnType();
-            Class propertyType = getPropertyType();
+            Class<?> returnType = getter.getReturnType();
+            Class<?> propertyType = getPropertyType();
             if((propertyType != null) && !returnType.equals(propertyType)) {
                 throw new IntrospectionException(
                         "Parameter type in getter method does not "
@@ -237,7 +237,7 @@
      * @com.intel.drl.spec_ref
      */
     public Class<?> getPropertyType() {
-        Class result = null;
+        Class<?> result = null;
         if (getter != null) {
             result = getter.getReturnType();
         } else if (setter != null) {
@@ -282,7 +282,7 @@
         return bound;
     }
     
-    boolean hasMethod(Class beanClass, String methodName) {
+    boolean hasMethod(Class<?> beanClass, String methodName) {
         Method[] methods = findMethods(beanClass, methodName);
         return (methods.length > 0);
     }
@@ -297,7 +297,7 @@
         return result;
     }
     
-    Method[] findMethods(Class aClass, String methodName) {
+    Method[] findMethods(Class<?> aClass, String methodName) {
         Method[] allMethods = aClass.getMethods();
         Vector<Method> matchedMethods = new Vector<Method>();
         for (int i = 0; i < allMethods.length; ++i) {
@@ -314,7 +314,7 @@
         return result;
     }
     
-    private void setReadMethod(Class beanClass, String getterName) {
+    private void setReadMethod(Class<?> beanClass, String getterName) {
         boolean result = false;
         
         Method[] getters = findMethods(beanClass, getterName);
@@ -332,7 +332,7 @@
         }
     }
 
-    private void setWriteMethod(Class beanClass, String setterName)
+    private void setWriteMethod(Class<?> beanClass, String setterName)
             throws IntrospectionException {
         boolean result = false;
         

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorManager.java?rev=414913&r1=414912&r2=414913&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorManager.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorManager.java
Fri Jun 16 14:11:01 2006
@@ -21,6 +21,7 @@
 package java.beans;
 
 import java.util.HashMap;
+import java.util.Map;
 
 /**
  * @author Maxim V. Berkultsev
@@ -30,7 +31,7 @@
 public class PropertyEditorManager {
     
     private static String[] path = {"org.apache.harmony.beans.editors"};
-    private static HashMap<Class, Class> registeredEditors = new HashMap<Class,
Class>();
+    private static Map<Class<?>, Class<?>> registeredEditors = new HashMap<Class<?>,
Class<?>>();
     
     /**
      */
@@ -64,10 +65,10 @@
             throw new NullPointerException();
         }
 
-        Class editorClass = null;
+        Class<?> editorClass = null;
         PropertyEditor editor = null;
 
-        editorClass = (Class) registeredEditors.get(targetType);
+        editorClass = registeredEditors.get(targetType);
 
         if (editorClass == null) {
             String editorClassName = targetType.getName() + "Editor";

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorSupport.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorSupport.java?rev=414913&r1=414912&r2=414913&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorSupport.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorSupport.java
Fri Jun 16 14:11:01 2006
@@ -25,6 +25,7 @@
 import java.awt.Rectangle;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author Maxim V. Berkultsev
@@ -34,7 +35,7 @@
 public class PropertyEditorSupport implements PropertyEditor {
     
     Object source = null;
-    ArrayList<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
+    List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
     Object oldValue = null;
     Object newValue = null;
 
@@ -150,7 +151,7 @@
         if(listeners.size() > 0) {
             PropertyChangeEvent event = new PropertyChangeEvent(
                     source, null, oldValue, newValue);
-            Iterator iterator = listeners.iterator();
+            Iterator<PropertyChangeListener> iterator = listeners.iterator();
             while (iterator.hasNext()) {
                 PropertyChangeListener listener =
                         (PropertyChangeListener) iterator.next();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java?rev=414913&r1=414912&r2=414913&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/SimpleBeanInfo.java
Fri Jun 16 14:11:01 2006
@@ -60,10 +60,10 @@
                 
                 result = new byte[byteArrayList.size()];
                 
-                Iterator i = byteArrayList.iterator();
+                Iterator<Byte> i = byteArrayList.iterator();
                 int idx = 0;
                 while(i.hasNext()) {
-                    result[idx++] = ((Byte) i.next()).byteValue();
+                    result[idx++] = i.next().byteValue();
                 }
                 
             } catch (IOException ioe) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Statement.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Statement.java?rev=414913&r1=414912&r2=414913&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Statement.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Statement.java
Fri Jun 16 14:11:01 2006
@@ -108,7 +108,7 @@
                     target instanceof Class &&
                     ((Class) target).getName().equals("java.lang.reflect.Array"))
             {
-                Class componentType = (Class) arguments[0];
+                Class<?> componentType = (Class) arguments[0];
                 int length = ((Integer) arguments[1]).intValue();
 
                 result = Array.newInstance(componentType, length);
@@ -116,12 +116,12 @@
                       methodName.equals("newInstance"))
             {
                 if(target instanceof Class) {
-                    Constructor constructor = findConstructor();
+                    Constructor<?> constructor = findConstructor();
                     
                     result = constructor.newInstance(arguments);
                 } else {
                     // XXX should be investigated, dead code?
-                    Constructor constructor = findConstructor();
+                    Constructor<?> constructor = findConstructor();
 
                     result = constructor.newInstance(arguments);
                 }
@@ -180,16 +180,16 @@
         return args;
     }
     
-    private Constructor findConstructor() throws NoSuchMethodException {
+    private Constructor<?> findConstructor() throws NoSuchMethodException {
         Class[] argClasses = getClasses();
-        Class targetClass = (Class) target;
+        Class<?> targetClass = (Class) target;
 
-        Constructor result = null;
+        Constructor<?> result = null;
         Constructor[] constructors = targetClass.getConstructors();
 
         for(int i = 0; i < constructors.length; ++i) {
-            Constructor constructor = constructors[i];
-            Class[] parameterTypes = constructor.getParameterTypes();
+            Constructor<?> constructor = constructors[i];
+            Class<?>[] parameterTypes = constructor.getParameterTypes();
 
             if(parameterTypes.length == argClasses.length) {
                 boolean found = true;
@@ -230,7 +230,7 @@
     
     private Method findStaticMethod() throws NoSuchMethodException {
         Class[] argClasses = getClasses();
-        Class targetClass = (Class) target;
+        Class<?> targetClass = (Class) target;
         
         Method result = null;
         
@@ -241,7 +241,7 @@
                     method.getModifiers())) {
                 continue;
             }
-            Class[] parameterTypes = method.getParameterTypes();
+            Class<?>[] parameterTypes = method.getParameterTypes();
             if(parameterTypes.length == argClasses.length) {
                 boolean found = true;
                 
@@ -278,7 +278,7 @@
     
     private Method findMethod() throws NoSuchMethodException {
         Class[] argClasses = getClasses();
-        Class targetClass = target.getClass();
+        Class<?> targetClass = target.getClass();
         
         Method result = null;
         
@@ -287,7 +287,7 @@
             Method method = methods[i];
             
             if(method.getName().equals(methodName)) {
-                Class[] parameterTypes = method.getParameterTypes();
+                Class<?>[] parameterTypes = method.getParameterTypes();
                 
                 if(parameterTypes.length == argClasses.length) {
                     boolean found = true;
@@ -326,18 +326,7 @@
         return result;
     }
     
-    private boolean areAllParamsDefined(Class[] argClasses) {
-        boolean result = true;
-        for(int i = 0; i < argClasses.length; ++i) {
-            if(argClasses[i] == null) {
-                result = false;
-                break;
-            }
-        }
-        return result;
-    }
-    
-    private static boolean isPrimitiveWrapper(Class wrapper, Class base) {
+    private static boolean isPrimitiveWrapper(Class<?> wrapper, Class<?> base)
{
         return
             (base == boolean.class) && (wrapper == Boolean.class) ||
             (base == byte.class) && (wrapper == Byte.class) ||
@@ -349,9 +338,9 @@
             (base == double.class) && (wrapper == Double.class);
     }
     
-    static String convertClassName(Class type) {
-        Class componentType = type.getComponentType();
-        Class resultType = (componentType == null) ? type : componentType;
+    static String convertClassName(Class<?> type) {
+        Class<?> componentType = type.getComponentType();
+        Class<?> resultType = (componentType == null) ? type : componentType;
         StringTokenizer st = new StringTokenizer(resultType.getName(), ".");
         String result = st.hasMoreElements() ? (String) st.nextElement() : null;
         if(result == null) return result;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java?rev=414913&r1=414912&r2=414913&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
Fri Jun 16 14:11:01 2006
@@ -28,6 +28,8 @@
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author Maxim V. Berkultsev
@@ -39,11 +41,11 @@
     private static final long serialVersionUID = -5090210921595982017l;
     
     private transient Object sourceBean;
-    private transient ArrayList allVetoableChangeListeners = new ArrayList();
-    private transient HashMap selectedVetoableChangeListeners = new HashMap();
+    private transient List<VetoableChangeListener> allVetoableChangeListeners = new
ArrayList<VetoableChangeListener>();
+    private transient Map<String, List<VetoableChangeListener>> selectedVetoableChangeListeners
= new HashMap<String, List<VetoableChangeListener>>();
     
     // fields for serialization compatibility
-    private Hashtable children;
+    private Hashtable<String, List<VetoableChangeListener>> children;
     private Object source;
     private int vetoableChangeSupportSerializedDataVersion = 1; 
 
@@ -73,8 +75,7 @@
     public synchronized void removeVetoableChangeListener(
             String propertyName, VetoableChangeListener listener) {
         if ( (propertyName != null) && (listener != null) ) {
-            ArrayList listeners =
-                (ArrayList) selectedVetoableChangeListeners.get(propertyName);
+            List<VetoableChangeListener> listeners = selectedVetoableChangeListeners.get(propertyName);
             
             if(listeners != null) {
                 listeners.remove(listener);    
@@ -88,11 +89,11 @@
     public synchronized void addVetoableChangeListener(String propertyName,
             VetoableChangeListener listener) {
         if (propertyName != null && listener != null) {
-            ArrayList listeners = (ArrayList) selectedVetoableChangeListeners
+            List<VetoableChangeListener> listeners = selectedVetoableChangeListeners
                     .get(propertyName);
 
             if (listeners == null) {
-                listeners = new ArrayList();
+                listeners = new ArrayList<VetoableChangeListener>();
                 selectedVetoableChangeListeners.put(propertyName, listeners);
             }
 
@@ -105,11 +106,10 @@
      */
     public synchronized VetoableChangeListener[] getVetoableChangeListeners(
             String propertyName) {
-        ArrayList listeners = null;
+        List<VetoableChangeListener> listeners = null;
         
         if (propertyName != null) {
-            listeners = (ArrayList) selectedVetoableChangeListeners.get(
-                    propertyName);
+            listeners = selectedVetoableChangeListeners.get(propertyName);
         }
         
         return (listeners == null) ? new VetoableChangeListener[] {} :
@@ -147,8 +147,7 @@
     public synchronized boolean hasListeners(String propertyName) {
         boolean result = allVetoableChangeListeners.size() > 0;
         if (!result && propertyName != null) {
-            ArrayList listeners =
-                (ArrayList) selectedVetoableChangeListeners.get(propertyName);
+            List<VetoableChangeListener> listeners = selectedVetoableChangeListeners.get(propertyName);
             if (listeners != null) {
                 result = listeners.size() > 0;
             }
@@ -162,10 +161,9 @@
     public synchronized void removeVetoableChangeListener(
             VetoableChangeListener listener) {
         if (listener != null) {
-            Iterator iterator = allVetoableChangeListeners.iterator();
+            Iterator<VetoableChangeListener> iterator = allVetoableChangeListeners.iterator();
             while (iterator.hasNext()) {
-                VetoableChangeListener pcl =
-                        (VetoableChangeListener) iterator.next();
+                VetoableChangeListener pcl = iterator.next();
                 if (pcl == listener) {
                     iterator.remove();
                     break;
@@ -188,21 +186,16 @@
      * @com.intel.drl.spec_ref
      */
     public synchronized VetoableChangeListener[] getVetoableChangeListeners() {
-        ArrayList result = new ArrayList(allVetoableChangeListeners);
+        List<VetoableChangeListener> result = new ArrayList<VetoableChangeListener>(allVetoableChangeListeners);
         
-        Iterator keysIterator =
+        Iterator<String> keysIterator =
                 selectedVetoableChangeListeners.keySet().iterator();
         while (keysIterator.hasNext()) {
-            String propertyName = (String) keysIterator.next();
+            String propertyName = keysIterator.next();
             
-            ArrayList selectedListeners =
-                (ArrayList) selectedVetoableChangeListeners.get(propertyName);
+            List<VetoableChangeListener> selectedListeners = selectedVetoableChangeListeners.get(propertyName);
             if(selectedListeners != null) {
-
-                Iterator i = selectedListeners.iterator();
-                while(i.hasNext()) {
-                    VetoableChangeListener listener =
-                            (VetoableChangeListener) i.next();
+                for (VetoableChangeListener listener : selectedListeners) {
                     result.add(new VetoableChangeListenerProxy(
                             propertyName, listener));
                 }
@@ -218,29 +211,19 @@
      * @com.intel.drl.spec_ref
      */
     private void writeObject(ObjectOutputStream oos) throws IOException {
-        ArrayList allSerializedVetoableChangeListeners = new ArrayList();
-        Iterator i = allVetoableChangeListeners.iterator();
-        while(i.hasNext()) {
-            VetoableChangeListener vcl = (VetoableChangeListener) i.next();
+        List<VetoableChangeListener> allSerializedVetoableChangeListeners = new ArrayList<VetoableChangeListener>();
+        for (VetoableChangeListener vcl : allVetoableChangeListeners) {
             if(vcl instanceof Serializable) {
                 allSerializedVetoableChangeListeners.add(vcl);
             }
         }
         
-        HashMap selectedSerializedVetoableChangeListeners = new HashMap();
-        Iterator keyIterator =
-                selectedVetoableChangeListeners.keySet().iterator();
-        while(keyIterator.hasNext()) {
-            String propertyName = (String) keyIterator.next();
-            ArrayList keyValues =
-                (ArrayList) selectedVetoableChangeListeners.get(propertyName);
+        Map<String, List<VetoableChangeListener>> selectedSerializedVetoableChangeListeners
= new HashMap<String, List<VetoableChangeListener>>();
+        for (String propertyName : selectedVetoableChangeListeners.keySet()) {
+            List<VetoableChangeListener> keyValues = selectedVetoableChangeListeners.get(propertyName);
             if(keyValues != null) {
-                ArrayList serializedVetoableChangeListeners = new ArrayList();
-                
-                Iterator j = keyValues.iterator();
-                while(j.hasNext()) {
-                    PropertyChangeListener pcl =
-                            (PropertyChangeListener) j.next();
+                List<VetoableChangeListener> serializedVetoableChangeListeners = new
ArrayList<VetoableChangeListener>();
+                for (VetoableChangeListener pcl : keyValues) {
                     if(pcl instanceof Serializable) {
                         serializedVetoableChangeListeners.add(pcl);
                     }
@@ -254,7 +237,7 @@
             }
         }
         
-        children = new Hashtable(selectedSerializedVetoableChangeListeners);
+        children = new Hashtable<String, List<VetoableChangeListener>>(selectedSerializedVetoableChangeListeners);
         children.put("", allSerializedVetoableChangeListeners);
         oos.writeObject(children);
         
@@ -273,13 +256,12 @@
     private void readObject(ObjectInputStream ois) throws IOException,
             ClassNotFoundException {
 
-        children = (Hashtable) ois.readObject();
+        children = (Hashtable<String, List<VetoableChangeListener>>)ois.readObject();
 
-        selectedVetoableChangeListeners = new HashMap(children);
-        allVetoableChangeListeners = (ArrayList) selectedVetoableChangeListeners
-                .remove("");
+        selectedVetoableChangeListeners = new HashMap<String, List<VetoableChangeListener>>(children);
+        allVetoableChangeListeners = selectedVetoableChangeListeners.remove("");
         if (allVetoableChangeListeners == null) {
-            allVetoableChangeListeners = new ArrayList();
+            allVetoableChangeListeners = new ArrayList<VetoableChangeListener>();
         }
 
         sourceBean = ois.readObject();
@@ -332,12 +314,12 @@
         }
     }
 
-    private void notifyListeners(Iterator iterator, PropertyChangeEvent event)
+    private void notifyListeners(Iterator<VetoableChangeListener> iterator, PropertyChangeEvent
event)
             throws PropertyVetoException {
 
         VetoableChangeListener listener = null;
         while (iterator.hasNext()) {
-            listener = (VetoableChangeListener) iterator.next();
+            listener = iterator.next();
             listener.vetoableChange(event);
         }
 
@@ -348,8 +330,7 @@
 
         notifyListeners(allVetoableChangeListeners.iterator(), event);
         String propertyName = event.getPropertyName();
-        ArrayList listeners = (ArrayList) selectedVetoableChangeListeners
-                .get(propertyName);
+        List<VetoableChangeListener> listeners = selectedVetoableChangeListeners.get(propertyName);
         if (listeners == null) {
             return;
         }
@@ -357,7 +338,7 @@
     }
     
     private static VetoableChangeListener[] getAsVetoableChangeListenerArray(
-            ArrayList listeners) {
+            List<VetoableChangeListener> listeners) {
         Object[] objects = listeners.toArray();
         VetoableChangeListener[] arrayResult =
                 new VetoableChangeListener[objects.length];



Mime
View raw message