org.apache.turbine.util
Class SequencedHashtable

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byorg.apache.turbine.util.SequencedHashtable
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

Deprecated. Use SequencedHashMap from the commons collections.

public class SequencedHashtable
extends java.util.Hashtable

A Hashtable whose keys are sequenced. The sequencing of the keys allow easy access to the values in the order which they were added in. This class is thread safe.

Implementing the List interface is not possible due to a instance method name clash between the Collection and the List interface:

Collectionsboolean remove(Object o)
ListsObject remove(Object o)
So one cannot implement both interfaces at the same, which is unfortunate because the List interface would be very nice in conjuction with Velocity.

A slightly more complex implementation and interface could involve the use of a list of Map.Entry objects.

Version:
$Id: SequencedHashtable.java 264152 2005-08-29 14:50:22Z henning $
Author:
Daniel Rall
See Also:
Serialized Form

Constructor Summary
SequencedHashtable()
          Deprecated. Creates a new instance with default storage.
SequencedHashtable(int size)
          Deprecated. Creates a new instance with the specified storage.
 
Method Summary
 void clear()
          Deprecated. Clears all elements.
 java.lang.Object clone()
          Deprecated. Creates a shallow copy of this object, preserving the internal structure by copying only references.
protected  void freshenSequence(java.lang.Object key, java.lang.Object value)
          Deprecated. Freshens the sequence of the element value if value is not null.
 java.lang.Object get(int index)
          Deprecated. Returns the key at the specified index.
 java.lang.Object getValue(int index)
          Deprecated. Returns the value at the specified index.
 int indexOf(java.lang.Object key)
          Deprecated. Returns the index of the specified key.
 java.util.Iterator iterator()
          Deprecated. Returns a key iterator.
 int lastIndexOf(java.lang.Object key)
          Deprecated. Returns the last index of the specified key.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Deprecated. Stores the provided key/value pair.
 void putAll(java.util.Map t)
          Deprecated. Stores the provided key/value pairs.
 java.lang.Object remove(int index)
          Deprecated. Removes the element at the specified index.
 java.lang.Object remove(java.lang.Object key)
          Deprecated. Removes the element with the specified key.
 java.util.List sequence()
          Deprecated. Returns the ordered sequence of keys.
 java.util.Collection values()
          Deprecated. Slightly cheaper implementation of values() method.
 
Methods inherited from class java.util.Hashtable
contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, rehash, size, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SequencedHashtable

public SequencedHashtable()
Deprecated. 
Creates a new instance with default storage.


SequencedHashtable

public SequencedHashtable(int size)
Deprecated. 
Creates a new instance with the specified storage.

Parameters:
size - The storage to allocate up front.
Method Detail

clear

public void clear()
Deprecated. 
Clears all elements.


clone

public java.lang.Object clone()
Deprecated. 
Creates a shallow copy of this object, preserving the internal structure by copying only references. The keys, values, and sequence are not clone()'d.

Returns:
A clone of this instance.

get

public java.lang.Object get(int index)
Deprecated. 
Returns the key at the specified index.


getValue

public java.lang.Object getValue(int index)
Deprecated. 
Returns the value at the specified index.


indexOf

public int indexOf(java.lang.Object key)
Deprecated. 
Returns the index of the specified key.


iterator

public java.util.Iterator iterator()
Deprecated. 
Returns a key iterator.


lastIndexOf

public int lastIndexOf(java.lang.Object key)
Deprecated. 
Returns the last index of the specified key.


sequence

public java.util.List sequence()
Deprecated. 
Returns the ordered sequence of keys. This method is meant to be used for retrieval of Key / Value pairs in e.g. Velocity:
 ## $table contains a sequenced hashtable
 #foreach ($key in $table.sequence())
 <TR>
 <TD>Key: $key</TD>
 </TD>Value: $table.get($key)</TD>
 </TR>
 #end
 

Returns:
The ordered list of keys.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Deprecated. 
Stores the provided key/value pair. Freshens the sequence of existing elements.

Parameters:
key - The key to the provided value.
value - The value to store.
Returns:
The previous value for the specified key, or null if none.

freshenSequence

protected void freshenSequence(java.lang.Object key,
                               java.lang.Object value)
Deprecated. 
Freshens the sequence of the element value if value is not null.

Parameters:
key - The key whose sequence to freshen.
value - The value whose existance to check before removing the old key sequence.

putAll

public void putAll(java.util.Map t)
Deprecated. 
Stores the provided key/value pairs.

Parameters:
t - The key/value pairs to store.

remove

public java.lang.Object remove(int index)
Deprecated. 
Removes the element at the specified index.

Parameters:
index - The index of the object to remove.
Returns:
The previous value coressponding the key, or null if none existed.

remove

public java.lang.Object remove(java.lang.Object key)
Deprecated. 
Removes the element with the specified key.

Parameters:
key - The Map key of the object to remove.
Returns:
The previous value coressponding the key, or null if none existed.

values

public java.util.Collection values()
Deprecated. 
Slightly cheaper implementation of values() method.



Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.