Modified LDAP attribute comparison to use equals() when the object does
not implement Comparable.


git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@421626 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java
index 245de81..602c0d6 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java
@@ -1266,31 +1266,29 @@
             {
                 return compareBoolean(lhs, rhs, operator);
             }
-        
-            // If LHS is not a Boolean, then verify it is a comparable
-            // and perform comparison.
+
+            // If the LHS is not a comparable, then try to use simple
+            // equals() comparison. If that fails, return false.
             if (!(Comparable.class.isAssignableFrom(lhsClass)))
             {
-                String opName = null;
-                switch (operator)
+                try
                 {
-                    case EQUAL :
-                        opName = "=";
-                    case GREATER_EQUAL :
-                        opName = ">=";
-                    case LESS_EQUAL :
-                        opName = "<=";
-                    case APPROX:
-                        opName = "~=";
-                    default:
-                        opName = "UNKNOWN OP";
+                    Object rhsObject = lhsClass
+                        .getConstructor(new Class[] { String.class })
+                            .newInstance(new Object[] { rhs });
+                        return lhs.equals(rhsObject);
+                }
+                catch (Exception ex)
+                {
+                    // Always return false.
                 }
 
-                unsupportedType(opName, lhsClass);
+                return false;
             }
 
-            // We will try to create a comparable object from the
-            // RHS string.
+            // Here we know that the LHS is a comparable object, so
+            // try to create an object for the RHS by using a constructor
+            // that will take the RHS string as a parameter.
             Comparable rhsComparable = null;
             try
             {