directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r949022 - in /directory/shared/trunk: i18n/src/main/java/org/apache/directory/shared/i18n/ i18n/src/main/resources/org/apache/directory/shared/i18n/ ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/ ldap...
Date Thu, 27 May 2010 22:15:52 GMT
Author: elecharny
Date: Thu May 27 22:15:52 2010
New Revision: 949022

URL: http://svn.apache.org/viewvc?rev=949022&view=rev
Log:
o Renamed the IntegerOrderingComparator class
o Updated the booleanMatch, integerMatch and integerOrderingMatch MR
o Fixed some of the comparators

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerComparator.java
      - copied, changed from r948637, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerOrderingComparator.java
Removed:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerOrderingComparator.java
Modified:
    directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
    directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
    directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/MatchingRuleTest.java
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.13.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.14.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.15.ldif
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/LongComparator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NumericStringComparator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/StringComparator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/UniqueMemberComparator.java

Modified: directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java?rev=949022&r1=949021&r2=949022&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java (original)
+++ directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java Thu
May 27 22:15:52 2010
@@ -357,8 +357,8 @@ public enum I18n
     ERR_04216( "ERR_04216" ),
     ERR_04217( "ERR_04217" ),
     ERR_04218( "ERR_04218" ),
-    ERR_04219( "ERR_04219" ),
-    ERR_04220( "ERR_04220" ),
+    ERR_04219_ARGUMENT1_NULL( "ERR_04219_ARGUMENT1_NULL" ),
+    ERR_04220_ARGUMENT2_NULL( "ERR_04220_ARGUMENT2_NULL" ),
     ERR_04221( "ERR_04221" ),
     ERR_04222( "ERR_04222" ),
     ERR_04223( "ERR_04223" ),

Modified: directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties?rev=949022&r1=949021&r2=949022&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
(original)
+++ directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
Thu May 27 22:15:52 2010
@@ -341,8 +341,8 @@ ERR_04215=Unescaped special characters a
 ERR_04216=This class is not aware of schema information and cannot normalize
 ERR_04217=None of the arguments are Comparable objects\:\n\targ1 \= {0}\n\targ2 \= {1}
 ERR_04218=I do not know how to handle dn comparisons with objects of class: {0}
-ERR_04219=Argument 'obj1' is null
-ERR_04220=Argument 'obj2' is null
+ERR_04219_ARGUMENT1_NULL=Argument 'obj1' is null
+ERR_04220_ARGUMENT2_NULL=Argument 'obj2' is null
 ERR_04221=Matching rule not found: {0}
 ERR_04222=The value stored in a non Human Readable attribute as a String should be convertible
to a byte[]
 ERR_04223=The value stored in an Human Readable attribute as a byte[] should be convertible
to a String

Modified: directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/MatchingRuleTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/MatchingRuleTest.java?rev=949022&r1=949021&r2=949022&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/MatchingRuleTest.java
(original)
+++ directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/MatchingRuleTest.java
Thu May 27 22:15:52 2010
@@ -33,7 +33,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schema.comparators.GeneralizedTimeComparator;
-import org.apache.directory.shared.ldap.schema.comparators.IntegerOrderingComparator;
+import org.apache.directory.shared.ldap.schema.comparators.IntegerComparator;
 import org.apache.directory.shared.ldap.schema.comparators.NumericStringComparator;
 import org.apache.directory.shared.ldap.schema.comparators.TelephoneNumberComparator;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
@@ -142,16 +142,16 @@ public class MatchingRuleTest
         MatchingRule mr1 = schemaManager.lookupMatchingRuleRegistry( "integerMatch" );
         assertEquals( NumericNormalizer.class.getName(), mr1.getNormalizer().getClass().getName()
);
         assertEquals( "1234567890", mr1.getNormalizer().normalize( " 1 234 567 890 " ) );
-        //assertEquals( IntegerOrderingComparator.class.getName(), mr1.getLdapComparator().getClass().getName()
);
+        //assertEquals( IntegerComparator.class.getName(), mr1.getLdapComparator().getClass().getName()
);
         //assertEquals( 0, mr1.getLdapComparator().compare( " 1 234 567 890 ", "1234567890"
) );
 
         MatchingRule mr2 = schemaManager.lookupMatchingRuleRegistry( "integerOrderingMatch"
);
         assertEquals( NumericNormalizer.class.getName(), mr2.getNormalizer().getClass().getName()
);
         assertEquals( "1234567890", mr2.getNormalizer().normalize( " 1 234 567 890 " ) );
-        assertEquals( IntegerOrderingComparator.class.getName(), mr2.getLdapComparator().getClass().getName()
);
-        assertEquals( 0, mr2.getLdapComparator().compare( " 1 234 567 890 ", "1234567890"
) );
-        assertTrue( mr2.getLdapComparator().compare( " 1 2 3  ", " 2 3 4" ) < 0 );
-        assertTrue( mr2.getLdapComparator().compare( " 1 2 3 4 ", " 2 3 4" ) > 0 );
+        assertEquals( IntegerComparator.class.getName(), mr2.getLdapComparator().getClass().getName()
);
+        assertEquals( 0, mr2.getLdapComparator().compare( 1234567890L, 1234567890L ) );
+        assertTrue( mr2.getLdapComparator().compare( 123L, 234L ) < 0 );
+        assertTrue( mr2.getLdapComparator().compare( 1234L, 234L ) > 0 );
 
         // test a real attribute type: uidNumber
         AttributeType at = schemaManager.lookupAttributeTypeRegistry( "uidNumber" );

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.13.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dcomparators/m-oid%3D2.5.13.13.ldif?rev=949022&r1=949021&r2=949022&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.13.ldif
(original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.13.ldif
Thu May 27 22:15:52 2010
@@ -3,8 +3,7 @@ dn: m-oid=2.5.13.13,ou=comparators,cn=sy
 createtimestamp: 20090818022728Z
 m-oid: 2.5.13.13
 entrycsn: 20090818052728.118000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.comparators.ComparableComparator
- 
+m-fqcn: org.apache.directory.shared.ldap.schema.comparators.BooleanComparator
 objectclass: metaComparator
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.14.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dcomparators/m-oid%3D2.5.13.14.ldif?rev=949022&r1=949021&r2=949022&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.14.ldif
(original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.14.ldif
Thu May 27 22:15:52 2010
@@ -3,8 +3,7 @@ dn: m-oid=2.5.13.14,ou=comparators,cn=sy
 createtimestamp: 20090818022728Z
 m-oid: 2.5.13.14
 entrycsn: 20090818052728.237000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.comparators.ComparableComparator
- 
+m-fqcn: org.apache.directory.shared.ldap.schema.comparators.IntegerComparator
 objectclass: metaComparator
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.15.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dcomparators/m-oid%3D2.5.13.15.ldif?rev=949022&r1=949021&r2=949022&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.15.ldif
(original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.15.ldif
Thu May 27 22:15:52 2010
@@ -3,8 +3,7 @@ dn: m-oid=2.5.13.15,ou=comparators,cn=sy
 createtimestamp: 20090818022728Z
 m-oid: 2.5.13.15
 entrycsn: 20090818052728.022000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.comparators.IntegerOrderingCompa
- rator
+m-fqcn: org.apache.directory.shared.ldap.schema.comparators.IntegerComparator
 objectclass: metaComparator
 objectclass: metaTop
 objectclass: top

Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerComparator.java
(from r948637, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerOrderingComparator.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerComparator.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerComparator.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerOrderingComparator.java&r1=948637&r2=949022&rev=949022&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerOrderingComparator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerComparator.java
Thu May 27 22:15:52 2010
@@ -36,20 +36,20 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 437007 $
  */
-public class IntegerOrderingComparator extends LdapComparator<String>
+public class IntegerComparator extends LdapComparator<Object>
 {
     /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( IntegerOrderingComparator.class
);
+    private static final Logger LOG = LoggerFactory.getLogger( IntegerComparator.class );
 
     /** The serialVersionUID */
     private static final long serialVersionUID = 1L;
 
 
     /**
-     * The IntegerOrderingComparator constructor. Its OID is the IntegerOrderingMatch matching
+     * The IntegerComparator constructor. Its OID is the IntegerOrderingMatch matching
      * rule OID.
      */
-    public IntegerOrderingComparator( String oid )
+    public IntegerComparator( String oid )
     {
         super( oid );
     }
@@ -58,7 +58,76 @@ public class IntegerOrderingComparator e
     /**
      * Implementation of the Compare method
      */
-    public int compare( String backendValue, String assertValue )
+    public int compare( Object v1, Object v2 )
+    {
+        if ( v1 instanceof String )
+        {
+            return compare( ( String ) v1, ( String ) v2 );
+        }
+        else
+        {
+            return compare( ( Long ) v1, ( Long ) v2 );
+        }
+    }
+
+
+    /**
+     * Implementation of the Compare method
+     */
+    private int compare( Long backendValue, Long assertValue )
+    {
+        LOG.debug( "comparing IntegerOrdering objects '{}' with '{}'", backendValue, assertValue
);
+
+        // First, shortcut the process by comparing
+        // references. If they are equals, then o1 and o2
+        // reference the same object
+        if ( backendValue == assertValue )
+        {
+            return 0;
+        }
+
+        // Then, deal with one of o1 or o2 being null
+        // Both can't be null, because then they would 
+        // have been caught by the previous test
+        if ( ( backendValue == null ) || ( assertValue == null ) )
+        {
+            return ( backendValue == null ? -1 : 1 );
+        }
+
+        // Both objects must be stored as String for numeric.
+        // But we need to normalize the values first.
+        /*
+        try
+        {
+            backendValue = PrepareString.normalize( ( String ) backendValue, PrepareString.StringType.NUMERIC_STRING
);
+        }
+        catch ( IOException e )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, backendValue )
);
+        }
+        try
+        {
+            assertValue = PrepareString.normalize( ( String ) assertValue, PrepareString.StringType.NUMERIC_STRING
);
+        }
+        catch ( IOException e )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, assertValue ) );
+        }
+
+        BigInteger b1 = new BigInteger( ( String ) backendValue );
+        BigInteger b2 = new BigInteger( ( String ) assertValue );
+        */
+
+        //return b1.compareTo( b2 );
+
+        return backendValue.compareTo( assertValue );
+    }
+
+
+    /**
+     * Implementation of the Compare method
+     */
+    private int compare( String backendValue, String assertValue )
     {
         LOG.debug( "comparing IntegerOrdering objects '{}' with '{}'", backendValue, assertValue
);
 
@@ -97,8 +166,9 @@ public class IntegerOrderingComparator e
             throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, assertValue ) );
         }
 
-        BigInteger b1 = new BigInteger( backendValue );
-        BigInteger b2 = new BigInteger( assertValue );
+        BigInteger b1 = new BigInteger( ( String ) backendValue );
+        BigInteger b2 = new BigInteger( ( String ) assertValue );
+
         return b1.compareTo( b2 );
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/LongComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/LongComparator.java?rev=949022&r1=949021&r2=949022&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/LongComparator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/LongComparator.java
Thu May 27 22:15:52 2010
@@ -36,7 +36,8 @@ public class LongComparator extends Ldap
      * Version id for serialization.
      */
     static final long serialVersionUID = 1L;
-    
+
+
     /**
      * The LongComparator constructor. Its OID is the IntegerOrderingMatch matching
      * rule OID.
@@ -56,20 +57,21 @@ public class LongComparator extends Ldap
      */
     public int compare( Long obj1, Long obj2 )
     {
-        try
+        if ( obj1 == obj2 )
         {
-            return obj1.compareTo( obj2 );
+            return 0;
         }
-        catch ( NullPointerException npe )
+
+        if ( obj1 == null )
         {
-            if ( obj1 == null )
-            {
-                throw new IllegalArgumentException( I18n.err( I18n.ERR_04219 ) );
-            }
-            else
-            {
-                throw new IllegalArgumentException( I18n.err( I18n.ERR_04220 ));
-            }
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04219_ARGUMENT1_NULL )
);
         }
+
+        if ( obj2 == null )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04220_ARGUMENT2_NULL )
);
+        }
+
+        return obj1.compareTo( obj2 );
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NumericStringComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NumericStringComparator.java?rev=949022&r1=949021&r2=949022&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NumericStringComparator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NumericStringComparator.java
Thu May 27 22:15:52 2010
@@ -45,7 +45,7 @@ public class NumericStringComparator ext
 
 
     /**
-     * The IntegerOrderingComparator constructor. Its OID is the numericStringOrderingMatch
matching
+     * The IntegerComparator constructor. Its OID is the numericStringOrderingMatch matching
      * rule OID.
      */
     public NumericStringComparator( String oid )

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/StringComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/StringComparator.java?rev=949022&r1=949021&r2=949022&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/StringComparator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/StringComparator.java
Thu May 27 22:15:52 2010
@@ -39,6 +39,7 @@ public class StringComparator extends Ld
     /** The serialVersionUID */
     private static final long serialVersionUID = 1L;
 
+
     /**
      * The StringComparator constructor. Its OID is the StringMatch matching
      * rule OID.
@@ -48,13 +49,19 @@ public class StringComparator extends Ld
         super( oid );
     }
 
+
     /**
      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
      */
     public int compare( String s1, String s2 )
     {
         LOG.debug( "comparing String objects '{}' with '{}'", s1, s2 );
-        
+
+        if ( s1 == s2 )
+        {
+            return 0;
+        }
+
         // -------------------------------------------------------------------
         // Handle some basis cases
         // -------------------------------------------------------------------
@@ -62,12 +69,12 @@ public class StringComparator extends Ld
         {
             return ( s2 == null ) ? 0 : -1;
         }
-        
+
         if ( s2 == null )
         {
             return 1;
         }
-        
+
         return s1.compareTo( s2 );
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/UniqueMemberComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/UniqueMemberComparator.java?rev=949022&r1=949021&r2=949022&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/UniqueMemberComparator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/UniqueMemberComparator.java
Thu May 27 22:15:52 2010
@@ -46,7 +46,7 @@ public class UniqueMemberComparator exte
 
 
     /**
-     * The IntegerOrderingComparator constructor. Its OID is the IntegerOrderingMatch matching
+     * The IntegerComparator constructor. Its OID is the IntegerOrderingMatch matching
      * rule OID.
      */
     public UniqueMemberComparator( String oid )



Mime
View raw message