com.tensegrity.generic.util
Interface PropertiesFile

All Known Implementing Classes:
com.tensegrity.generic.util.Properties

public interface PropertiesFile

The PropertiesFile interface represents a Properties alike behavior for persistent properties for a component, class or system, which needs persistent properties. Such PropertiesFile implementation should consist of an internal file or stream based association which is completely hidden to the outside. Users should only call load() and save(String) to either load or store the properties.

Version:
$Id: PropertiesFile.java,v 1.1 2004/07/29 15:57:39 GillesIachelini Exp $
Author:
GillesIachelini

Method Summary
 void clear()
          Clears the internal list of properties.
 java.lang.String getProperty(java.lang.String key)
          Returns the property string previously associated to the parameter key.
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Returns the property string previously associated to the parameter key.
 java.util.Set keySet()
          Returns a set of keys.
 void load()
          Loads properties from the stream it was previously associated with.
 java.lang.Object remove(java.lang.Object key)
          Removes a key and corresponding value from this PropertiesFile.
 void save(java.lang.String header)
          Writes the currently key-value pairs of this PropertiesFile instance out to internally set stream.
 java.lang.String setProperty(java.lang.String key, java.lang.String value)
          Maps the specified key to the specified value in this PropertiesFile.
 

Method Detail

clear

public void clear()
Clears the internal list of properties.


load

public void load()
          throws java.io.IOException
Loads properties from the stream it was previously associated with. Any existing property should be overwritten by the newly read one.

Throws:
java.io.IOException - if an error occurred when reading from the input stream.

getProperty

public java.lang.String getProperty(java.lang.String key)
Returns the property string previously associated to the parameter key. If no such property can be found null is returned.

Parameters:
key - the key of a property.
Returns:
the string value associated with the parameter key.

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
Returns the property string previously associated to the parameter key. If no such property can be found defaultValue is returned.

Parameters:
key - the key of a property.
defaultValue - the value which should be returned if no value was associated with the given key.
Returns:
the string value associated with the parameter key.

setProperty

public java.lang.String setProperty(java.lang.String key,
                                    java.lang.String value)
Maps the specified key to the specified value in this PropertiesFile. Neither the key nor the value can be null. If there was no entry with that key yet, null is returned. Otherwise the previously mapped value is returned.

Parameters:
key - the key for the property.
value - the value.
Returns:
the previous value to which the key was mapped in this dictionary, or null if the key did not have a previous mapping.

remove

public java.lang.Object remove(java.lang.Object key)
Removes a key and corresponding value from this PropertiesFile.

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

keySet

public java.util.Set keySet()
Returns a set of keys.

Returns:
a Set of the current keys of this PropertiesFile.

save

public void save(java.lang.String header)
          throws java.io.IOException
Writes the currently key-value pairs of this PropertiesFile instance out to internally set stream.

Parameters:
header - the header to prepend to the key-value pairs. (optional)
Throws:
java.io.IOException - if writing this property list to the specified output stream throws an IOException.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.