Class ServletRequestConfiguration
- java.lang.Object
-
- org.apache.commons.configuration.event.EventSource
-
- org.apache.commons.configuration.AbstractConfiguration
-
- org.apache.commons.configuration.web.ServletRequestConfiguration
-
- All Implemented Interfaces:
Configuration
public class ServletRequestConfiguration extends AbstractConfiguration
A configuration wrapper to read the parameters of a servlet request. This configuration is read only, adding or removing a property will throw an UnsupportedOperationException.- Since:
- 1.1
- Version:
- $Id: ServletRequestConfiguration.java 1211131 2011-12-06 20:57:37Z oheger $
- Author:
- Emmanuel Bourg
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.servlet.ServletRequest
request
Stores the wrapped request.-
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN
-
-
Constructor Summary
Constructors Constructor Description ServletRequestConfiguration(javax.servlet.ServletRequest request)
Create a ServletRequestConfiguration using the request parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addPropertyDirect(java.lang.String key, java.lang.Object obj)
Adds a property to this configuration.void
clearProperty(java.lang.String key)
Removes the property with the given key.boolean
containsKey(java.lang.String key)
Checks whether the specified key is stored in this configuration.java.util.Iterator<java.lang.String>
getKeys()
Get the list of the keys contained in the configuration.java.lang.Object
getProperty(java.lang.String key)
Gets a property from the configuration.protected java.lang.Object
handleDelimiters(java.lang.Object value)
Takes care of list delimiters in property values.boolean
isEmpty()
Checks if this configuration is empty.-
Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
addErrorLogListener, addProperty, append, clear, clearPropertyDirect, copy, createInterpolator, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getList, getList, getListDelimiter, getLogger, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, getSubstitutor, interpolate, interpolate, interpolatedConfiguration, interpolateHelper, isDelimiterParsingDisabled, isScalarValue, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, setLogger, setProperty, setThrowExceptionOnMissing, subset
-
Methods inherited from class org.apache.commons.configuration.event.EventSource
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, clone, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents
-
-
-
-
Method Detail
-
getProperty
public java.lang.Object getProperty(java.lang.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 theConfiguration
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 theConfiguration
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 java.util.Iterator<java.lang.String> getKeys()
Description copied from interface:Configuration
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'sremove()
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 callingConfiguration.clearProperty(String)
for this property. So it is highly recommended to avoid using the iterator'sremove()
method.- Returns:
- An Iterator.
-
isEmpty
public boolean isEmpty()
Checks if this configuration is empty. This implementation makes use of thegetKeys()
method (which must be defined by concrete sub classes) to find out whether properties exist.- Returns:
- a flag whether this configuration is empty
-
containsKey
public boolean containsKey(java.lang.String key)
Checks whether the specified key is stored in this configuration.- Parameters:
key
- the key- Returns:
- a flag whether this key exists in this configuration
-
clearProperty
public void clearProperty(java.lang.String key)
Removes the property with the given key. This operation is not supported and will throw an UnsupportedOperationException.- Specified by:
clearProperty
in interfaceConfiguration
- Overrides:
clearProperty
in classAbstractConfiguration
- Parameters:
key
- the key of the property to be removed- Throws:
java.lang.UnsupportedOperationException
- because this operation is not allowed
-
addPropertyDirect
protected void addPropertyDirect(java.lang.String key, java.lang.Object obj)
Adds a property to this configuration. This operation is not supported and will throw an UnsupportedOperationException.- Specified by:
addPropertyDirect
in classAbstractConfiguration
- Parameters:
key
- the key of the propertyobj
- the value to be added- Throws:
java.lang.UnsupportedOperationException
- because this operation is not allowed
-
handleDelimiters
protected java.lang.Object handleDelimiters(java.lang.Object value)
Takes care of list delimiters in property values. This method checks if delimiter parsing is enabled and the passed in value contains a delimiter character. If this is the case, a split operation is performed.- Parameters:
value
- the property value to be examined- Returns:
- the processed value
-
-