CapabilitySet should ignore case when indexing attributes, since this
is necessary for service properties. (FELIX-2040)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@938241 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java b/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
index 3802275..bb84b4b 100644
--- a/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
+++ b/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
@@ -29,11 +29,13 @@
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.TreeMap;
+import org.apache.felix.framework.util.StringComparator;
 
 public class CapabilitySet
 {
     private final Map<String, Map<Object, Set<Capability>>> m_indices =
-        new HashMap<String, Map<Object, Set<Capability>>>();
+        new TreeMap<String, Map<Object, Set<Capability>>>(new StringComparator(false));
     private final Set<Capability> m_capList = new HashSet<Capability>();
 
     public CapabilitySet(List<String> indexProps)
diff --git a/framework/src/main/java/org/apache/felix/framework/util/StringComparator.java b/framework/src/main/java/org/apache/felix/framework/util/StringComparator.java
new file mode 100644
index 0000000..03af305
--- /dev/null
+++ b/framework/src/main/java/org/apache/felix/framework/util/StringComparator.java
@@ -0,0 +1,48 @@
+/*
+ * 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.Comparator;
+
+public class StringComparator implements Comparator
+{
+    private final boolean m_isCaseSensitive;
+
+    public StringComparator(boolean b)
+    {
+        m_isCaseSensitive = b;
+    }
+
+    public int compare(Object o1, Object o2)
+    {
+        if (m_isCaseSensitive)
+        {
+            return o1.toString().compareTo(o2.toString());
+        }
+        else
+        {
+            return o1.toString().compareToIgnoreCase(o2.toString());
+        }
+    }
+
+    public boolean isCaseSensitive()
+    {
+        return m_isCaseSensitive;
+    }
+}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/framework/util/StringMap.java b/framework/src/main/java/org/apache/felix/framework/util/StringMap.java
index 3486463..7ad7f78 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/StringMap.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/StringMap.java
@@ -131,31 +131,4 @@
     {
         return m_map.toString();
     }
-
-    private static class StringComparator implements Comparator
-    {
-        private final boolean m_isCaseSensitive;
-
-        public StringComparator(boolean b)
-        {
-            m_isCaseSensitive = b;
-        }
-
-        public int compare(Object o1, Object o2)
-        {
-            if (m_isCaseSensitive)
-            {
-                return o1.toString().compareTo(o2.toString());
-            }
-            else
-            {
-                return o1.toString().compareToIgnoreCase(o2.toString());
-            }
-        }
-
-        public boolean isCaseSensitive()
-        {
-            return m_isCaseSensitive;
-        }
-    }
 }
\ No newline at end of file