Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.util
Class HashCode

    java.lang.Object
      org.jboss.util.HashCode

All Implemented Interfaces:
  Cloneable, Comparable, Serializable

public final class HashCode
extends Object
implements Serializable, Cloneable, Comparable

A hash-code generator and a collection of static hash-code generation methods.

Version:
  `$Revision: 1.1 $`
Author:
  Jason Dillon
See Also:
  Serialized Form

Constructor Summary
`HashCode()` Construct a new `HashCode`.
`HashCode(int value)` Construct a new `HashCode` using the given `int` as the base value.

Method Summary
`HashCode` | `add(boolean b)` Add the hash-code of the given value.
`HashCode` | `add(byte n)` Add the hash-code of the given value.
`HashCode` | `add(char n)` Add the hash-code of the given value.
`HashCode` | `add(double f)` Add the hash-code of the given value.
`HashCode` | `add(float f)` Add the hash-code of the given value.
`HashCode` | `add(int n)` Add the hash-code of the given value.
`HashCode` | `add(long n)` Add the hash-code of the given value.
`HashCode` | `add(Object obj)` Add the hash-code of the given object.
`HashCode` | `add(short n)` Add the hash-code of the given value.
`Object` | `clone()` Return a cloned copy of this `HashCode`.
`int` | `compareTo(int other)` Compares this object with the specified `int` for order.
`int` | `compareTo(Object obj)` Compares this object with the specified object for order.
`boolean` | `equals(Object obj)` Test the equality of this `HashCode` and another object.
`static int` | `generate(boolean value)` Generate a hash code for a boolean value.
`static int` | `generate(byte[] bytes)` Generate a hash code for a byte array.
`static int` | `generate(double value)` Generate a hash code for a double value.
`static int` | `generate(float value)` Generate a hash code for a float value.
`static int` | `generate(long value)` Generate a hash code for a long value.
`static int` | `generate(Object obj)` Generate a hash code for an object.
`static int` | `generate(Object[] array)` Generate a shallow hash code for an object array.
`static int` | `generate(Object[] array, boolean deep)` Generate a hash code for an object array.
`int` | `hashCode()` Get the hash-code.
`String` | `toString()` Return a string representation of this `HashCode`.

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### HashCode

    public HashCode(int value)

  Construct a new `HashCode` using the given `int` as the base value.

Parameters:
  `value` - `int` to use as the base value.

### HashCode

    public HashCode()

  Construct a new `HashCode`.

Method Detail

### add

    public HashCode add(boolean b)

  Add the hash-code of the given value.

  Parameters:
    `b` - Value to get hash-code from.
  Returns:
    This `HashCode`.

### add

    public HashCode add(byte n)

  Add the hash-code of the given value.

  Parameters:
    `n` - Value to get hash-code from.
  Returns:
    This `HashCode`.

### add

    public HashCode add(char n)

  Add the hash-code of the given value.

  Parameters:
    `n` - Value to get hash-code from.
  Returns:
    This `HashCode`.

### add

    public HashCode add(short n)

  Add the hash-code of the given value.

  Parameters:
    `n` - Value to get hash-code from.
  Returns:
    This `HashCode`.

### add

    public HashCode add(int n)

  Add the hash-code of the given value.

  Parameters:
    `n` - Value to get hash-code from.
  Returns:
    This `HashCode`.

### add

    public HashCode add(long n)

  Add the hash-code of the given value.

  Parameters:
    `n` - Value to get hash-code from.
  Returns:
    This `HashCode`.

### add

    public HashCode add(float f)

  Add the hash-code of the given value.

  Parameters:
    `f` - Value to get hash-code from.
  Returns:
    This `HashCode`.

### add

    public HashCode add(double f)

  Add the hash-code of the given value.

  Parameters:
    `f` - Value to get hash-code from.
  Returns:
    This `HashCode`.

### add

    public HashCode add(Object obj)

  Add the hash-code of the given object.

  Parameters:
    `obj` - Value to get hash-code from.
  Returns:
    This `HashCode`.

### hashCode

    public int hashCode()

  Get the hash-code.

  Returns:
    Hash-code.

### compareTo

    public int compareTo(int other)

  Compares this object with the specified `int` for order.

  Parameters:
    `other` - Value to compare with.
  Returns:
    A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

### compareTo

    public int compareTo(Object obj)
                  throws ClassCastException

  Compares this object with the specified object for order.

  Specified by:
    `compareTo` in interface `Comparable`
  Returns:
    A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
  Throws:
    `ClassCastException` - Object is not a `HashCode`.

### equals

    public boolean equals(Object obj)

  Test the equality of this `HashCode` and another object.

  Parameters:
    `obj` - Object to test equality with.
  Returns:
    True if object is equal.

### toString

    public String toString()

  Return a string representation of this `HashCode`.

  Returns:
    A string representation of this `HashCode`.

### clone

    public Object clone()

  Return a cloned copy of this `HashCode`.

  Returns:
    Cloned `HashCode`.

### generate

    public static int generate(boolean value)

  Generate a hash code for a boolean value.

  Parameters:
    `value` - Boolean value to generate hash code from.
  Returns:
    Hash code.

### generate

    public static int generate(long value)

  Generate a hash code for a long value.

  Parameters:
    `value` - Long value to generate hash code from.
  Returns:
    Hash code.

### generate

    public static int generate(double value)

  Generate a hash code for a double value.

  Parameters:
    `value` - Double value to generate hash code from.
  Returns:
    Hash code.

### generate

    public static int generate(float value)

  Generate a hash code for a float value.

  Parameters:
    `value` - Float value to generate hash code from.
  Returns:
    Hash code.

### generate

    public static int generate(byte[] bytes)

  Generate a hash code for a byte array.

  Parameters:
    `bytes` - An array of bytes to generate a hash code from.
  Returns:
    Hash code.

### generate

    public static int generate(Object[] array,
                               boolean deep)

  Generate a hash code for an object array.

  Does not handle nested primitive array elements.

  Parameters:
    `array` - Array to generate hashcode for.
    `deep` - True to traverse elements which are arrays to determine the elements hash code.
  Returns:
    Hash code.

### generate

    public static int generate(Object[] array)

  Generate a shallow hash code for an object array.

  Parameters:
    `array` - Array to generate hashcode for.
  Returns:
    Hash code.

### generate

    public static int generate(Object obj)

  Generate a hash code for an object.

  Parameters:
    `obj` - Object to generate hashcode for.
  Returns:
    Hash code.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 JBoss Group, LLC. All Rights Reserved.