Joram 5.0.7

org.objectweb.joram.shared.util
Class Properties

java.lang.Object
  extended by org.objectweb.joram.shared.util.Properties
All Implemented Interfaces:
java.lang.Cloneable

public class Properties
extends java.lang.Object
implements java.lang.Cloneable

This class implements a set of properties, which maps keys to values. Only string object can be used as a key, all primitives type can be used as a value.


Constructor Summary
Properties()
          Constructs a new, empty hashtable with a default initial capacity (11) and load factor, which is 0.75.
Properties(int initialCapacity)
          Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is 0.75.
Properties(int initialCapacity, float loadFactor)
          Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.
 
Method Summary
 void clear()
          Clears this hashtable so that it contains no keys.
 java.lang.Object clone()
          Creates a shallow copy of this hashtable.
 boolean containsKey(java.lang.String key)
          Tests if the specified object is a key in this hashtable.
 void copyInto(java.util.Map h)
           
 java.util.Enumeration elements()
          Returns an enumeration of the values in this hashtable.
 java.lang.Object get(java.lang.String key)
          Returns the value to which the specified key is mapped in this hashtable.
 int hashCode()
          Returns the hash code value for this Map as per the definition in the Map interface.
 boolean isEmpty()
          Tests if this hashtable maps no keys to values.
 java.util.Enumeration keys()
          Returns an enumeration of the keys in this hashtable.
 java.lang.Object put(java.lang.String key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtable.
static Properties readFrom(java.io.InputStream is)
          The object implements the readFrom method to restore its contents from the input stream.
protected  void rehash()
          Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently.
 java.lang.Object remove(java.lang.String key)
          Removes the key (and its corresponding value) from this hashtable.
 int size()
          Returns the number of keys in this hashtable.
 java.lang.String toString()
          Returns a string representation of this Properties object in the form of a set of entries, enclosed in braces and separated by the ASCII characters "" (comma and space).
 void writeTo(java.io.OutputStream os)
          The object implements the writeTo method to write its contents to the output stream.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Properties

public Properties(int initialCapacity,
                  float loadFactor)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.

Parameters:
initialCapacity - the initial capacity of the hashtable.
loadFactor - the load factor of the hashtable.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.

Properties

public Properties(int initialCapacity)
Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is 0.75.

Parameters:
initialCapacity - the initial capacity of the hashtable.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero.

Properties

public Properties()
Constructs a new, empty hashtable with a default initial capacity (11) and load factor, which is 0.75.

Method Detail

size

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

Returns:
the number of keys in this hashtable.

isEmpty

public boolean isEmpty()
Tests if this hashtable maps no keys to values.

Returns:
true if this hashtable maps no keys to values; false otherwise.

keys

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

Returns:
an enumeration of the keys in this hashtable.
See Also:
Enumeration, elements(), #keySet(), Map

elements

public java.util.Enumeration elements()
Returns an enumeration of the values 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, keys(), #values(), Map

containsKey

public boolean containsKey(java.lang.String key)
Tests if the specified object is a key in this hashtable.

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.
Throws:
java.lang.NullPointerException - if the key is null.
See Also:
#contains(Object)

get

public java.lang.Object get(java.lang.String key)
Returns the value to which the specified key is mapped in this hashtable.

Parameters:
key - a key in the hashtable.
Returns:
the value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.
Throws:
java.lang.NullPointerException - if the key is null.
See Also:
#put(Object, Object)

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 java.lang.Object put(java.lang.String key,
                            java.lang.Object value)
Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

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

Parameters:
key - the hashtable key.
value - the value.
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one.
Throws:
java.lang.NullPointerException - if the key or value is null.
See Also:
Object.equals(Object), #get(Object)

remove

public java.lang.Object remove(java.lang.String key)
Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.

Parameters:
key - the key that needs to be removed.
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.
Throws:
java.lang.NullPointerException - if the key is null.

clear

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


clone

public java.lang.Object clone()
Creates a shallow copy of this hashtable. All the structure of the hashtable itself is copied, but the keys and values are not cloned. This is a relatively expensive operation.

Overrides:
clone in class java.lang.Object
Returns:
a clone of the hashtable.

toString

public java.lang.String toString()
Returns a string representation of this Properties object in the form of a set of entries, enclosed in braces and separated by the ASCII characters "" (comma and space). Each entry is rendered as the key, an equals sign =, and the associated element, where the toString method is used to convert the key and element to strings.

Overrides to toString method of Object.

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

hashCode

public int hashCode()
Returns the hash code value for this Map as per the definition in the Map interface.

Overrides:
hashCode in class java.lang.Object
Since:
1.2
See Also:
Map.hashCode()

copyInto

public void copyInto(java.util.Map h)

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException
The object implements the writeTo method to write its contents to the output stream.

Parameters:
os - the stream to write the object to
Throws:
java.io.IOException

readFrom

public static Properties readFrom(java.io.InputStream is)
                           throws java.io.IOException
The object implements the readFrom method to restore its contents from the input stream.

Parameters:
is - the stream to read data from in order to restore the object
Throws:
java.io.IOException

Joram 5.0.7

Copyright © 2005 Scalagent - All rights reserved