directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1066043 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap: codec/controls/ControlDecorator.java codec/decorators/SearchRequestDecorator.java model/message/controls/BasicControl.java
Date Tue, 01 Feb 2011 13:43:53 GMT
Author: elecharny
Date: Tue Feb  1 13:43:53 2011
New Revision: 1066043

URL: http://svn.apache.org/viewvc?rev=1066043&view=rev
Log:
Added some missing hashCode() methods

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/BasicControl.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecorator.java?rev=1066043&r1=1066042&r2=1066043&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecorator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecorator.java
Tue Feb  1 13:43:53 2011
@@ -195,37 +195,27 @@ public abstract class ControlDecorator<E
     // ------------------------------------------------------------------------
     // Object Method Overrides
     // ------------------------------------------------------------------------
-
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        return decorated.hashCode();
+    }
 
     /**
      * @see Object#equals(Object)
      */
     public boolean equals( Object o )
     {
-        if ( o == this )
+        if ( decorated == null )
         {
-            return true;
+            return o == null;
         }
-
-        if ( o == null )
+        else
         {
-            return false;
+            return decorated.equals( o );
         }
-
-        if ( !( o instanceof Control) )
-        {
-            return false;
-        }
-
-        Control otherControl = ( Control ) o;
-        
-        if ( !getOid().equalsIgnoreCase( otherControl.getOid() ) )
-        {
-            return false;
-        }
-
-        //noinspection SimplifiableIfStatement
-        return otherControl.isCritical() == isCritical();
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java?rev=1066043&r1=1066042&r2=1066043&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
Tue Feb  1 13:43:53 2011
@@ -669,100 +669,6 @@ public class SearchRequestDecorator exte
     }
 
 
-    /**
-     * Checks to see if two search requests are equal. The Lockable properties
-     * and the get/set context specific parameters are not consulted to
-     * determine equality. The filter expression tree comparison will normalize
-     * the child order of filter branch nodes then generate a string
-     * representation which is comparable. For the time being this is a very
-     * costly operation.
-     *
-     * @param obj the object to check for equality to this SearchRequest
-     * @return true if the obj is a SearchRequest and equals this SearchRequest,
-     *         false otherwise
-     */
-    public boolean equals( Object obj )
-    {
-        if ( obj == this )
-        {
-            return true;
-        }
-
-        if ( !super.equals( obj ) )
-        {
-            return false;
-        }
-
-        SearchRequest req = ( SearchRequest ) obj;
-
-        if ( !req.getBase().equals( getDecorated().getBase() ) )
-        {
-            return false;
-        }
-
-        if ( req.getDerefAliases() != getDecorated().getDerefAliases() )
-        {
-            return false;
-        }
-
-        if ( req.getScope() != getDecorated().getScope() )
-        {
-            return false;
-        }
-
-        if ( req.getSizeLimit() != getDecorated().getSizeLimit() )
-        {
-            return false;
-        }
-
-        if ( req.getTimeLimit() != getDecorated().getTimeLimit() )
-        {
-            return false;
-        }
-
-        if ( req.getTypesOnly() != getDecorated().getTypesOnly() )
-        {
-            return false;
-        }
-
-        List<String> attributes = getDecorated().getAttributes();
-        if ( req.getAttributes() == null && attributes != null && attributes.size()
> 0 )
-        {
-            return false;
-        }
-
-        if ( req.getAttributes() != null && attributes == null && req.getAttributes().size()
> 0 )
-        {
-            return false;
-        }
-
-        if ( req.getAttributes() != null && attributes != null )
-        {
-            if ( req.getAttributes().size() != attributes.size() )
-            {
-                return false;
-            }
-
-            for ( String attribute : attributes )
-            {
-                if ( ! req.getAttributes().contains( attribute ) )
-                {
-                    return false;
-                }
-            }
-        }
-
-        BranchNormalizedVisitor visitor = new BranchNormalizedVisitor();
-        req.getFilter().accept( visitor );
-        getDecorated().getFilter().accept( visitor );
-
-        String myFilterString = currentFilter.toString();
-        String reqFilterString = req.getFilter().toString();
-
-        return myFilterString.equals( reqFilterString );
-    }
-
-
     //-------------------------------------------------------------------------
     // The SearchRequest methods
     //-------------------------------------------------------------------------

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/BasicControl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/BasicControl.java?rev=1066043&r1=1066042&r2=1066043&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/BasicControl.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/BasicControl.java
Tue Feb  1 13:43:53 2011
@@ -96,6 +96,19 @@ public class BasicControl implements Con
     {
         this.criticality = criticality;
     }
+    
+    
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        int h = 17;
+        h = h*37 + ( criticality ? 1 : 0 );
+        h = h*37 + ( oid == null ? 0 : oid.hashCode() );
+        
+        return h;
+    }
 
     
     /**



Mime
View raw message