directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1745846 - /directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
Date Sat, 28 May 2016 08:03:12 GMT
Author: elecharny
Date: Sat May 28 08:03:11 2016
New Revision: 1745846

URL: http://svn.apache.org/viewvc?rev=1745846&view=rev
Log:
o Added a default Comparator for when we don't have an Equality MathcingRule
o Added a test for a potential NPE

Modified:
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java?rev=1745846&r1=1745845&r2=1745846&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
(original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
Sat May 28 08:03:11 2016
@@ -35,6 +35,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.schema.MatchingRule;
 import org.apache.directory.api.ldap.model.schema.Normalizer;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.api.ldap.model.schema.comparators.StringComparator;
 import org.apache.directory.api.ldap.model.schema.normalizers.NoOpNormalizer;
 import org.apache.directory.api.util.Serialize;
 import org.apache.directory.api.util.Strings;
@@ -94,6 +95,9 @@ public class Value implements Cloneable,
     /** Two flags used to tell if the value is HR or not in serialization */
     private boolean isHR = true;
     
+    /** A default comparator if we don't have an EQUALITY MR */
+    private static StringComparator stringComparator = new StringComparator( null );
+    
     // -----------------------------------------------------------------------
     // Constructors
     // -----------------------------------------------------------------------
@@ -167,7 +171,7 @@ public class Value implements Cloneable,
 
         this.attributeType = attributeType;
         
-        if ( !attributeType.isRelaxed() )
+        if ( ( attributeType != null ) && !attributeType.isRelaxed() )
         {
             // Check the value
             SyntaxChecker syntaxChecker = attributeType.getSyntax().getSyntaxChecker();
@@ -1335,7 +1339,8 @@ public class Value implements Cloneable,
                     
                     if ( other.attributeType.getEquality() == null )
                     {
-                        return false;
+                        // No equality ? Default to comparing using a String comparator
+                        return stringComparator.compare( normValue, other.normValue ) ==
0;
                     }
                     
                     Normalizer normalizer = other.attributeType.getEquality().getNormalizer();



Mime
View raw message