classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Field position attribute handling


From: Mark Wielaard
Subject: Re: [PATCH] Field position attribute handling
Date: Tue, 18 Nov 2003 22:28:12 +0100

Hi,

On Tue, 2003-11-18 at 20:30, Dalibor Topic wrote:
>     * <li>The specified object is an instance of <code>FieldPosition</code>.
> -   * <li>The specified object has the same field identifier and beginning
> -   * and ending index as this object.
> +   * <li>The specified object has the same field identifier, field attribute 
> +   * and beginning and ending index as this object.
>     * </ul>
>     *
>     * @param obj The object to test for equality to this object.
> @@ -143,15 +180,39 @@
>     */
>    public boolean equals (Object obj)
>    {
> -    if (! (obj instanceof FieldPosition))
> +    if (this == obj)
> +      return true;
> +
> +    if (obj != null && (obj.getClass() != this.getClass()))
>        return false;

The documentation and code don't match up now.
My Class Library book seems to indicate that it actually is instanceof,
thought in most cases your code comparing the actual Class seems more
correct.

> +  /**
> +   * This method returns a hash value for this object
> +   * 
> +   * @return A hash value for this object.
> +   */
> +  public int hashCode ()
> +  {
> +    int hash = 7;
> +
> +    hash = 31 * hash + field_id;
> +    hash = 31 * hash + begin;
> +    hash = 31 * hash + end;
> +    hash = 31 * hash + (null == field_attribute ? 0 : 
> field_attribute.hashCode());
> +
> +    return hash;
> +  }

Just curious, why this particular hash function?
I couldn't find one specified, so I guess any good one will do.
Don't know if you need to include the field_attribute.hashCode() since
it will probably depend on the field_id in almost all cases.

Cheers,

Mark

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]