Code cleanup (e.g., remove IteratorToEnumeration class).


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1022720 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java b/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
index c80c3b6..34ada2c 100644
--- a/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
@@ -56,7 +56,6 @@
 import org.apache.felix.framework.resolver.WireModuleImpl;
 import org.apache.felix.framework.util.CompoundEnumeration;
 import org.apache.felix.framework.util.FelixConstants;
-import org.apache.felix.framework.util.IteratorToEnumeration;
 import org.apache.felix.framework.util.SecureAction;
 import org.apache.felix.framework.util.SecurityManagerEx;
 import org.apache.felix.framework.util.Util;
@@ -1036,7 +1035,7 @@
             }
         }
 
-        return new IteratorToEnumeration(l.iterator());
+        return Collections.enumeration(l);
     }
 
     // TODO: API: Investigate how to handle this better, perhaps we need
@@ -1730,7 +1729,7 @@
                     }
                     localURLs.add(url);
                 }
-                urls = new IteratorToEnumeration(localURLs.iterator());
+                urls = Collections.enumeration(localURLs);
             }
             return urls;
         }
@@ -2284,7 +2283,7 @@
                 wire = null;
             }
 
-            String exporter = (exporters.size() == 0)
+            String exporter = (exporters.isEmpty())
                 ? null : exporters.iterator().next().getModule().getBundle().toString();
 
             StringBuffer sb = new StringBuffer("*** Class '");
diff --git a/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java b/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
index f26f887..e417cdf 100644
--- a/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
@@ -415,7 +415,7 @@
 
         public List<Directive> getDirectives()
         {
-            return Util.m_emptyList;
+            return Collections.EMPTY_LIST;
         }
 
         public Attribute getAttribute(String name)
@@ -426,12 +426,12 @@
 
         public List<Attribute> getAttributes()
         {
-            return Util.m_emptyList;
+            return Collections.EMPTY_LIST;
         }
 
         public List<String> getUses()
         {
-            return Util.m_emptyList;
+            return Collections.EMPTY_LIST;
         }
 
         public Object getProperty(String s)
diff --git a/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java b/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
index 7c8f505..404daa3 100644
--- a/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
@@ -43,9 +43,6 @@
 {
     private final Logger m_logger;
 
-    // Reusable empty array.
-    private static final List<Wire> m_emptyWires = Util.m_emptyList;
-
     // Holds candidate permutations based on permutating "uses" chains.
     // These permutations are given higher priority.
     private final List<Map<Requirement, Set<Capability>>> m_usesPermutations =
@@ -1263,7 +1260,7 @@
             return sources;
         }
 
-        return Util.m_emptyList;
+        return Collections.EMPTY_LIST;
     }
 
     private static List<Capability> getPackageSourcesInternal(
@@ -1328,7 +1325,7 @@
     {
         if (!module.isResolved() && !wireMap.containsKey(module))
         {
-            wireMap.put(module, m_emptyWires);
+            wireMap.put(module, (List<Wire>) Collections.EMPTY_LIST);
 
             List<Wire> packageWires = new ArrayList<Wire>();
             List<Wire> moduleWires = new ArrayList<Wire>();
@@ -1379,7 +1376,7 @@
         Module module, String pkgName, Map<Module, Packages> modulePkgMap,
         Map<Module, List<Wire>> wireMap, Map<Requirement, Set<Capability>> candidateMap)
     {
-        wireMap.put(module, m_emptyWires);
+        wireMap.put(module, (List<Wire>) Collections.EMPTY_LIST);
 
         List<Wire> packageWires = new ArrayList<Wire>();
 
diff --git a/framework/src/main/java/org/apache/felix/framework/util/IteratorToEnumeration.java b/framework/src/main/java/org/apache/felix/framework/util/IteratorToEnumeration.java
deleted file mode 100644
index 91b6bbd..0000000
--- a/framework/src/main/java/org/apache/felix/framework/util/IteratorToEnumeration.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.framework.util;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-
-public class IteratorToEnumeration implements Enumeration
-{
-    private final Iterator m_iter;
-
-    public IteratorToEnumeration(Iterator iter)
-    {
-        m_iter = iter;
-    }
-
-    public boolean hasMoreElements()
-    {
-        if (m_iter == null)
-            return false;
-        return m_iter.hasNext();
-    }
-
-    public Object nextElement()
-    {
-        if (m_iter == null)
-            return null;
-        return m_iter.next();
-    }
-}
diff --git a/framework/src/main/java/org/apache/felix/framework/util/MapToDictionary.java b/framework/src/main/java/org/apache/felix/framework/util/MapToDictionary.java
index 9bf5705..7b955c0 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/MapToDictionary.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/MapToDictionary.java
@@ -43,7 +43,7 @@
 
     public Enumeration elements()
     {
-        return new IteratorToEnumeration(m_map.values().iterator());
+        return Collections.enumeration(m_map.values());
     }
 
     public Object get(Object key)
@@ -58,7 +58,7 @@
 
     public Enumeration keys()
     {
-        return new IteratorToEnumeration(m_map.keySet().iterator());
+        return Collections.enumeration(m_map.keySet());
     }
 
     public Object put(Object key, Object value)
diff --git a/framework/src/main/java/org/apache/felix/framework/util/Util.java b/framework/src/main/java/org/apache/felix/framework/util/Util.java
index 9d59424..66437af 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/Util.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/Util.java
@@ -23,7 +23,6 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -41,8 +40,6 @@
 
 public class Util
 {
-    public static final List m_emptyList = Collections.unmodifiableList(new ArrayList());
-
     /**
      * The default name used for the default configuration properties file.
     **/