fr.dyade.aaa.agent
Class ServersHT

java.lang.Object
  extended by fr.dyade.aaa.agent.ServersHT

public class ServersHT
extends java.lang.Object

This class implements a ServerDesc hashtable, which uses sid as keys.


Nested Class Summary
private  class ServersHT.Enumerator
          A hashtable enumerator class.
private static class ServersHT.ServerDescEntry
          Hashtable collision list.
 
Field Summary
private  int count
          The total number of entries in the hash table.
private static int initialCapacity
          The default initial capacity for the hashtable: 13.
private static int KEYS
           
private static float loadFactor
          The default load factor for the hashtable: 0.75f.
private  int modCount
          The number of times this Hashtable has been modified.
private  ServersHT.ServerDescEntry[] table
          The hash table data.
private  int threshold
          The table is rehashed each time its size exceeds this threshold.
private static int VALUES
           
 
Constructor Summary
ServersHT()
          Constructs a new, empty hashtable with the default initial capacity and load factor.
 
Method Summary
 void clear()
          Clears this hashtable so that it contains no descriptors.
 java.util.Enumeration elements()
          Returns an enumeration of the server descriptors in this hashtable.
 ServerDesc get(short sid)
          Returns the descriptor of the corresponding server.
 java.util.Enumeration keys()
          Returns an enumeration of the keys (server id.) in this hashtable.
 ServerDesc put(ServerDesc desc)
          Maps the specified desc in this hashtable.
protected  void rehash()
          Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently.
 ServerDesc remove(short sid)
          Removes the descriptor from this hashtable.
 int size()
          Returns the number of entries in this hashtable.
 java.lang.String toString()
          Returns a string representation of this Hashtable object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

table

private transient ServersHT.ServerDescEntry[] table
The hash table data.


count

private transient int count
The total number of entries in the hash table.


initialCapacity

private static final int initialCapacity
The default initial capacity for the hashtable: 13.

See Also:
Constant Field Values

loadFactor

private static final float loadFactor
The default load factor for the hashtable: 0.75f.

See Also:
Constant Field Values

threshold

private int threshold
The table is rehashed each time its size exceeds this threshold.


modCount

private transient int modCount
The number of times this Hashtable has been modified.


KEYS

private static final int KEYS
See Also:
Constant Field Values

VALUES

private static final int VALUES
See Also:
Constant Field Values
Constructor Detail

ServersHT

public ServersHT()
Constructs a new, empty hashtable with the default initial capacity and load factor.

Method Detail

size

public int size()
Returns the number of entries in this hashtable.

Returns:
the number of entries in this hashtable.

keys

public java.util.Enumeration keys()
Returns an enumeration of the keys (server id.) in this hashtable.

Returns:
an enumeration of the keys in this hashtable.
See Also:
Enumeration

elements

public java.util.Enumeration elements()
Returns an enumeration of the server descriptors in this hashtable. Use the Enumeration methods on the returned object to fetch the elements sequentially.

Returns:
an enumeration of the values in this hashtable.
See Also:
Enumeration

get

public ServerDesc get(short sid)
Returns the descriptor of the corresponding server.

Parameters:
sid - The server unique identification.
Returns:
the descriptor of the corresponding server.

rehash

protected void rehash()
Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently. This method is called automatically when the number of keys in the hashtable exceeds this hashtable's capacity and load factor.


put

public ServerDesc put(ServerDesc desc)
Maps the specified desc in this hashtable. The descriptor can be retrieved by calling the get method with a key that is equal to the server id.

Parameters:
desc - the descriptor.
Returns:
the previous value of the descriptor, or null if it did not have one.
Throws:
java.lang.NullPointerException - if the descriptor is null.

remove

public ServerDesc remove(short sid)
Removes the descriptor from this hashtable. This method does nothing if the key is not in the hashtable.

Parameters:
sid - the id of server that needs to be removed.
Returns:
the descriptor of the server or null if it is not defined.

clear

public void clear()
Clears this hashtable so that it contains no descriptors.


toString

public java.lang.String toString()
Returns a string representation of this Hashtable object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this hashtable.


Copyright © 2010 ScalAgent D.T.. All Rights Reserved.