FELIX-2867 Fix iterator to find appropriate size. The map is <Integer, String> and the iterator is iterating over the keys, hence the return iterator values are Integer (and no Map.Entry as expected in the existing code). Also renamed variables to reflect there intended value.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1187680 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/LocalizedObjectClassDefinition.java b/metatype/src/main/java/org/apache/felix/metatype/internal/LocalizedObjectClassDefinition.java
index e4fda4f..6baafae 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/LocalizedObjectClassDefinition.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/LocalizedObjectClassDefinition.java
@@ -117,7 +117,7 @@
      * @throws IOException
      * @see org.osgi.service.metatype.ObjectClassDefinition#getIcon(int)
      */
-    public InputStream getIcon( int size ) throws IOException
+    public InputStream getIcon( int desiredSize ) throws IOException
     {
         // nothing if no icons are defined
         Map icons = ocd.getIcons();
@@ -127,22 +127,22 @@
         }
 
         // get exact size
-        String iconPath = ( String ) icons.get( new Integer( size ) );
+        String iconPath = ( String ) icons.get( new Integer( desiredSize ) );
+
         if ( iconPath == null )
         {
             // approximate size: largest icon smaller than requested
-            Integer selected = new Integer( Integer.MIN_VALUE );
+            Integer selectedSize = new Integer( Integer.MIN_VALUE );
             for ( Iterator ei = icons.keySet().iterator(); ei.hasNext(); )
             {
-                Map.Entry entry = ( Map.Entry ) ei.next();
-                Integer keySize = ( Integer ) entry.getKey();
-                if ( keySize.intValue() <= size && selected.compareTo( keySize ) < 0 )
+                Integer iconSize = ( Integer ) ei.next();
+                if ( iconSize.intValue() <= desiredSize && selectedSize.compareTo( iconSize ) < 0 )
                 {
-                    selected = keySize;
+                    selectedSize = iconSize;
                 }
             }
             // get the raw path, fail if no path can be found
-            iconPath = ( String ) icons.get( selected );
+            iconPath = ( String ) icons.get( selectedSize );
         }
 
         // fail if no icon could be found