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

[email protected]
Newsgroups gmane.text.xml.soap.devel
Message-ID <[email protected]>
snichol     2003/04/28 08:40:11

  Modified:    java/src/org/apache/soap/encoding Hex.java
  Log:
  Submitted by: [email protected] (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 <[email protected]>
  + * @author Davanum Srinivas &lt;[email protected]&gt;
  + * @author Hugh Kennedy &lt;[email protected]&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 =
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.