org.freeshell.zs.common
Class SimpleProperties

java.lang.Object
  extended by org.freeshell.zs.common.SimpleProperties

public class SimpleProperties
extends java.lang.Object

Represent a collection of properties, each denoted by a key-value pair. This class is synchronized to allow simultaneous access; however, it must be externally synchronized when iterating through its keys and values.


Constructor Summary
SimpleProperties()
          Constructor.
SimpleProperties(SimpleProperties defaultProperties)
          Constructor.
SimpleProperties(java.lang.String defaultProperties)
          Constructor.
 
Method Summary
 java.lang.Object get(java.lang.String key)
          Get the property value corresponding to the specified key.
 java.lang.String getAsString(java.lang.String key)
          Get the property value (cast as a String) corresponding to the specified key.
 boolean getBoolean(java.lang.String key)
          Get the property value (cast as a boolean) corresponding to the specified key.
 java.io.File getFile(java.lang.String key)
          Get the property value (cast as a File) corresponding to the specified key.
 int getInt(java.lang.String key)
          Get the property value (cast as an int) corresponding to the specified key.
 long getLong(java.lang.String key)
          Get the property value (cast as a long) corresponding to the specified key.
 java.lang.String getString(java.lang.String key)
          Get the property value (cast as a String) corresponding to the specified key.
 java.util.Set<java.lang.String> keySet()
          Get the set of keys in this collection of properties.
 void set(java.lang.String key, java.lang.Object value)
          Set the property value corresponding to the specified key.
 void setBoolean(java.lang.String key, boolean value)
          Set the property value (a boolean) corresponding to the specified key.
 void setFile(java.lang.String key, java.io.File value)
          Set the property value (a File) corresponding to the specified key.
 void setInt(java.lang.String key, int value)
          Set the property value (an int) corresponding to the specified key.
 void setLong(java.lang.String key, long value)
          Set the property value (a long) corresponding to the specified key.
 void setString(java.lang.String key, java.lang.String value)
          Set the property value (a String) corresponding to the specified key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleProperties

public SimpleProperties()
Constructor. Creates an empty collection of properties.


SimpleProperties

public SimpleProperties(SimpleProperties defaultProperties)
Constructor. Creates a collection of properties containing the specified default properties.

Parameters:
defaultProperties - default properties

SimpleProperties

public SimpleProperties(java.lang.String defaultProperties)
Constructor. Creates a collection of properties containing the default properties obtained by parsing the specified string for "key:value" pairs.

Parameters:
defaultProperties - default properties
Method Detail

keySet

public java.util.Set<java.lang.String> keySet()
Get the set of keys in this collection of properties.

Returns:
set of keys in this collection of properties

get

public java.lang.Object get(java.lang.String key)
Get the property value corresponding to the specified key.

Parameters:
key - key
Returns:
property value corresponding to the specified key

set

public void set(java.lang.String key,
                java.lang.Object value)
Set the property value corresponding to the specified key.

Parameters:
key - key
value - property value

getAsString

public java.lang.String getAsString(java.lang.String key)
Get the property value (cast as a String) corresponding to the specified key. Unlike getString(), this method does not change the property value in the map to a String.

Parameters:
key - key
Returns:
property value (cast as a String)

getString

public java.lang.String getString(java.lang.String key)
Get the property value (cast as a String) corresponding to the specified key. This method changes the property value in the map to a String, if necessary.

Parameters:
key - key
Returns:
property value (cast as a String)

setString

public void setString(java.lang.String key,
                      java.lang.String value)
Set the property value (a String) corresponding to the specified key.

Parameters:
key - key
value - property value (a String)

getBoolean

public boolean getBoolean(java.lang.String key)
Get the property value (cast as a boolean) corresponding to the specified key. This method changes the property value in the map to a Boolean, if necessary.

Parameters:
key - key
Returns:
property value (cast as a boolean)

setBoolean

public void setBoolean(java.lang.String key,
                       boolean value)
Set the property value (a boolean) corresponding to the specified key.

Parameters:
key - key
value - property value (a boolean)

getInt

public int getInt(java.lang.String key)
Get the property value (cast as an int) corresponding to the specified key. This method changes the property value in the map to an Integer, if necessary.

Parameters:
key - key
Returns:
property value (cast as an int)

setInt

public void setInt(java.lang.String key,
                   int value)
Set the property value (an int) corresponding to the specified key.

Parameters:
key - key
value - property value (an int)

getLong

public long getLong(java.lang.String key)
Get the property value (cast as a long) corresponding to the specified key. This method changes the property value in the map to a Long, if necessary.

Parameters:
key - key
Returns:
property value (cast as a long)

setLong

public void setLong(java.lang.String key,
                    long value)
Set the property value (a long) corresponding to the specified key.

Parameters:
key - key
value - property value (a long)

getFile

public java.io.File getFile(java.lang.String key)
Get the property value (cast as a File) corresponding to the specified key. This method changes the property value in the map to a File, if necessary.

Parameters:
key - key
Returns:
property value (cast as a File)

setFile

public void setFile(java.lang.String key,
                    java.io.File value)
Set the property value (a File) corresponding to the specified key.

Parameters:
key - key
value - property value (a File)