src/share/classes/java/beans/beancontext/BeanContextSupport.java

Print this page

        

@@ -252,11 +252,11 @@
     /**
      * Gets all JavaBean or <tt>BeanContext</tt> instances
      * currently nested in this <tt>BeanContext</tt>.
      * @return an <tt>Iterator</tt> of the nested children
      */
-    public Iterator iterator() {
+    public Iterator<Object> iterator() {
         synchronized(children) {
             return new BCSIterator(children.keySet().iterator());
         }
     }
 

@@ -290,18 +290,18 @@
     /**
      * protected final subclass that encapsulates an iterator but implements
      * a noop remove() method.
      */
 
-    protected static final class BCSIterator implements Iterator {
-        BCSIterator(Iterator i) { super(); src = i; }
+    protected static final class BCSIterator implements Iterator<Object> {
+        BCSIterator(Iterator<?> i) { super(); src = i; }
 
         public boolean hasNext() { return src.hasNext(); }
         public Object  next()    { return src.next();    }
         public void    remove()  { /* do nothing */      }
 
-        private Iterator src;
+        private Iterator<?> src;
     }
 
     /************************************************************************/
 
     /*

@@ -502,11 +502,11 @@
 
             if (!validatePendingRemove(targetChild)) {
                 throw new IllegalStateException();
             }
 
-            BCSChild bcsc  = (BCSChild)children.get(targetChild);
+            BCSChild bcsc  = children.get(targetChild);
             BCSChild pbcsc = null;
             Object   peer  = null;
 
             // we are required to notify the child that it is no longer nested here if
             // it implements java.beans.beancontext.BeanContextChild

@@ -531,11 +531,11 @@
 
                 synchronized (children) {
                     children.remove(targetChild);
 
                     if (bcsc.isProxyPeer()) {
-                        pbcsc = (BCSChild)children.get(peer = bcsc.getProxyPeer());
+                        pbcsc = children.get(peer = bcsc.getProxyPeer());
                         children.remove(peer);
                     }
                 }
 
                 if (getChildSerializable(targetChild) != null) serializable--;

@@ -564,13 +564,14 @@
      *
      * @return <tt>true</tt> if all objects
      * in the collection are children of
      * this <tt>BeanContext</tt>, false if not.
      */
+    @SuppressWarnings("rawtypes")
     public boolean containsAll(Collection c) {
         synchronized(children) {
-            Iterator i = c.iterator();
+            Iterator<?> i = c.iterator();
             while (i.hasNext())
                 if(!contains(i.next()))
                     return false;
 
             return true;

@@ -581,10 +582,11 @@
      * add Collection to set of Children (Unsupported)
      * implementations must synchronized on the hierarchy lock and "children" protected field
      * @throws UnsupportedOperationException thrown unconditionally by this implementation
      * @return this implementation unconditionally throws {@code UnsupportedOperationException}
      */
+    @SuppressWarnings("rawtypes")
     public boolean addAll(Collection c) {
         throw new UnsupportedOperationException();
     }
 
     /**

@@ -592,10 +594,11 @@
      * implementations must synchronized on the hierarchy lock and "children" protected field
      * @throws UnsupportedOperationException thrown unconditionally by this implementation
      * @return this implementation unconditionally throws {@code UnsupportedOperationException}
 
      */
+    @SuppressWarnings("rawtypes")
     public boolean removeAll(Collection c) {
         throw new UnsupportedOperationException();
     }
 
 

@@ -603,10 +606,11 @@
      * retain only specified children (Unsupported)
      * implementations must synchronized on the hierarchy lock and "children" protected field
      * @throws UnsupportedOperationException thrown unconditionally by this implementation
      * @return this implementation unconditionally throws {@code UnsupportedOperationException}
      */
+    @SuppressWarnings("rawtypes")
     public boolean retainAll(Collection c) {
         throw new UnsupportedOperationException();
     }
 
     /**

@@ -761,11 +765,11 @@
             if (bc instanceof Container || bc instanceof Component)
                 return true;
         }
 
         synchronized(children) {
-            for (Iterator i = children.keySet().iterator(); i.hasNext();) {
+            for (Iterator<Object> i = children.keySet().iterator(); i.hasNext();) {
                 Object c = i.next();
 
                 try {
                         return ((Visibility)c).needsGui();
                     } catch (ClassCastException cce) {

@@ -788,11 +792,11 @@
         if (okToUseGui) {
             okToUseGui = false;
 
             // lets also tell the Children that can that they may not use their GUI's
             synchronized(children) {
-                for (Iterator i = children.keySet().iterator(); i.hasNext();) {
+                for (Iterator<Object> i = children.keySet().iterator(); i.hasNext();) {
                     Visibility v = getChildVisibility(i.next());
 
                     if (v != null) v.dontUseGui();
                }
             }

@@ -807,11 +811,11 @@
         if (!okToUseGui) {
             okToUseGui = true;
 
             // lets also tell the Children that can that they may use their GUI's
             synchronized(children) {
-                for (Iterator i = children.keySet().iterator(); i.hasNext();) {
+                for (Iterator<Object> i = children.keySet().iterator(); i.hasNext();) {
                     Visibility v = getChildVisibility(i.next());
 
                     if (v != null) v.okToUseGui();
                 }
             }

@@ -839,11 +843,11 @@
     /**
      * Returns an iterator of all children
      * of this <tt>BeanContext</tt>.
      * @return an iterator for all the current BCSChild values
      */
-    protected Iterator bcsChildren() { synchronized(children) { return children.values().iterator();  } }
+    protected Iterator<BCSChild> bcsChildren() { synchronized(children) { return children.values().iterator();  } }
 
     /**
      * called by writeObject after defaultWriteObject() but prior to
      * serialization of currently serializable children.
      *

@@ -894,11 +898,11 @@
      * @param oos the <tt>ObjectOutputStream</tt>
      * to use during serialization
      * @param coll the <tt>Collection</tt> to serialize
      * @throws IOException if serialization failed
      */
-    protected final void serialize(ObjectOutputStream oos, Collection coll) throws IOException {
+    protected final void serialize(ObjectOutputStream oos, Collection<?> coll) throws IOException {
         int      count   = 0;
         Object[] objects = coll.toArray();
 
         for (int i = 0; i < objects.length; i++) {
             if (objects[i] instanceof Serializable)

@@ -924,10 +928,11 @@
      * @param ois the ObjectInputStream to use
      * @param coll the Collection
      * @throws IOException if deserialization failed
      * @throws ClassNotFoundException if needed classes are not found
      */
+    @SuppressWarnings({"rawtypes", "unchecked"})
     protected final void deserialize(ObjectInputStream ois, Collection coll) throws IOException, ClassNotFoundException {
         int count = 0;
 
         count = ois.readInt();
 

@@ -951,14 +956,14 @@
         serializing = true;
 
         int count = 0;
 
         synchronized(children) {
-            Iterator i = children.entrySet().iterator();
+            Iterator<Map.Entry<Object, BCSChild>> i = children.entrySet().iterator();
 
             while (i.hasNext() && count < serializable) {
-                Map.Entry entry = (Map.Entry)i.next();
+                Map.Entry<Object, BCSChild> entry = i.next();
 
                 if (entry.getKey() instanceof Serializable) {
                     try {
                         oos.writeObject(entry.getKey());   // child
                         oos.writeObject(entry.getValue()); // BCSChild

@@ -1080,11 +1085,11 @@
             bcsPreDeserializationHook(ois);
 
             if (serializable > 0 && this.equals(getBeanContextPeer()))
                 readChildren(ois);
 
-            deserialize(ois, bcmListeners = new ArrayList(1));
+            deserialize(ois, bcmListeners = new ArrayList<>(1));
         }
     }
 
     /**
      * subclasses may envelope to monitor veto child property changes.

@@ -1099,11 +1104,11 @@
                 containsKey(source)                    &&
                 !getBeanContextPeer().equals(pce.getNewValue())
             ) {
                 if (!validatePendingRemove(source)) {
                     throw new PropertyVetoException("current BeanContext vetoes setBeanContext()", pce);
-                } else ((BCSChild)children.get(source)).setRemovePending(true);
+                } else children.get(source).setRemovePending(true);
             }
         }
     }
 
     /**

@@ -1115,17 +1120,17 @@
         Object source       = pce.getSource();
 
         synchronized(children) {
             if ("beanContext".equals(propertyName) &&
                 containsKey(source)                    &&
-                ((BCSChild)children.get(source)).isRemovePending()) {
+                children.get(source).isRemovePending()) {
                 BeanContext bc = getBeanContextPeer();
 
                 if (bc.equals(pce.getOldValue()) && !bc.equals(pce.getNewValue())) {
                     remove(source, false);
                 } else {
-                    ((BCSChild)children.get(source)).setRemovePending(false);
+                    children.get(source).setRemovePending(false);
                 }
             }
         }
     }
 

@@ -1310,12 +1315,12 @@
      * subclasses may envelope this method to add their own initialization
      * behavior
      */
 
     protected synchronized void initialize() {
-        children     = new HashMap(serializable + 1);
-        bcmListeners = new ArrayList(1);
+        children     = new HashMap<>(serializable + 1);
+        bcmListeners = new ArrayList<>(1);
 
         childPCL = new PropertyChangeListener() {
 
             /*
              * this adaptor is used by the BeanContextSupport class to forward

@@ -1357,11 +1362,11 @@
      * or their names are equal.
      * @param first the first object
      * @param second the second object
      * @return true if equal, false if not
      */
-    protected static final boolean classEquals(Class first, Class second) {
+    protected static final boolean classEquals(Class<?> first, Class<?> second) {
         return first.equals(second) || first.getName().equals(second.getName());
     }
 
 
     /*

@@ -1371,19 +1376,19 @@
 
     /**
      * all accesses to the <code> protected HashMap children </code> field
      * shall be synchronized on that object.
      */
-    protected transient HashMap         children;
+    protected transient HashMap<Object, BCSChild>         children;
 
     private             int             serializable  = 0; // children serializable
 
     /**
      * all accesses to the <code> protected ArrayList bcmListeners </code> field
      * shall be synchronized on that object.
      */
-    protected transient ArrayList       bcmListeners;
+    protected transient ArrayList<BeanContextMembershipListener> bcmListeners;
 
     //
 
     /**
      * The current locale of this BeanContext.