Package helma.framework

# Class RequestTrans

java.lang.Object
helma.framework.RequestTrans

All Implemented Interfaces:
  `Serializable`

public class RequestTrans extends Object implements Serializable
A Transmitter for a request from the servlet client. Objects of this class are directly exposed to JavaScript as global property req.

See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DELETE`
`static final String`
`EXTERNAL`
`static final String`
`GET`
`static final String`
`HEAD`
`static final String`
`INTERNAL`
`static final String`
`OPTIONS`
`static final String`
`POST`
`static final String`
`PUT`
`static final String`
`TRACE`
`static final String`
`XMLRPC`

## Constructor Summary

Constructors
Constructor
Description
`RequestTrans(String method, String path)`
Create a new Request transmitter with an empty data map.
`RequestTrans(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String path)`
Create a new request transmitter with the given data map.

## Method Summary

Modifier and Type
Method
Description
`void`
`addPostParam(String name, Object value)`
Add a post parameter to the request
`boolean`
`checkXmlRpc()`
Return true if we should try to handle this as XML-RPC request.
`boolean`
`equals(Object what)`
A request is considered equal to another one if it has the same method, path, session, request data, and conditional get data.
`Object`
`get(String name)`
Get a value from the requests map by key.
`String`
`getAction()`
Get the request's action.
`Object`
`getActionHandler()`
Get the request's action handler.
`Map`
`getCookies()`
`long`
`getDateHeader(String name)`
Proxy to HttpServletRequest.getDateHeader(), fails silently by returning -1.
`Set`
`getETags()`
`String`
`getHeader(String name)`
Proxy to HttpServletRequest.getHeader().
`String[]`
`getHeaders(String name)`
Proxy to HttpServletRequest.getHeaders(), returns header values as string array.
`long`
`getIfModifiedSince()`
`int`
`getIntHeader(String name)`
Proxy to HttpServletRequest.getIntHeader(), fails silently by returning -1.
`String`
`getMethod()`
Return the method of the request.
`Map`
`getParams()`
`String`
`getPassword()`
`String`
`getPath()`
Get the request's path
`Map`
`getPostParams()`
`Map`
`getQueryParams()`
`Map`
`getRequestData()`
Get the data map for this request transmitter.
`javax.servlet.http.HttpServletRequest`
`getServletRequest()`
Returns the Servlet request represented by this RequestTrans instance.
`javax.servlet.http.HttpServletResponse`
`getServletResponse()`
Returns the Servlet response for this request.
`String`
`getSession()`
Get the request's session id
`long`
`getStartTime()`
Get the time the request was created.
`String`
`getUri()`
Get the request's path
`String`
`getUsername()`
`boolean`
`hasETag(String etag)`
`int`
`hashCode()`
The hash code is computed from the session id if available.
`boolean`
`isGet()`
Return true if this object represents a HTTP GET Request.
`boolean`
`isPost()`
Return true if this object represents a HTTP GET Request.
`boolean`
`isXmlRpc()`
Return true if this request is in fact handled as XML-RPC request.
`void`
`set(String name, Object value)`
Set a parameter value in this request transmitter.
`void`
`setAction(String action)`
Set the request's action.
`void`
`setActionHandler(Object handler)`
Set the request's action handler.
`void`
`setCookie(String name, javax.servlet.http.Cookie cookie)`
Set a cookie
`void`
`setETags(String etagHeader)`
`void`
`setIfModifiedSince(long since)`
`void`
`setMethod(String method)`
Set the method of this request.
`void`
`setParameters(Map parameters, boolean isPost)`
set the request parameters
`void`
`setSession(String session)`
Set the request's session id
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### GET

public static final String GET

See Also:
  - Constant Field Values

### POST

public static final String POST

See Also:
  - Constant Field Values

### DELETE

public static final String DELETE

See Also:
  - Constant Field Values

### HEAD

public static final String HEAD

See Also:
  - Constant Field Values

### OPTIONS

public static final String OPTIONS

See Also:
  - Constant Field Values

### PUT

public static final String PUT

See Also:
  - Constant Field Values

### TRACE

public static final String TRACE

See Also:
  - Constant Field Values

### XMLRPC

public static final String XMLRPC

See Also:
  - Constant Field Values

### EXTERNAL

public static final String EXTERNAL

See Also:
  - Constant Field Values

### INTERNAL

public static final String INTERNAL

See Also:
  - Constant Field Values

## Constructor Details

### RequestTrans

public RequestTrans(String method, String path)
Create a new Request transmitter with an empty data map.

### RequestTrans

public RequestTrans(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String path)
Create a new request transmitter with the given data map.

## Method Details

### checkXmlRpc

public boolean checkXmlRpc()
Return true if we should try to handle this as XML-RPC request.

Returns:
  true if this might be an XML-RPC request.

### isXmlRpc

public boolean isXmlRpc()
Return true if this request is in fact handled as XML-RPC request. This implies that `checkXmlRpc()` returns true and a matching XML-RPC action was found.

Returns:
  true if this request is handled as XML-RPC request.

### setCookie

public void setCookie(String name, javax.servlet.http.Cookie cookie)
Set a cookie

Parameters:
  `name` - the cookie name
  `cookie` - the cookie

### getCookies

public Map getCookies()

Returns:
  a map containing the cookies sent with this request

### getParams

public Map getParams()

Returns:
  the combined query and post parameters for this request

### getQueryParams

public Map getQueryParams()

Returns:
  get the query parameters for this request

### getPostParams

public Map getPostParams()

Returns:
  get the post parameters for this request

### setParameters

public void setParameters(Map parameters, boolean isPost)
set the request parameters

### addPostParam

public void addPostParam(String name, Object value)
Add a post parameter to the request

Parameters:
  `name` - the parameter name
  `value` - the parameter value

### set

public void set(String name, Object value)
Set a parameter value in this request transmitter. This parses foo[bar][baz] as nested objects/maps.

### get

public Object get(String name)
Get a value from the requests map by key.

### getRequestData

public Map getRequestData()
Get the data map for this request transmitter.

### getServletRequest

public javax.servlet.http.HttpServletRequest getServletRequest()
Returns the Servlet request represented by this RequestTrans instance. Returns null for internal and XML-RPC requests.

### getHeader

public String getHeader(String name)
Proxy to HttpServletRequest.getHeader().

Parameters:
  `name` - the header name
Returns:
  the header value, or null

### getHeaders

public String[] getHeaders(String name)
Proxy to HttpServletRequest.getHeaders(), returns header values as string array.

Parameters:
  `name` - the header name
Returns:
  the header values as string array

### getIntHeader

public int getIntHeader(String name)
Proxy to HttpServletRequest.getIntHeader(), fails silently by returning -1.

Parameters:
  `name` - the header name
Returns:
  the header parsed as integer or -1

### getDateHeader

public long getDateHeader(String name)
Proxy to HttpServletRequest.getDateHeader(), fails silently by returning -1.

Parameters:
  `name` - the header name
Returns:
  the date in milliseconds, or -1

### getServletResponse

public javax.servlet.http.HttpServletResponse getServletResponse()
Returns the Servlet response for this request. Returns null for internal and XML-RPC requests.

### hashCode

public int hashCode()
The hash code is computed from the session id if available. This is used to detect multiple identic requests.

Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object what)
A request is considered equal to another one if it has the same method, path, session, request data, and conditional get data. This is used to evaluate multiple simultanous identical requests only once.

Overrides:
  `equals` in class `Object`

### getMethod

public String getMethod()
Return the method of the request. This may either be a HTTP method or one of the Helma pseudo methods defined in this class.

### setMethod

public void setMethod(String method)
Set the method of this request.

Parameters:
  `method` - the method.

### isGet

public boolean isGet()
Return true if this object represents a HTTP GET Request.

### isPost

public boolean isPost()
Return true if this object represents a HTTP GET Request.

### getSession

public String getSession()
Get the request's session id

### setSession

public void setSession(String session)
Set the request's session id

### getPath

public String getPath()
Get the request's path

### getUri

public String getUri()
Get the request's path

### getAction

public String getAction()
Get the request's action.

### setAction

public void setAction(String action)
Set the request's action.

### getActionHandler

public Object getActionHandler()
Get the request's action handler. The action handler allows the onRequest() method to set the function object to be invoked for processing the request, overriding the action resolved from the request path.

Returns:
  the action handler function

### setActionHandler

public void setActionHandler(Object handler)
Set the request's action handler. The action handler allows the onRequest() method to set the function object to be invoked for processing the request, overriding the action resolved from the request path.

Parameters:
  `handler` - the action handler

### getStartTime

public long getStartTime()
Get the time the request was created.

### setIfModifiedSince

public void setIfModifiedSince(long since)

Parameters:
  `since` - ...

### getIfModifiedSince

public long getIfModifiedSince()

Returns:
  ...

### setETags

public void setETags(String etagHeader)

Parameters:
  `etagHeader` - ...

### getETags

public Set getETags()

Returns:
  ...

### hasETag

public boolean hasETag(String etag)

Parameters:
  `etag` - ...
Returns:
  ...

### getUsername

public String getUsername()

Returns:
  ...

### getPassword

public String getPassword()

Returns:
  ...

### toString

public String toString()

Overrides:
  `toString` in class `Object`