nz.ac.waikato.jdsl.core.ref
Class HashtableDecorable

java.lang.Object
  extended by nz.ac.waikato.jdsl.core.ref.HashtableDecorable
All Implemented Interfaces:
java.io.Serializable, Decorable
Direct Known Subclasses:
NodeBinaryTree.NBTNode, NodeSequence.FNSNode

public class HashtableDecorable
extends java.lang.Object
implements Decorable, java.io.Serializable

An implementation of Decorable using a hashtable.

Version:
JDSL 2.1.1
Author:
Mike Boilen (mgb) , Benoit Hudson (bh) , Ryan Shaun Baker (rsb)
See Also:
Serialized Form

Constructor Summary
HashtableDecorable()
           
 
Method Summary
 ObjectIterator attributes()
          Returns an iterator over all the attributes attached to this decorable.
protected  int capacity()
          Gets the capacity of this hashtable.
 java.lang.Object destroy(java.lang.Object key)
          Destroys a decoration.
 java.lang.Object get(java.lang.Object key)
          Gets the value of a decoration.
 boolean has(java.lang.Object key)
          Tests if a decoration exists.
protected  int hash(java.lang.Object o)
          Gets the hashcode for a particular object.
protected  void rehash()
           
 void set(java.lang.Object key, java.lang.Object value)
          Sets the value of a decoration.
protected  int size()
          Gets the size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashtableDecorable

public HashtableDecorable()
Method Detail

destroy

public final java.lang.Object destroy(java.lang.Object key)
                               throws InvalidAttributeException,
                                      CoreException
Destroys a decoration.

Specified by:
destroy in interface Decorable
Parameters:
key - The attribute to destroy (eliminate)
Returns:
the value associated with destroyed attribute
Throws:
InvalidAttributeException - if the decoration does not exist.
CoreException

has

public final boolean has(java.lang.Object key)
Tests if a decoration exists.

Specified by:
has in interface Decorable
Parameters:
key - The attribute for which to check this decorable object

set

public final void set(java.lang.Object key,
                      java.lang.Object value)
               throws InvalidAttributeException,
                      CoreException
Sets the value of a decoration.

Specified by:
set in interface Decorable
Parameters:
key - The attribute to set (and create if necessary)
value - the new value of the attribute in the decorable object
Throws:
InvalidAttributeException - if the attribute is invalid (i.e. wrong class)
CoreException

get

public final java.lang.Object get(java.lang.Object key)
                           throws InvalidAttributeException,
                                  CoreException
Gets the value of a decoration.

Specified by:
get in interface Decorable
Parameters:
key - The attribute of which to attempt to get the value
Returns:
The value associated with attribute
Throws:
InvalidAttributeException - if attr is not set or is otherwise invalid (i.e. wrong class)
CoreException

attributes

public final ObjectIterator attributes()
Description copied from interface: Decorable
Returns an iterator over all the attributes attached to this decorable.

Specified by:
attributes in interface Decorable
Returns:
an ObjectIterator over all the attributes attached to this decorable

size

protected final int size()
Gets the size.


capacity

protected final int capacity()
Gets the capacity of this hashtable. The capacity is cached to avoid accessing iData.length many times.


rehash

protected final void rehash()

hash

protected final int hash(java.lang.Object o)
Gets the hashcode for a particular object. If the object is null, it returns 0. Uses System.identityHashCode (aka the address in memory).



Copyright © 2009 ModelJUnit Project. All Rights Reserved.