You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/08/24 02:21:58 UTC

svn commit: rev 36793 - incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message

Author: akarasulu
Date: Mon Aug 23 17:21:58 2004
New Revision: 36793

Modified:
   incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/SearchResponseEntryImpl.java
Log:
fixed formating (a_,m_,; crap) and added equals method

Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/SearchResponseEntryImpl.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/SearchResponseEntryImpl.java	(original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/SearchResponseEntryImpl.java	Mon Aug 23 17:21:58 2004
@@ -14,10 +14,10 @@
  *   limitations under the License.
  *
  */
-package org.apache.ldap.common.message ;
+package org.apache.ldap.common.message;
 
 
-import javax.naming.directory.Attributes ;
+import javax.naming.directory.Attributes;
 
 
 /**
@@ -31,9 +31,9 @@
     extends AbstractResponse implements SearchResponseEntry
 {
     /** Distinguished name of the search result entry returned */
-    private String m_dn ;
+    private String dn = "";
     /** Partial set of attributes returned in response to search */
-    private Attributes m_attributes ;
+    private Attributes attributes;
 
 
     // ------------------------------------------------------------------------
@@ -49,7 +49,7 @@
      */
     public SearchResponseEntryImpl( final int id )
     {
-        super( id, TYPE ) ;
+        super( id, TYPE );
     }
 
 
@@ -65,7 +65,7 @@
      */
     public Attributes getAttributes()
     {
-        return m_attributes ;
+        return attributes;
     }
 
 
@@ -77,8 +77,8 @@
     public void setAttributes( Attributes attributes )
     {
         lockCheck(
-            "Attempt to alter attributes of a locked SearchResponseEntry!" ) ;
-        m_attributes = attributes ;
+            "Attempt to alter attributes of a locked SearchResponseEntry!" );
+        this.attributes = attributes;
     }
 
 
@@ -89,7 +89,7 @@
      */
     public String getObjectName()
     {
-        return m_dn ;
+        return dn;
     }
 
 
@@ -100,7 +100,53 @@
      */
     public void setObjectName( String dn )
     {
-        lockCheck( "Attempt to alter Dn of a locked SearchResponseEntry!" ) ;
-        m_dn = dn ;
+        lockCheck( "Attempt to alter Dn of a locked SearchResponseEntry!" );
+        this.dn = dn;
+    }
+
+
+    /**
+     * Checks for equality by comparing the objectName, and attributes
+     * properties of this Message after delegating to the super.equals()
+     * method.
+     *
+     * @param obj the object to test for equality with this message
+     * @return true if the obj is equal false otherwise
+     */
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+
+        if ( ! super.equals( obj ) )
+        {
+            return false;
+        }
+
+        SearchResponseEntry resp = ( SearchResponseEntry ) obj;
+
+        if ( ! dn.equals( resp.getObjectName() ) )
+        {
+            return false;
+        }
+
+        if ( attributes == null && resp.getAttributes() != null )
+        {
+            return false;
+        }
+
+        if ( attributes != null && resp.getAttributes() == null )
+        {
+            return false;
+        }
+
+        if ( attributes != null && resp.getAttributes() != null )
+        {
+            return attributes.equals( resp.getAttributes() );
+        }
+        
+        return true;
     }
 }