uk.org.ogsadai.config
Class SimpleKeyValueProperties

java.lang.Object
  extended by uk.org.ogsadai.config.SimpleKeyValueProperties
All Implemented Interfaces:
KeyValueEventDispatcher, KeyValueProperties, Persistable

public class SimpleKeyValueProperties
extends java.lang.Object
implements KeyValueProperties

Simple implementation of a key-value properties set.

Author:
The OGSA-DAI Project Team

Constructor Summary
SimpleKeyValueProperties()
          Constructor.
 
Method Summary
 void addKeyValueEventListener(KeyValueEventListener listener)
          Add a listener to those to be notified of state changed.
 void clear(Key key)
          Remove property with specific key.
 void clearRegexp(java.lang.String regexp)
          Remove keys from the properties based on a supplied regular expression for matching keys.
 boolean containsKey(Key key)
          Returns true if this properties set has a entry for this specified key.
 java.lang.Object get(Key key)
          Return the value associated with a specific key.
 Key[] getKeys()
          Return the keys of all the values.
 Key[] getKeysRegexp(java.lang.String regexp)
          Return all the keys that match a given regular expression.
 void put(Key key, java.lang.Object value)
          Add a key-value to the set.
 void put(KeyValueProperties keyValueProperties)
          Puts all the entries in the given key-value properties store into this key-value properties store.
 void putIndexed(Key key, java.lang.Object[] values)
          Put the values of the array in successive keys where each value is entered with a separate key formed from the given key with a postfix of 1..N where N = values.length.
 void removeKeyValueEventListener(KeyValueEventListener listener)
          Remove a listener from those to be notified of state changed.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleKeyValueProperties

public SimpleKeyValueProperties()
Constructor.

Method Detail

containsKey

public boolean containsKey(Key key)
Returns true if this properties set has a entry for this specified key.

Specified by:
containsKey in interface KeyValueProperties
Parameters:
key - keys whose value in the properties set is to be tested.
Returns:
true if this properties set has an entry for the specified key, false otherwise.

getKeys

public Key[] getKeys()
Return the keys of all the values.

Specified by:
getKeys in interface KeyValueProperties
Returns:
array of keys

get

public java.lang.Object get(Key key)
                     throws KeyValueUnknownException
Return the value associated with a specific key.

Specified by:
get in interface KeyValueProperties
Parameters:
key - Key
Returns:
value
Throws:
KeyValueUnknownException - If there is no value with the given key.

getKeysRegexp

public Key[] getKeysRegexp(java.lang.String regexp)
                    throws java.util.regex.PatternSyntaxException
Return all the keys that match a given regular expression.

Specified by:
getKeysRegexp in interface KeyValueProperties
Parameters:
regexp - Regular expression.
Returns:
Object[] with zero or more keys.
Throws:
java.util.regex.PatternSyntaxException - If the regular expression is not valid.

put

public void put(Key key,
                java.lang.Object value)
Add a key-value to the set. Any previous value with this key is overwritten.

Specified by:
put in interface KeyValueProperties
Parameters:
key - Key
value - Value

putIndexed

public void putIndexed(Key key,
                       java.lang.Object[] values)
Put the values of the array in successive keys where each value is entered with a separate key formed from the given key with a postfix of 1..N where N = values.length.

Specified by:
putIndexed in interface KeyValueProperties
Parameters:
key - Key prefix
values - Values

put

public void put(KeyValueProperties keyValueProperties)
Puts all the entries in the given key-value properties store into this key-value properties store. Any previous values with a key in the given store will be overwritten.

Specified by:
put in interface KeyValueProperties
Parameters:
keyValueProperties - the key-value properties to be added.

clear

public void clear(Key key)
Remove property with specific key.

Specified by:
clear in interface KeyValueProperties
Parameters:
key - Key prefix

clearRegexp

public void clearRegexp(java.lang.String regexp)
                 throws java.util.regex.PatternSyntaxException
Remove keys from the properties based on a supplied regular expression for matching keys.

Specified by:
clearRegexp in interface KeyValueProperties
Parameters:
regexp - Pattern for keys to remove
Throws:
java.util.regex.PatternSyntaxException - If the regular expression is not valid.

addKeyValueEventListener

public void addKeyValueEventListener(KeyValueEventListener listener)
Add a listener to those to be notified of state changed.

Specified by:
addKeyValueEventListener in interface KeyValueEventDispatcher
Parameters:
listener - the listener to be added

removeKeyValueEventListener

public void removeKeyValueEventListener(KeyValueEventListener listener)
Remove a listener from those to be notified of state changed.

Specified by:
removeKeyValueEventListener in interface KeyValueEventDispatcher
Parameters:
listener - the listener to be removed

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object