velosurf.util
Class UserContext

java.lang.Object
  extended by velosurf.util.UserContext

public class UserContext
extends java.lang.Object

Used to store contextual values relatives to the user (in a web context, there is one UserContext per http session).

Author:
Claude Brisson

Field Summary
private  java.lang.String error
          last error message
private  java.util.Map<Entity,java.lang.Long> lastInsertedIDs
          map of last inserted IDs
private  java.util.Locale locale
          locale
private  Localizer localizer
          localizer
static java.lang.String USER_CONTEXT_KEY
          key used to store the user context in the http session.
private  java.util.List<java.lang.String> validationErrors
          list of validation error messages
 
Constructor Summary
UserContext()
          Constructor.
 
Method Summary
 void addValidationError(java.lang.String err)
          Add a validation error.
 void clearValidationErrors()
          Clear validation errors.
 java.lang.Object get(java.lang.String key)
          generic getter.
 java.lang.String getError()
          Last error getter.
 long getLastInsertedID(Entity entity)
          Get the last inserted ID for an entity.
 java.util.Locale getLocale()
          Locale getter.
 java.util.List<java.lang.String> getValidationErrors()
          Get all validation error messages.
 java.lang.String localize(java.lang.String str, java.lang.Object... params)
          Localize a parameterized message.
 void setError(java.lang.String err)
          Last error setter.
 void setLastInsertedID(Entity entity, long id)
          Set the last inserted ID for an entity.
 void setLocale(java.util.Locale loc)
          Locale setter.
 void setLocalizer(Localizer loc)
          Localizer setter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_CONTEXT_KEY

public static final java.lang.String USER_CONTEXT_KEY
key used to store the user context in the http session.

See Also:
Constant Field Values

error

private java.lang.String error
last error message


validationErrors

private java.util.List<java.lang.String> validationErrors
list of validation error messages


localizer

private Localizer localizer
localizer


locale

private java.util.Locale locale
locale


lastInsertedIDs

private java.util.Map<Entity,java.lang.Long> lastInsertedIDs
map of last inserted IDs

Constructor Detail

UserContext

public UserContext()
Constructor.

Method Detail

setError

public void setError(java.lang.String err)
Last error setter.

Parameters:
err - error

getError

public java.lang.String getError()
Last error getter.

Returns:
last error message.

setLocalizer

public void setLocalizer(Localizer loc)
Localizer setter.

Parameters:
loc - localizer

setLocale

public void setLocale(java.util.Locale loc)
Locale setter.

Parameters:
loc - Locale

localize

public java.lang.String localize(java.lang.String str,
                                 java.lang.Object... params)
Localize a parameterized message.

Parameters:
str - message to localize
params - parameters that are meant to replace "{0}", "{1}", ... in the message
Returns:
localized message

clearValidationErrors

public void clearValidationErrors()
Clear validation errors.


addValidationError

public void addValidationError(java.lang.String err)
Add a validation error.

Parameters:
err - validation error

getValidationErrors

public java.util.List<java.lang.String> getValidationErrors()
Get all validation error messages.

Returns:
validation error messages

get

public java.lang.Object get(java.lang.String key)
generic getter.


getLocale

public java.util.Locale getLocale()
Locale getter.

Returns:
current locale

setLastInsertedID

public void setLastInsertedID(Entity entity,
                              long id)
Set the last inserted ID for an entity.

Parameters:
entity - entity
id - last inserted id

getLastInsertedID

public long getLastInsertedID(Entity entity)
Get the last inserted ID for an entity.

Parameters:
entity - entity
Returns:
last inserted ID of -1


~ooOoo~