You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by sn...@apache.org on 2003/04/28 17:40:11 UTC

cvs commit: xml-soap/java/src/org/apache/soap/encoding Hex.java

snichol     2003/04/28 08:40:11

  Modified:    java/src/org/apache/soap/encoding Hex.java
  Log:
  Submitted by: kennedyh@engin.umich.edu (hugh kennedy)
  Reviewed by: Scott Nichol
  
  i have a patch for org.apache.soap.encoding.Hex at
   http://hugh-kennedy.chicago.il.us/apache/org.apache.soap.encoding.Hex.java.patch
  
  to fix the .equals() and .hashCode() methods.
  
  Revision  Changes    Path
  1.3       +14 -7     xml-soap/java/src/org/apache/soap/encoding/Hex.java
  
  Index: Hex.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/Hex.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Hex.java	6 Sep 2002 17:50:26 -0000	1.2
  +++ Hex.java	28 Apr 2003 15:40:11 -0000	1.3
  @@ -59,7 +59,8 @@
   /**
    * Custom class for supporting primitive XSD data type hexBinary.
    *
  - * @author Davanum Srinivas <di...@yahoo.com>
  + * @author Davanum Srinivas &lt;dims@yahoo.com&gt;
  + * @author Hugh Kennedy &lt;kennedyh@engin.umich.edu&gt;
    */
   public class Hex extends Object{
   
  @@ -81,15 +82,21 @@
       }
   
       public int hashCode(){
  -        //TODO: How do we hash this?
  -        return super.hashCode();
  +        return m_value.hashCode();
       }
   
       public boolean equals(java.lang.Object object){
  -        //TODO: Is this good enough?
  -        String s1 = object.toString();
  -        String s2 = this.toString();
  -        return s1.equals(s2);
  +        if (this == object) {
  +            return true;
  +        }
  +
  +        if (! (object instanceof Hex)) {
  +            return false;
  +        }
  +
  +        Hex h = (Hex) object;
  +
  +        return java.util.Arrays.equals(h.m_value, m_value);
       }
   
       public static final String ERROR_ODD_NUMBER_OF_DIGITS =