org.norther.tammi.acorn.lang
Class ArrayKey

java.lang.Object
  extended by org.norther.tammi.acorn.lang.ArrayKey
All Implemented Interfaces:
Serializable, Cloneable, Comparable

public class ArrayKey
extends Object
implements Comparable, Cloneable, Serializable

A class for using one-dimensional arrays as map keys.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
ArrayKey(Object[] a)
          Constructs a new key.
 
Method Summary
 Object clone()
           
 int compareTo(Object other)
           
 boolean equals(int index, ArrayKey key)
          Checks whether the given key equals this one starting from the specified array index.
 boolean equals(Object o)
           
 Object get(int index)
          Gets the indexed element.
 int hashCode()
           
 int length()
          Returns the length of the array.
 void set(int index, Object o)
          Sets the indexed element.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayKey

public ArrayKey(Object[] a)
Constructs a new key.

Parameters:
a - the array.
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

compareTo

public int compareTo(Object other)
Specified by:
compareTo in interface Comparable

clone

public Object clone()
Overrides:
clone in class Object

equals

public boolean equals(int index,
                      ArrayKey key)
Checks whether the given key equals this one starting from the specified array index.

Parameters:
index - they starting index.
key - the key to compare.
Returns:
true if equals, false otherwise.

get

public Object get(int index)
Gets the indexed element.

Parameters:
index - the index.
Returns:
the element.
Throws:
NullPointerException - if the array is null.
ArrayIndexOutOfBoundsException - for an invalid index.

set

public void set(int index,
                Object o)
Sets the indexed element.

Parameters:
index - the index.
o - the element.
Throws:
NullPointerException - if the array is null.
ArrayIndexOutOfBoundsException - for an invalid index.

length

public int length()
Returns the length of the array.

Returns:
the array length.
Throws:
NullPointerException - if the array is null.


Copyright © 2004 The Norther Organization. All rights reserved.