directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r732033 - in /directory: apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/ shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparator/
Date Tue, 06 Jan 2009 18:14:49 GMT
Author: elecharny
Date: Tue Jan  6 10:14:48 2009
New Revision: 732033

URL: http://svn.apache.org/viewvc?rev=732033&view=rev
Log:
Create a new IntegerOrderingComparator, and injected it into the server MatchingRules

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparator/IntegerOrderingComparator.java
Modified:
    directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemComparatorProducer.java

Modified: directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemComparatorProducer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemComparatorProducer.java?rev=732033&r1=732032&r2=732033&view=diff
==============================================================================
--- directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemComparatorProducer.java
(original)
+++ directory/apacheds/trunk/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemComparatorProducer.java
Tue Jan  6 10:14:48 2009
@@ -36,6 +36,7 @@
 import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.NormalizingComparator;
 import org.apache.directory.shared.ldap.schema.ObjectIdentifierComparator;
+import org.apache.directory.shared.ldap.schema.comparator.IntegerOrderingComparator;
 
 
 /**
@@ -160,10 +161,10 @@
         cb.schemaObjectProduced( this, "2.5.13.14", comparator );
 
         /*
-         ( 2.5.13.14 NAME 'integerOrderingMatch'
+         ( 2.5.13.15 NAME 'integerOrderingMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
          */
-        comparator = new ComparableComparator();
+        comparator = new IntegerOrderingComparator();
         cb.schemaObjectProduced( this, "2.5.13.15", comparator );
 
         /*

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparator/IntegerOrderingComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparator/IntegerOrderingComparator.java?rev=732033&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparator/IntegerOrderingComparator.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparator/IntegerOrderingComparator.java
Tue Jan  6 10:14:48 2009
@@ -0,0 +1,72 @@
+/*
+ *  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.directory.shared.ldap.schema.comparator;
+
+
+import java.util.Comparator;
+
+/**
+ * A class for the IntegerOrderingComparator matchingRule (RFC 4517, par. 4.2.20)
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 437007 $
+ */
+public class IntegerOrderingComparator implements Comparator<Object>
+{
+    /**
+     * Implementation of the Compare method
+     */
+    public int compare( Object backendValue, Object 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 object must be stored as String for boolean
+        // values. If this is not the case, we have a pb...
+        // However, the method will then throw a ClassCastException
+        int b1 = Integer.parseInt( (String)backendValue );
+        int b2 = Integer.parseInt( (String)assertValue );
+        
+        if ( b1 == b2 )
+        {
+            return 0;
+        }
+
+        // The boolean should have been stored as 'TRUE' or 'FALSE'
+        // into the server, and the compare method will be called
+        // with normalized booleans, so no need to uppercase them.
+        // We don't need to check the assertion value, because we
+        // are dealing with booleans.
+        return ( b1 > b2 ? 1 : -1 );
+    }
+}



Mime
View raw message