portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jf...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/common/impl LocalizedFieldImpl.java
Date Mon, 08 Mar 2004 16:01:08 GMT
jford       2004/03/08 08:01:08

  Modified:    components/registry/src/java/org/apache/jetspeed/om/common/impl
                        LocalizedFieldImpl.java
  Log:
  Added equals and hashcode impl
  
  Revision  Changes    Path
  1.3       +37 -1     jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/common/impl/LocalizedFieldImpl.java
  
  Index: LocalizedFieldImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/common/impl/LocalizedFieldImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocalizedFieldImpl.java	26 Feb 2004 19:13:11 -0000	1.2
  +++ LocalizedFieldImpl.java	8 Mar 2004 16:01:08 -0000	1.3
  @@ -16,6 +16,7 @@
   import java.util.Locale;
   
   import org.apache.jetspeed.om.common.LocalizedField;
  +import org.apache.jetspeed.util.HashCodeBuilder;
   import org.apache.jetspeed.util.JetspeedObjectID;
   import org.apache.pluto.om.common.ObjectID;
   
  @@ -116,5 +117,40 @@
       public void setName(String name)
       {
           this.name = name;        
  +    }
  +    
  +    public String toString()
  +    {
  +        return "Name: " + name + " Value: " + value + " Locale: " + locale;
  +    }
  +    
  +    public boolean equals(Object o)
  +    {
  +        boolean result = false;
  +        
  +        if(o instanceof LocalizedFieldImpl && o != null)
  +        {
  +            LocalizedFieldImpl localField = (LocalizedFieldImpl)o;
  +            
  +            result = (this.name == null) ? (localField.name == null) : (this.name.equals(localField.name));
  +            result = result && ((this.value == null) ? (localField.value == null)
: (this.value.equals(localField.value)));
  +            result = result && ((this.locale == null) ? (localField.locale == null)
: (this.locale.equals(localField.locale)));
  +        }
  +        
  +        return result;
  +    }
  +    
  +    /**
  +     * @see java.lang.Object#hashCode()
  +     */
  +    public int hashCode()
  +    {
  +        HashCodeBuilder hasher = new HashCodeBuilder(27, 101);
  +        hasher.append(name).append(value);
  +        if(locale != null)
  +        {    
  +            hasher.append(locale.getCountry()).append(locale.getLanguage()).append(locale.getVariant());
  +        }
  +        return hasher.toHashCode();
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message