com.google.code.rees.scope.session
Class SessionUtil

java.lang.Object
  extended by com.google.code.rees.scope.session.SessionUtil

public class SessionUtil
extends Object

A utility class that provides static methods that are used internally and for unit testing. Use outside of these contexts should come only as a last resort.

Author:
rees.byars

Constructor Summary
SessionUtil()
           
 
Method Summary
static String buildKey(String name, Class<?> clazz)
          Given the name of a session-scoped field and its class, this method returns the appropriate key that is used to identify instances of the field in the session-field map.
static void extractFields(Object target)
          The current values of session fields annotated with SessionField are extracted from the target object and placed into the session.
static
<T> T
getField(String name, Class<T> clazz)
          Given a session field's name and class, the value of the field is returned from the session.
protected static String getSessionFieldName(Field field)
          Returns the name of the given field's SessionField
static void injectFields(Object target)
          The target object's session fields that are annotated with SessionField are injected from the session.
static void setField(String name, Object sessionField)
          Given a session field's name and an instance, the value is set for the field in the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionUtil

public SessionUtil()
Method Detail

buildKey

public static String buildKey(String name,
                              Class<?> clazz)
Given the name of a session-scoped field and its class, this method returns the appropriate key that is used to identify instances of the field in the session-field map.

Parameters:
name -
clazz -
Returns:

getField

public static <T> T getField(String name,
                             Class<T> clazz)
Given a session field's name and class, the value of the field is returned from the session.

Type Parameters:
T -
Parameters:
name -
clazz -
Returns:

setField

public static void setField(String name,
                            Object sessionField)
Given a session field's name and an instance, the value is set for the field in the session.

Parameters:
fieldName -
fieldValue -

extractFields

public static void extractFields(Object target)
The current values of session fields annotated with SessionField are extracted from the target object and placed into the session. No caching is performed, for use only in unit testing.

Parameters:
target -

injectFields

public static void injectFields(Object target)
The target object's session fields that are annotated with SessionField are injected from the session. No caching is performed, for use only in unit testing.

Parameters:
target -

getSessionFieldName

protected static String getSessionFieldName(Field field)
Returns the name of the given field's SessionField

Parameters:
field -
Returns:


Copyright © 2012-2013. All Rights Reserved.