cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r123897 - /cocoon/branches/BRANCH_2_1_X/src/blocks/serializers/java/org/apache/cocoon/components/serializers/util/DocType.java
Date Sun, 02 Jan 2005 18:41:36 GMT
Author: antonio
Date: Sun Jan  2 10:41:35 2005
New Revision: 123897

URL: http://svn.apache.org/viewcvs?view=rev&rev=123897
Log:
Define hashCode()
Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/serializers/java/org/apache/cocoon/components/serializers/util/DocType.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/serializers/java/org/apache/cocoon/components/serializers/util/DocType.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/serializers/java/org/apache/cocoon/components/serializers/util/DocType.java?view=diff&rev=123897&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/serializers/java/org/apache/cocoon/components/serializers/util/DocType.java&r1=123896&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/serializers/java/org/apache/cocoon/components/serializers/util/DocType.java&r2=123897
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/serializers/java/org/apache/cocoon/components/serializers/util/DocType.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/serializers/java/org/apache/cocoon/components/serializers/util/DocType.java
Sun Jan  2 10:41:35 2005
@@ -15,7 +15,8 @@
  */
 package org.apache.cocoon.components.serializers.util;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
 
 /**
  * The <code>DocType</code> class encapsulates informations regarding
@@ -134,17 +135,27 @@
      * instance.
      */
     public boolean equals(Object object) {
-        if (object == null) return(false);
-        if (this == object) return(true);
-
-        if (!(object instanceof DocType)) return(false);
-        DocType doctype = (DocType)object;
-
-        if (StringUtils.equals(this.public_id, doctype.public_id)
-            && StringUtils.equals(this.system_id, doctype.system_id)
-            && this.root_name.equals(doctype.root_name)) {
-            return true;
+        if (!(object instanceof DocType)) {
+            return false;
         }
-        return false;
+        DocType rhs = (DocType)object;
+        return new EqualsBuilder()
+            .appendSuper(super.equals(object))
+            .append(public_id, rhs.public_id)
+            .append(system_id, rhs.system_id)
+            .append(root_name, rhs.root_name)
+            .isEquals();
+    }
+
+    /**
+     * Returns the hash code value for this docType
+     */
+    public int hashCode() {
+        return new HashCodeBuilder()
+            .appendSuper(super.hashCode())
+            .append(public_id)
+            .append(system_id)
+            .append(root_name)
+            .toHashCode();
     }
 }

Mime
View raw message