Agent System POND 1.2 (28.2.2002)

FIM.Util
Class ReadOnlyStore

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--FIM.Util.ReadOnlyStore
All Implemented Interfaces:
Serializable

public class ReadOnlyStore
extends Dictionary
implements Serializable

Similar to a Hashtable, but only allows to set a value once. Removal of entries or overwriting values is not allowed.
The data is stored in serialized form. Therefore value must implement java.io.Serializable. Changes after adding the object to the store are not reflected.

Version:
1.0, 1.7.2000
Author:
Michael Sonntag
See Also:
Hashtable, Serializable, Serialized Form

Constructor Summary
ReadOnlyStore()
          Constructs a new, empty read-only store.
ReadOnlyStore(int initialCapacity)
          Constructs a new, empty read-only store with the specified initial capacity.
 
Method Summary
 boolean contains(Object value)
          Tests if some key maps into the specified value in this store.
 boolean containsKey(Object key)
          Tests if the specified object is a key in this store.
 Enumeration elements()
          Returns an enumeration of the values in this store.
 Object get(Object key)
          Returns the value to which the specified key is mapped in this table.
 boolean isEmpty()
          Tests if this store maps no keys to values.
 Enumeration keys()
          Returns an enumeration of the keys in this store.
 Object put(Object key, Object value)
          Maps the specified key to the specified value in this table.
 Object remove(Object key)
          Removes an object from the store.
 int size()
          Returns the number of keys in this store.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnlyStore

public ReadOnlyStore()
Constructs a new, empty read-only store.

ReadOnlyStore

public ReadOnlyStore(int initialCapacity)
Constructs a new, empty read-only store with the specified initial capacity.
Parameters:
initialCapacity - the initial capacity
Throws:
IllegalArgumentException - if the initial capacity is less than one
Method Detail

contains

public boolean contains(Object value)
Tests if some key maps into the specified value in this store.
Parameters:
value - a value to search for
Returns:
true if and only if some key maps to the value argument in this store as determined by the equals method, false otherwise
Throws:
NullPointerException - if the value is null
See Also:
containsKey(Object)

containsKey

public boolean containsKey(Object key)
Tests if the specified object is a key in this store.
Parameters:
key - possible key
Returns:
true if and only if the specified object is a key in this hashtable, as determined by the equals method, false otherwise
See Also:
contains(Object)

elements

public Enumeration elements()
Returns an enumeration of the values in this store. Use the Enumeration methods on the returned object to fetch the elements sequentially.
Overrides:
elements in class Dictionary
Returns:
an enumeration of the values in this store
See Also:
Enumeration, keys()

keys

public Enumeration keys()
Returns an enumeration of the keys in this store.
Overrides:
keys in class Dictionary
Returns:
an enumeration of the keys in this store
See Also:
Enumeration, elements()

isEmpty

public boolean isEmpty()
Tests if this store maps no keys to values.
Overrides:
isEmpty in class Dictionary
Returns:
true if this store maps no keys to values, false otherwise.

size

public int size()
Returns the number of keys in this store.
Overrides:
size in class Dictionary
Returns:
the number of keys in this store

get

public Object get(Object key)
Returns the value to which the specified key is mapped in this table.
Overrides:
get in class Dictionary
Parameters:
key - a key in the htable.
Returns:
the value to which the key is mapped in this table; null if the key is not mapped to any value in this table.
See Also:
put(Object, Object)

remove

public Object remove(Object key)
Removes an object from the store. Not allowed in a read-only store.
Overrides:
remove in class Dictionary
Parameters:
key - ignored
Throws:
IllegalStateException - always

put

public Object put(Object key,
                  Object value)
Maps the specified key to the specified value in this table. Neither the key nor the value can be null. The value must be Serializable. The key may not currently exist in the table (Overwriting value is prohibited).

The value can be retrieved by calling the get method with a key that is equal to the original key.

Overrides:
put in class Dictionary
Parameters:
key - the table key
value - the value
Returns:
always null, as overwriting is not allowed
Throws:
NullPointerException - if the key or value is null.
IllegalArgumentException - if the value is not serializable.
See Also:
Object.equals(Object), get(Object)

Agent System POND 1.2 (28.2.2002)

Submit a bug

Copyright 2001,2002 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.