org.apache.fulcrum.parser
Class DefaultCookieParser

java.lang.Object
  extended by org.apache.fulcrum.parser.BaseValueParser
      extended by org.apache.fulcrum.parser.DefaultCookieParser
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled, CookieParser, ParserServiceSupport, ValueParser, org.apache.fulcrum.pool.Recyclable

public class DefaultCookieParser
extends BaseValueParser
implements CookieParser

CookieParser is used to get and set values of Cookies on the Client Browser. You can use CookieParser to convert Cookie values to various types or to set Bean values with setParameters(). See the Servlet Spec for more information on Cookies.

Use set() or unset() to Create or Destroy Cookies.

NOTE: The name= portion of a name=value pair may be converted to lowercase or uppercase when the object is initialized and when new data is added. This behaviour is determined by the url.case.folding property in TurbineResources.properties. Adding a name/value pair may overwrite existing name=value pairs if the names match:

 CookieParser cp = data.getCookies();
 cp.add("ERROR",1);
 cp.add("eRrOr",2);
 int result = cp.getInt("ERROR");
 
In the above example, result is 2.

Version:
$Id: DefaultCookieParser.java 812786 2009-09-09 07:01:49Z tv $
Author:
Ilkka Priha, Leon Messerschmidt, Thomas Vandahl

Field Summary
 
Fields inherited from class org.apache.fulcrum.parser.BaseValueParser
parameters, parserService
 
Fields inherited from interface org.apache.fulcrum.parser.CookieParser
AGE_DELETE, AGE_SESSION
 
Fields inherited from interface org.apache.fulcrum.parser.ValueParser
DEFAULT_CHARACTER_ENCODING
 
Constructor Summary
DefaultCookieParser()
          Constructs a new CookieParser.
 
Method Summary
 void dispose()
          Disposes the parser.
 javax.servlet.http.HttpServletRequest getRequest()
          Gets the servlet request.
 void set(String name, String value)
          Set a cookie that will be stored on the client for the duration of the session.
 void set(String name, String value, int seconds_age)
          Set a persisten cookie on the client that will expire after a maximum age (given in seconds).
 void setData(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Sets the servlet request and response to be parsed.
 void unset(String name)
          Remove a previously set cookie from the client machine.
 
Methods inherited from class org.apache.fulcrum.parser.BaseValueParser
add, add, add, add, add, add, clear, containsKey, convert, convertAndTrim, convertAndTrim, enableLogging, get, getBigDecimal, getBigDecimal, getBigDecimals, getBoolean, getBoolean, getBooleanObject, getBooleanObject, getBooleanObjects, getBooleans, getByte, getByte, getByteObject, getByteObject, getBytes, getCharacterEncoding, getDate, getDate, getDate, getDateFormat, getDouble, getDouble, getDoubleObject, getDoubleObject, getDoubleObjects, getDoubles, getFloat, getFloat, getFloatObject, getFloatObject, getFloatObjects, getFloats, getInt, getInt, getIntObject, getIntObject, getIntObjects, getInts, getKeys, getLocale, getLogger, getLong, getLong, getLongObject, getLongObject, getLongObjects, getLongs, getNumberFormat, getObject, getObjects, getParam, getString, getString, getStrings, getStrings, getToStringParam, getUrlFolding, isDisposed, keySet, putParam, recycle, recycle, remove, setCharacterEncoding, setDateFormat, setLocale, setNumberFormat, setParserService, setProperties, setProperty, setString, setStrings, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.fulcrum.parser.ValueParser
add, add, add, add, add, add, clear, containsKey, convert, convertAndTrim, convertAndTrim, get, getBigDecimal, getBigDecimal, getBigDecimals, getBoolean, getBoolean, getBooleanObject, getBooleanObject, getBooleanObjects, getBooleans, getByte, getByte, getByteObject, getByteObject, getBytes, getCharacterEncoding, getDate, getDate, getDate, getDateFormat, getDouble, getDouble, getDoubleObject, getDoubleObject, getDoubleObjects, getDoubles, getFloat, getFloat, getFloatObject, getFloatObject, getFloatObjects, getFloats, getInt, getInt, getIntObject, getIntObject, getIntObjects, getInts, getKeys, getLocale, getLong, getLong, getLongObject, getLongObject, getLongObjects, getLongs, getNumberFormat, getObject, getObjects, getString, getString, getStrings, getStrings, getUrlFolding, keySet, remove, setCharacterEncoding, setDateFormat, setLocale, setNumberFormat, setProperties, setString, setStrings, toString
 

Constructor Detail

DefaultCookieParser

public DefaultCookieParser()
Constructs a new CookieParser.

Method Detail

dispose

public void dispose()
Disposes the parser.

Specified by:
dispose in interface org.apache.fulcrum.pool.Recyclable
Overrides:
dispose in class BaseValueParser

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Gets the servlet request.

Specified by:
getRequest in interface CookieParser
Returns:
the servlet request object or null.

setData

public void setData(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response)
Sets the servlet request and response to be parsed. All previous cookies will be cleared.

Specified by:
setData in interface CookieParser
Parameters:
request - the servlet request object.
response - the servlet response object

set

public void set(String name,
                String value)
Set a cookie that will be stored on the client for the duration of the session.

Specified by:
set in interface CookieParser

set

public void set(String name,
                String value,
                int seconds_age)
Set a persisten cookie on the client that will expire after a maximum age (given in seconds).

Specified by:
set in interface CookieParser

unset

public void unset(String name)
Remove a previously set cookie from the client machine.

Specified by:
unset in interface CookieParser


Copyright © 2005-2009 The Apache Software Foundation. All Rights Reserved.