com.elasticpath.sfweb.util
Interface RequestHelper

All Known Implementing Classes:
RequestHelperImpl

public interface RequestHelper

RequestHelper represents a helper instance for http requests.


Method Summary
 java.lang.String getCookieValue(javax.servlet.http.HttpServletRequest request, java.lang.String cookieName)
          Returns the value of a cookie with the specified name.
 ElasticPath getElasticPath()
          Get the ElasticPath singleton.
 int getIntParameterOrAttribute(javax.servlet.http.HttpServletRequest request, java.lang.String name, int defaultVal)
          Get an int parameter or attribute, with a fallback value.
 java.lang.Long getLongParameter(javax.servlet.http.HttpServletRequest request, java.lang.String parameterName)
          Retrieve the given parameter as Long from the given request.
 ShoppingCart getShoppingCart(javax.servlet.http.HttpServletRequest request)
          Return a ShoppingCart instance if there is one stored in http session.
 java.lang.String getStringParameterOrAttribute(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.String defaultVal)
          Get a string parameter or attribute, with a fallback value.
 java.lang.String getUrl(javax.servlet.http.HttpServletRequest request)
          Retrive the absolute url from the given request.
 void setElasticPath(ElasticPath elasticpath)
          Inject the ElasticPath singleton.
 void setShoppingCart(javax.servlet.http.HttpServletRequest request, ShoppingCart shoppingCart)
          Set a ShoppingCart into http sessino.
 

Method Detail

getCookieValue

java.lang.String getCookieValue(javax.servlet.http.HttpServletRequest request,
                                java.lang.String cookieName)
Returns the value of a cookie with the specified name.

Parameters:
request - The Http request to retrieve cookies from
cookieName - The name of the cookie to be retrieved
Returns:
the value of the cookie as a string

getElasticPath

ElasticPath getElasticPath()
Get the ElasticPath singleton.

Returns:
elasticpath the ElasticPath singleton.

getIntParameterOrAttribute

int getIntParameterOrAttribute(javax.servlet.http.HttpServletRequest request,
                               java.lang.String name,
                               int defaultVal)
Get an int parameter or attribute, with a fallback value. Never throws an exception. Can pass a distinguished value as default to enable checks of whether it was supplied.

Parameters:
request - current HTTP request
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the int value of parameter or attribute if it exists, otherwise, returns a fallback value

getLongParameter

java.lang.Long getLongParameter(javax.servlet.http.HttpServletRequest request,
                                java.lang.String parameterName)
                                throws EpRequestParameterBindingException
Retrieve the given parameter as Long from the given request.

Parameters:
request - the request
parameterName - the parameter name
Returns:
a Long type instance if the parameter is set, otherwise null
Throws:
EpRequestParameterBindingException - if the parameter value isn't a number.

getShoppingCart

ShoppingCart getShoppingCart(javax.servlet.http.HttpServletRequest request)
Return a ShoppingCart instance if there is one stored in http session. Otherwise, create a new one and return it.

Parameters:
request - the http request
Returns:
a ShoppingCart instance

getStringParameterOrAttribute

java.lang.String getStringParameterOrAttribute(javax.servlet.http.HttpServletRequest request,
                                               java.lang.String name,
                                               java.lang.String defaultVal)
Get a string parameter or attribute, with a fallback value. Never throws an exception.

Parameters:
request - current HTTP request
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the int value of parameter or attribute if it exists, otherwise, returns a fallback value

getUrl

java.lang.String getUrl(javax.servlet.http.HttpServletRequest request)
Retrive the absolute url from the given request.

Parameters:
request - the request
Returns:
the absolute url

setElasticPath

void setElasticPath(ElasticPath elasticpath)
Inject the ElasticPath singleton.

Parameters:
elasticpath - the ElasticPath singleton.

setShoppingCart

void setShoppingCart(javax.servlet.http.HttpServletRequest request,
                     ShoppingCart shoppingCart)
Set a ShoppingCart into http sessino.

Parameters:
request - the http request
shoppingCart - the shopping cart to save