org.codehaus.plexus.registry
Interface Registry


public interface Registry

The Plexus registry is a single source of external configuration for Plexus components and applications. It can be used by components to source configuration, knowing that it can be used from within applications without the information being hard coded into the component.


Field Summary
static java.lang.String ROLE
           
 
Method Summary
 void addChangeListener(RegistryListener listener)
          Add a change listener.
 void addConfigurationFromFile(java.io.File file)
          Load configuration from the given file.
 void addConfigurationFromFile(java.io.File file, java.lang.String prefix)
          Load configuration from the given file.
 void addConfigurationFromResource(java.lang.String resource)
          Load configuration from the given classloader resource.
 void addConfigurationFromResource(java.lang.String resource, java.lang.String prefix)
          Load configuration from the given classloader resource.
 java.lang.String dump()
          Dump the entire registry to a string, for debugging purposes.
 boolean getBoolean(java.lang.String key)
          Get a boolean value from the registry.
 boolean getBoolean(java.lang.String key, boolean defaultValue)
          Get a boolean value from the registry.
 int getInt(java.lang.String key)
          Get an integer value from the registry.
 int getInt(java.lang.String key, int defaultValue)
          Get an integer value from the registry.
 java.util.Collection getKeys()
          Get all the keys in this registry.
 java.util.List getList(java.lang.String key)
          Get a list of strings at the given key in the registry.
 java.util.Properties getProperties(java.lang.String key)
          TODO move to Map which is more generic ? Get the properties at the given key in the registry.
 Registry getSection(java.lang.String name)
          Get a subsection of the registry, identified by the given name.
 java.lang.String getString(java.lang.String key)
          Get a string value from the registry.
 java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
          Get a string value from the registry.
 Registry getSubset(java.lang.String key)
          Get a subset of the registry, for all keys descended from the given key.
 java.util.List getSubsetList(java.lang.String key)
          Get a list of subsets of the registry, for all keys descended from the given key.
 boolean isEmpty()
          Determine if the registry contains any elements.
 void remove(java.lang.String key)
          Remove a keyed element from the registry.
 void removeSubset(java.lang.String key)
          Remove a keyed subset of the registry.
 void save()
          Save any changes to the registry since it was loaded.
 void setBoolean(java.lang.String key, boolean value)
          Set a boolean value in the registry.
 void setInt(java.lang.String key, int value)
          Set an integer value in the registry.
 void setString(java.lang.String key, java.lang.String value)
          Set a string value in the registry.
 

Field Detail

ROLE

static final java.lang.String ROLE
Method Detail

dump

java.lang.String dump()
Dump the entire registry to a string, for debugging purposes.

Returns:
the registry contents

getString

java.lang.String getString(java.lang.String key)
Get a string value from the registry. If not found, null is returned.

Parameters:
key - the key in the registry
Returns:
the value

getString

java.lang.String getString(java.lang.String key,
                           java.lang.String defaultValue)
Get a string value from the registry. If not found, the default value is used.

Parameters:
key - the key in the registry
defaultValue - the default value
Returns:
the value

setString

void setString(java.lang.String key,
               java.lang.String value)
Set a string value in the registry.

Parameters:
key - the key in the registry
value - the value to set

getInt

int getInt(java.lang.String key)
Get an integer value from the registry. If not found, an exception is thrown.

Parameters:
key - the key in the registry
Returns:
the value
Throws:
java.util.NoSuchElementException - if the key is not found

getInt

int getInt(java.lang.String key,
           int defaultValue)
Get an integer value from the registry. If not found, the default value is used.

Parameters:
key - the key in the registry
defaultValue - the default value
Returns:
the value

setInt

void setInt(java.lang.String key,
            int value)
Set an integer value in the registry.

Parameters:
key - the key in the registry
value - the value to set

getBoolean

boolean getBoolean(java.lang.String key)
Get a boolean value from the registry. If not found, an exception is thrown.

Parameters:
key - the key in the registry
Returns:
the value
Throws:
java.util.NoSuchElementException - if the key is not found

getBoolean

boolean getBoolean(java.lang.String key,
                   boolean defaultValue)
Get a boolean value from the registry. If not found, the default value is used.

Parameters:
key - the key in the registry
defaultValue - the default value
Returns:
the value

setBoolean

void setBoolean(java.lang.String key,
                boolean value)
Set a boolean value in the registry.

Parameters:
key - the key in the registry
value - the value to set

addConfigurationFromResource

void addConfigurationFromResource(java.lang.String resource)
                                  throws RegistryException
Load configuration from the given classloader resource.

Parameters:
resource - the location to load the configuration from
Throws:
RegistryException - if a problem occurred reading the resource to add to the registry

addConfigurationFromResource

void addConfigurationFromResource(java.lang.String resource,
                                  java.lang.String prefix)
                                  throws RegistryException
Load configuration from the given classloader resource.

Parameters:
resource - the location to load the configuration from
prefix - the location to add the configuration at in the registry
Throws:
RegistryException - if a problem occurred reading the resource to add to the registry

addConfigurationFromFile

void addConfigurationFromFile(java.io.File file)
                              throws RegistryException
Load configuration from the given file.

Parameters:
file - the location to load the configuration from
Throws:
RegistryException - if a problem occurred reading the resource to add to the registry

addConfigurationFromFile

void addConfigurationFromFile(java.io.File file,
                              java.lang.String prefix)
                              throws RegistryException
Load configuration from the given file.

Parameters:
file - the location to load the configuration from
prefix - the location to add the configuration at in the registry
Throws:
RegistryException - if a problem occurred reading the resource to add to the registry

isEmpty

boolean isEmpty()
Determine if the registry contains any elements.

Returns:
whether the registry contains any elements

getList

java.util.List getList(java.lang.String key)
Get a list of strings at the given key in the registry.

Parameters:
key - the key to lookup
Returns:
the list of strings

getProperties

java.util.Properties getProperties(java.lang.String key)
TODO move to Map which is more generic ? Get the properties at the given key in the registry.

Parameters:
key - the key to lookup
Returns:
the properties

getSubset

Registry getSubset(java.lang.String key)
Get a subset of the registry, for all keys descended from the given key.

Parameters:
key - the key to take the subset from
Returns:
the registry subset

getSubsetList

java.util.List getSubsetList(java.lang.String key)
Get a list of subsets of the registry, for all keys descended from the given key.

Parameters:
key - the key to take the subsets from
Returns:
the registry subsets

getSection

Registry getSection(java.lang.String name)
Get a subsection of the registry, identified by the given name. If it doesn't exist, null will be returned.

Parameters:
name - registry section name
Returns:
the registry

save

void save()
          throws RegistryException,
                 java.lang.UnsupportedOperationException
Save any changes to the registry since it was loaded.

Throws:
RegistryException - if there was a problem saving the registry
java.lang.UnsupportedOperationException - if the registry is not writable

addChangeListener

void addChangeListener(RegistryListener listener)
Add a change listener. Note that settings this on the base registry will only detect 'invalidation' events, not individual changes. You should retrieve the named sub-registry to listen for changes.

Parameters:
listener - the listener

getKeys

java.util.Collection getKeys()
Get all the keys in this registry. Keys are only retrieved at a depth of 1.

Returns:
the set of keys

remove

void remove(java.lang.String key)
Remove a keyed element from the registry.

Parameters:
key - the key to remove

removeSubset

void removeSubset(java.lang.String key)
Remove a keyed subset of the registry.

Parameters:
key - the subset to remove


Copyright © 2001-2011 Codehaus. All Rights Reserved.