## org.apache.commons.configuration
Class JNDIConfiguration

    java.lang.Object
      org.apache.commons.configuration.event.EventSource
          org.apache.commons.configuration.AbstractConfiguration
              org.apache.commons.configuration.JNDIConfiguration

All Implemented Interfaces:
  Configuration

    public class JNDIConfiguration

extends AbstractConfiguration

This Configuration class allows you to interface with a JNDI datasource. A JNDIConfiguration is read-only, write operations will throw an UnsupportedOperationException. The clear operations are supported but the underlying JNDI data source is not changed.

Version:
  $Id: JNDIConfiguration.java 439648 2006-09-02 20:42:10Z oheger $
Author:
  Eric Pugh

Field Summary

Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
`END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN`

Constructor Summary
`JNDIConfiguration()` Creates a JNDIConfiguration using the default initial context as the root of the properties.
`JNDIConfiguration(Context context)` Creates a JNDIConfiguration using the specified initial context as the root of the properties.
`JNDIConfiguration(Context context, String prefix)` Creates a JNDIConfiguration using the specified initial context shifted by the specified prefix as the root of the properties.
`JNDIConfiguration(String prefix)` Creates a JNDIConfiguration using the default initial context, shifted with the specified prefix, as the root of the properties.

Method Summary
`protected void` `addPropertyDirect(String key, Object obj)` This operation is not supported and will throw an UnsupportedOperationException.
`void` `clearProperty(String key)` Removes the specified property.
`boolean` `containsKey(String key)` Checks whether the specified key is contained in this configuration.
`Context` `getBaseContext()` Return the base context with the prefix applied.
`Context` `getContext()` Return the initial context used by this configuration.
`Iterator` `getKeys()` Returns an iterator with all property keys stored in this configuration.
`Iterator` `getKeys(String prefix)` Returns an iterator with all property keys starting with the given prefix.
`String` `getPrefix()` Returns the prefix.
`Object` `getProperty(String key)` Returns the value of the specified property.
`boolean` `isEmpty()` Returns a flag whether this configuration is empty.
`void` `setContext(Context context)` Set the initial context of the configuration.
`void` `setPrefix(String prefix)` Sets the prefix.
`void` `setProperty(String key, Object value)` This operation is not supported and will throw an UnsupportedOperationException.

Methods inherited from class org.apache.commons.configuration.AbstractConfiguration

`addProperty, clear, clearPropertyDirect, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getList, getList, getListDelimiter, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, interpolate, interpolate, interpolateHelper, isDelimiterParsingDisabled, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, setThrowExceptionOnMissing, subset`

Methods inherited from class org.apache.commons.configuration.event.EventSource
`addConfigurationListener, clearConfigurationListeners, createEvent, fireEvent, getConfigurationListeners, isDetailEvents, removeConfigurationListener, setDetailEvents`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JNDIConfiguration

    public JNDIConfiguration()
                      throws NamingException

  Creates a JNDIConfiguration using the default initial context as the root of the properties.

  Throws:
    `NamingException` - thrown if an error occurs when initializing the default context

### JNDIConfiguration

    public JNDIConfiguration(String prefix)
                      throws NamingException

  Creates a JNDIConfiguration using the default initial context, shifted with the specified prefix, as the root of the properties.

  Parameters:
    `prefix` - the prefix
  Throws:
    `NamingException` - thrown if an error occurs when initializing the default context

### JNDIConfiguration

    public JNDIConfiguration(Context context)

  Creates a JNDIConfiguration using the specified initial context as the root of the properties.

  Parameters:
    `context` - the initial context

### JNDIConfiguration

    public JNDIConfiguration(Context context,
                             String prefix)

  Creates a JNDIConfiguration using the specified initial context shifted by the specified prefix as the root of the properties.

  Parameters:
    `context` - the initial context
    `prefix` - the prefix

Method Detail

### getKeys

    public Iterator getKeys()

  Returns an iterator with all property keys stored in this configuration.

  Specified by:
    `getKeys` in interface `Configuration`
  Specified by:
    `getKeys` in class `AbstractConfiguration`
  Returns:
    an iterator with all keys

### getKeys

    public Iterator getKeys(String prefix)

  Returns an iterator with all property keys starting with the given prefix.

  Specified by:
    `getKeys` in interface `Configuration`
  Overrides:
    `getKeys` in class `AbstractConfiguration`
  Parameters:
    `prefix` - the prefix
  Returns:
    an iterator with the selected keys
  See Also:
    `Configuration.getKeys()`

### isEmpty

    public boolean isEmpty()

  Returns a flag whether this configuration is empty.

  Specified by:
    `isEmpty` in interface `Configuration`
  Specified by:
    `isEmpty` in class `AbstractConfiguration`
  Returns:
    the empty flag

### setProperty

    public void setProperty(String key,
                            Object value)

  This operation is not supported and will throw an UnsupportedOperationException.

  Specified by:
    `setProperty` in interface `Configuration`
  Overrides:
    `setProperty` in class `AbstractConfiguration`
  Parameters:
    `key` - the key
    `value` - the value
  Throws:
    `UnsupportedOperationException`

### clearProperty

    public void clearProperty(String key)

  Removes the specified property.

  Specified by:
    `clearProperty` in interface `Configuration`
  Overrides:
    `clearProperty` in class `AbstractConfiguration`
  Parameters:
    `key` - the key of the property to remove

### containsKey

    public boolean containsKey(String key)

  Checks whether the specified key is contained in this configuration.

  Specified by:
    `containsKey` in interface `Configuration`
  Specified by:
    `containsKey` in class `AbstractConfiguration`
  Parameters:
    `key` - the key to check
  Returns:
    a flag whether this key is stored in this configuration

### getPrefix

    public String getPrefix()

  Returns the prefix.

  Returns:
    the prefix

### setPrefix

    public void setPrefix(String prefix)

  Sets the prefix.

  Parameters:
    `prefix` - The prefix to set

### getProperty

    public Object getProperty(String key)

  Returns the value of the specified property.

  Parameters:
    `key` - the key of the property
  Returns:
    the value of this property

### addPropertyDirect

    protected void addPropertyDirect(String key,
                                     Object obj)

  This operation is not supported and will throw an UnsupportedOperationException.

  Specified by:
    `addPropertyDirect` in class `AbstractConfiguration`
  Parameters:
    `key` - the key
    `obj` - the value
  Throws:
    `UnsupportedOperationException`

### getBaseContext

    public Context getBaseContext()
                           throws NamingException

  Return the base context with the prefix applied.

  Returns:
    the base context
  Throws:
    `NamingException` - if an error occurs

### getContext

    public Context getContext()

  Return the initial context used by this configuration. This context is independent of the prefix specified.

  Returns:
    the initial context

### setContext

    public void setContext(Context context)

  Set the initial context of the configuration.

  Parameters:
    `context` - the context

Copyright © 2001-2006 The Apache Software Foundation. All Rights Reserved.