net.contextfw.web.application.request
Class Request

java.lang.Object
  extended by net.contextfw.web.application.request.Request

public class Request
extends Object

Provides functionality to access and set GET/POST-parameters through consistent abstraction.

Request is an abstraction that provides a set of functionalities to extend the usage of GET/POST-parameters. It tries to make handling parameters more convinient.

Features and benefits

  1. Helps testing the application, because Request is an interface and can be replaced with test-requests.
  2. Provides an easy way to store parameters for further processing.

Author:
Marko Lavikainen

Field Summary
static String REQUEST_SEPARATOR
           
 
Constructor Summary
Request(javax.servlet.http.HttpServletRequest httpRequest)
          Sole constructor.
 
Method Summary
 RequestParameter param(String name)
          Fetches a parameter from page data with given name This method is the only way to create new parameters.
 RequestParameter param(String name, int index)
          Fetches a parameter from page data with given name and index This is a convience method to fetch parameters with numeral index.
 void reinitialize(javax.servlet.http.HttpServletRequest httpRequest)
           
 Request subRequest(String name)
           
 Request subRequest(String name, long defaultIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_SEPARATOR

public static final String REQUEST_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

Request

public Request(javax.servlet.http.HttpServletRequest httpRequest)
Sole constructor.

Method Detail

reinitialize

public void reinitialize(javax.servlet.http.HttpServletRequest httpRequest)

subRequest

public Request subRequest(String name)

subRequest

public Request subRequest(String name,
                          long defaultIndex)

param

public RequestParameter param(String name)
                       throws NullPointerException
Fetches a parameter from page data with given name

This method is the only way to create new parameters. If parameter does not yet exist, it is automatically created an returned. Otherwise already existing parameter is returned

If a parameter without a name is tried to be fetched, then exception is thrown.

Parameters:
name - Name of the parameter
Returns:
Newly created paremeter or existing on
Throws:
NullPointerException - Thrown is name is null.

param

public RequestParameter param(String name,
                              int index)
                       throws NullPointerException
Fetches a parameter from page data with given name and index

This is a convience method to fetch parameters with numeral index.

The index is simply appended to the end of the name for instance name2. Otherwise behaviour is same with the single name.

Parameters:
name - Name of the parameter
index - Index of the parameter
Returns:
Newly created paremeter or existing on
Throws:
NullPointerException - Thrown is name is null.


Copyright © 2010. All Rights Reserved.