felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r421626 - /incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java
Date Thu, 13 Jul 2006 13:43:25 GMT
Author: rickhall
Date: Thu Jul 13 06:43:24 2006
New Revision: 421626

URL: http://svn.apache.org/viewvc?rev=421626&view=rev
Log:
Modified LDAP attribute comparison to use equals() when the object does
not implement Comparable.

Modified:
    incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java?rev=421626&r1=421625&r2=421626&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java
Thu Jul 13 06:43:24 2006
@@ -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
+                {
+                    Object rhsObject = lhsClass
+                        .getConstructor(new Class[] { String.class })
+                            .newInstance(new Object[] { rhs });
+                        return lhs.equals(rhsObject);
+                }
+                catch (Exception ex)
                 {
-                    case EQUAL :
-                        opName = "=";
-                    case GREATER_EQUAL :
-                        opName = ">=";
-                    case LESS_EQUAL :
-                        opName = "<=";
-                    case APPROX:
-                        opName = "~=";
-                    default:
-                        opName = "UNKNOWN OP";
+                    // 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
             {



Mime
View raw message