com.jfw.web.util
Class LocaleCookie

java.lang.Object
  extended by com.jfw.web.util.LocaleCookie

public final class LocaleCookie
extends java.lang.Object

Manage locale cookie.


Field Summary
static int COOKIE_AGE_BROWSER
          Cookie exist until browser is closed.
static int COOKIE_DELETE
          Cookie is deleted.
static java.lang.String COOKIE_NAME
          Default locale cookie name.
static java.lang.String COOKIE_SEPARATOR
          Separator char for cookie values.
 
Constructor Summary
LocaleCookie()
           
 
Method Summary
static void delete(javax.servlet.http.HttpServletResponse response)
          Use method delete(javax.servlet.http.HttpServletResponse, java.lang.String).
static void delete(javax.servlet.http.HttpServletResponse response, java.lang.String cookieName)
          Delete locale cookie.
static java.util.Locale read(javax.servlet.http.HttpServletRequest request)
          Use method read(javax.servlet.http.HttpServletRequest, java.lang.String).
static java.util.Locale read(javax.servlet.http.HttpServletRequest request, java.lang.String cookieName)
          Read locale cookie.
static void write(javax.servlet.http.HttpServletResponse response, java.util.Locale locale)
          Use method write(javax.servlet.http.HttpServletResponse, java.util.Locale, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int).
static void write(javax.servlet.http.HttpServletResponse response, java.util.Locale locale, java.lang.String cookieName, java.lang.String cookieDomain, java.lang.String cookiePath, java.lang.String cookieSecure, int cookieAge)
          Write the locale cookie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COOKIE_NAME

public static final java.lang.String COOKIE_NAME
Default locale cookie name.

See Also:
Constant Field Values

COOKIE_AGE_BROWSER

public static final int COOKIE_AGE_BROWSER
Cookie exist until browser is closed.

See Also:
Constant Field Values

COOKIE_DELETE

public static final int COOKIE_DELETE
Cookie is deleted.

See Also:
Constant Field Values

COOKIE_SEPARATOR

public static final java.lang.String COOKIE_SEPARATOR
Separator char for cookie values.

See Also:
Constant Field Values
Constructor Detail

LocaleCookie

public LocaleCookie()
Method Detail

read

public static java.util.Locale read(javax.servlet.http.HttpServletRequest request,
                                    java.lang.String cookieName)
Read locale cookie.

Parameters:
request - an HttpServletRequest object.
cookieName - cookie name. If null COOKIE_NAME is used.
Returns:
a Locale object or null if locale cookie not found.

read

public static java.util.Locale read(javax.servlet.http.HttpServletRequest request)
Use method read(javax.servlet.http.HttpServletRequest, java.lang.String). The default value of parameter cookieName is COOKIE_NAME.


write

public static void write(javax.servlet.http.HttpServletResponse response,
                         java.util.Locale locale,
                         java.lang.String cookieName,
                         java.lang.String cookieDomain,
                         java.lang.String cookiePath,
                         java.lang.String cookieSecure,
                         int cookieAge)
Write the locale cookie.

Parameters:
response - an HttpServletResponse object.
locale - a Locale object.
cookieName - cookie name. If null COOKIE_NAME is used.
cookieDomain - cokie domain. If null is not used.
cookiePath - cokie path. If null is not used.
cookieSecure - cokie secure option. If null is not used.
cookieAge - cokie age. A integer value > 0 indicates the msecs before cookie expire. If value is COOKIE_AGE_BROWSER cookie is not stored and expire when browser is closed.

write

public static void write(javax.servlet.http.HttpServletResponse response,
                         java.util.Locale locale)
Use method write(javax.servlet.http.HttpServletResponse, java.util.Locale, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int).
The default value of parameter cookieName is COOKIE_NAME.
The default value of parameter cookieDomain is null.
The default value of parameter cookiePath is null.
The default value of parameter cookieSecure is null.
The default value of parameter cookieAge is COOKIE_AGE_BROWSER.


delete

public static void delete(javax.servlet.http.HttpServletResponse response,
                          java.lang.String cookieName)
Delete locale cookie.

Parameters:
response - an HttpServletResponse object.
cookieName - cookie name. If null COOKIE_NAME is used.

delete

public static void delete(javax.servlet.http.HttpServletResponse response)
Use method delete(javax.servlet.http.HttpServletResponse, java.lang.String).
The default value of parameter cookieName is COOKIE_NAME.

Parameters:
response - an HttpServletResponse object.