org.apache.commons.configuration.web
Class ServletConfiguration

java.lang.Object
  extended byorg.apache.commons.configuration.event.EventSource
      extended byorg.apache.commons.configuration.AbstractConfiguration
          extended byorg.apache.commons.configuration.web.BaseWebConfiguration
              extended byorg.apache.commons.configuration.web.ServletConfiguration
All Implemented Interfaces:
Configuration

public class ServletConfiguration
extends BaseWebConfiguration

A configuration wrapper around a ServletConfig. This configuration is read only, adding or removing a property will throw an UnsupportedOperationException.

Since:
1.1
Version:
$Revision: 439648 $, $Date: 2006-09-02 22:42:10 +0200 (Sa, 02 Sep 2006) $
Author:
Emmanuel Bourg

Field Summary
protected  ServletConfig config
          Stores a reference to the wrapped ServletConfig.
 
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
ServletConfiguration(Servlet servlet)
          Create a ServletConfiguration using the initialization parameter of the specified servlet.
ServletConfiguration(ServletConfig config)
          Create a ServletConfiguration using the servlet initialization parameters.
 
Method Summary
protected  void addPropertyDirect(String key, Object obj)
          Adds a property to this configuration.
 void clearProperty(String key)
          Removes the property with the given key.
 boolean containsKey(String key)
          Checks whether the specified key is stored in this configuration.
 Iterator getKeys()
          Get the list of the keys contained in the configuration. The returned iterator can be used to obtain all defined keys. Note that the exact behavior of the iterator's remove() method is specific to a concrete implementation. It may remove the corresponding property from the configuration, but this is not guaranteed. In any case it is no replacement for calling Configuration.clearProperty(String) for this property. So it is highly recommended to avoid using the iterator's remove() method.
 Object getProperty(String key)
          Gets a property from the configuration.
 boolean isEmpty()
          Checks if this configuration is empty.
 
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, getKeys, getList, getList, getListDelimiter, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, interpolate, interpolate, interpolateHelper, isDelimiterParsingDisabled, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, setProperty, 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
 

Field Detail

config

protected ServletConfig config
Stores a reference to the wrapped ServletConfig.

Constructor Detail

ServletConfiguration

public ServletConfiguration(Servlet servlet)
Create a ServletConfiguration using the initialization parameter of the specified servlet.

Parameters:
servlet - the servlet

ServletConfiguration

public ServletConfiguration(ServletConfig config)
Create a ServletConfiguration using the servlet initialization parameters.

Parameters:
config - the servlet configuration
Method Detail

getProperty

public Object getProperty(String key)
Description copied from interface: Configuration
Gets a property from the configuration. This is the most basic get method for retrieving values of properties. In a typical implementation of the Configuration interface the other get methods (that return specific data types) will internally make use of this method. On this level variable substitution is not yet performed. The returned object is an internal representation of the property value for the passed in key. It is owned by the Configuration object. So a caller should not modify this object. It cannot be guaranteed that this object will stay constant over time (i.e. further update operations on the configuration may change its internal state).

Parameters:
key - property to retrieve
Returns:
the value to which this configuration maps the specified key, or null if the configuration contains no mapping for this key.

getKeys

public Iterator getKeys()
Description copied from class: AbstractConfiguration
Get the list of the keys contained in the configuration. The returned iterator can be used to obtain all defined keys. Note that the exact behavior of the iterator's remove() method is specific to a concrete implementation. It may remove the corresponding property from the configuration, but this is not guaranteed. In any case it is no replacement for calling Configuration.clearProperty(String) for this property. So it is highly recommended to avoid using the iterator's remove() method.

Specified by:
getKeys in interface Configuration
Specified by:
getKeys in class AbstractConfiguration

isEmpty

public boolean isEmpty()
Checks if this configuration is empty. This implementation makes use of the getKeys() method (which must be defined by concrete sub classes) to find out whether properties exist.

Specified by:
isEmpty in interface Configuration
Specified by:
isEmpty in class AbstractConfiguration
Returns:
a flag whether this configuration is empty

containsKey

public boolean containsKey(String key)
Checks whether the specified key is stored in this configuration.

Specified by:
containsKey in interface Configuration
Specified by:
containsKey in class AbstractConfiguration
Parameters:
key - the key
Returns:
a flag whether this key exists in this configuration

clearProperty

public void clearProperty(String key)
Removes the property with the given key. This operation is not supported and will throw an UnsupportedOperationException.

Specified by:
clearProperty in interface Configuration
Overrides:
clearProperty in class AbstractConfiguration
Parameters:
key - the key of the property to be removed
Throws:
UnsupportedOperationException - because this operation is not allowed

addPropertyDirect

protected void addPropertyDirect(String key,
                                 Object obj)
Adds a property to this configuration. This operation is not supported and will throw an UnsupportedOperationException.

Specified by:
addPropertyDirect in class AbstractConfiguration
Parameters:
key - the key of the property
obj - the value to be added
Throws:
UnsupportedOperationException - because this operation is not allowed


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