com.planetalia.dynject.sources
Class HttpRequestSource

java.lang.Object
  extended by com.planetalia.dynject.sources.HttpRequestSource
All Implemented Interfaces:
IValueSource

public class HttpRequestSource
extends java.lang.Object
implements IValueSource

Retrieves property values from the parameters sent with a HTTP request

Author:
Alexander Hristov

Constructor Summary
HttpRequestSource(javax.servlet.http.HttpServletRequest request)
          Constructs a source using the specified HTTP request
HttpRequestSource(javax.servlet.http.HttpServletRequest request, java.lang.String parameterNamePrefix)
          Constructs a source using the specified HTTP request and a prefix that is prepended to all property names before considering them parameter names
 
Method Summary
 ClassPreferences getPropertyClass(java.lang.String propertyName)
          Returns the class preferences for a property
 java.util.Set getPropertyNames()
          Returns the set of all existing properties at the time of invocation.
 java.lang.Object getValue(java.lang.String propertyName)
          Provides the value of a specific property
 boolean propertyExists(java.lang.String propertyName)
          Checks whether a specific property exists.
 void setValue(java.lang.String propertyName, java.lang.Object value)
          Sets the value of a specific property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpRequestSource

public HttpRequestSource(javax.servlet.http.HttpServletRequest request)
Constructs a source using the specified HTTP request

Parameters:
request - HTTP request from which the parameters are going to be extracted

HttpRequestSource

public HttpRequestSource(javax.servlet.http.HttpServletRequest request,
                         java.lang.String parameterNamePrefix)
Constructs a source using the specified HTTP request and a prefix that is prepended to all property names before considering them parameter names

Parameters:
request - HTTP request from which the parameters are going to be extracted
parameterNamePrefix - Prefix to prepend to the property name
Method Detail

getPropertyClass

public ClassPreferences getPropertyClass(java.lang.String propertyName)
Description copied from interface: IValueSource
Returns the class preferences for a property

Specified by:
getPropertyClass in interface IValueSource
Parameters:
propertyName - Name of the property
Returns:
List of class preferences for that property

getPropertyNames

public java.util.Set getPropertyNames()
Description copied from interface: IValueSource
Returns the set of all existing properties at the time of invocation.

Specified by:
getPropertyNames in interface IValueSource
Returns:
Set of property names

getValue

public java.lang.Object getValue(java.lang.String propertyName)
Description copied from interface: IValueSource
Provides the value of a specific property

Specified by:
getValue in interface IValueSource
Parameters:
propertyName - Name of the requested property. Assumed to exist.
Returns:
Property value

propertyExists

public boolean propertyExists(java.lang.String propertyName)
Description copied from interface: IValueSource
Checks whether a specific property exists. Not that a nonexistant property and a proprerty with a null value are not the same situation

Specified by:
propertyExists in interface IValueSource
Parameters:
propertyName - Name of the requested property
Returns:
True if the property exists, false otherwise

setValue

public void setValue(java.lang.String propertyName,
                     java.lang.Object value)
Description copied from interface: IValueSource
Sets the value of a specific property. It's the callers responsability to provide a correct data type for that property. This is an optional operation. Some sources do not support writing properties to them

Specified by:
setValue in interface IValueSource
Parameters:
propertyName - Name of the requested property.
value - Property value.