jdsl.core.ref
Class HashtableDecorable

java.lang.Object
  |
  +--jdsl.core.ref.HashtableDecorable
All Implemented Interfaces:
Decorable, java.io.Serializable
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:
$Id: HashtableDecorable.java,v 1.3 2000/11/05 23:05:12 lv Exp $
Author:
Mike Boilen (mgb) , Benoit Hudson (bh) , Ryan Shaun Baker (rsb)
See Also:
Serialized Form

Constructor Summary
HashtableDecorable()
           
 
Method Summary
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
Throws:
InvalidAttributeException - if the decoration does not exist.

has

public final boolean has(java.lang.Object key)
Tests if a decoration exists.
Specified by:
has in interface Decorable
Following copied from interface: jdsl.core.api.Decorable
Parameters:
attr - The attribute for which to check this decorable object
Throws:
InvalidAttributeException - if attribute is invalid for some reason.

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
Following copied from interface: jdsl.core.api.Decorable
Parameters:
attr - The attribute to set (and create if necessary)
value - the new value of the attribute in the decorable object.
Throws:
InvalidAttributeException - if the key is invalid (i.e. wrong class)

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
Following copied from interface: jdsl.core.api.Decorable
Parameters:
attr - 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)

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).