Weaver 3.1.0a1-D1

com.oldlight.weaver.clientbinding
Class WeaverAttributeUtil

java.lang.Object
  extended bycom.oldlight.weaver.clientbinding.WeaverAttributeUtil

public class WeaverAttributeUtil
extends Object

This is a utility class for dealing with scoped values (ala the EL). Methods are available to get, set and remove scoped values. You should use this class in your W-Beans to ensure consistent handling of scoped values.

Author:
Paul Harvey

Field Summary
static String[] ALL_SCOPES
           
static String SCOPE_APPLICATION
           
static String SCOPE_BEAN
           
static String SCOPE_LOCAL
           
static String SCOPE_REQUEST
           
static String SCOPE_SERVLET
           
static String SCOPE_SESSION
           
 
Constructor Summary
WeaverAttributeUtil()
           
 
Method Summary
static Object getAttribute(WeaverExecutionContext context, String paramName, String paramScope)
          Retrieve a scoped valued.
static void removeAttribute(WeaverExecutionContext context, String paramName, String paramScope)
          Remove a scoped value
static void setAttribute(WeaverExecutionContext context, String paramName, Object paramValue, String paramScope)
          Set a scoped value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCOPE_APPLICATION

public static final String SCOPE_APPLICATION
See Also:
Constant Field Values

SCOPE_SERVLET

public static final String SCOPE_SERVLET
See Also:
Constant Field Values

SCOPE_SESSION

public static final String SCOPE_SESSION
See Also:
Constant Field Values

SCOPE_REQUEST

public static final String SCOPE_REQUEST
See Also:
Constant Field Values

SCOPE_BEAN

public static final String SCOPE_BEAN
See Also:
Constant Field Values

SCOPE_LOCAL

public static final String SCOPE_LOCAL
See Also:
Constant Field Values

ALL_SCOPES

public static final String[] ALL_SCOPES
Constructor Detail

WeaverAttributeUtil

public WeaverAttributeUtil()
Method Detail

setAttribute

public static void setAttribute(WeaverExecutionContext context,
                                String paramName,
                                Object paramValue,
                                String paramScope)
                         throws WeaverException
Set a scoped value.

Parameters:
context - The context in which to set the value.
paramName - The name of the value to set.
paramValue - The actual value.
paramScope - The scope in which to set the value - taken from the SCOPE_* strings defined in this class.
Throws:
WeaverException - Thrown if the given scope is unknown.

removeAttribute

public static void removeAttribute(WeaverExecutionContext context,
                                   String paramName,
                                   String paramScope)
                            throws WeaverException
Remove a scoped value

Parameters:
context - The context from which to remove the value.
paramName - The name of the value to remove.
paramScope - The scope to remove the value from (if null the value is removed from all scopes).
Throws:
WeaverException - Thrown if the given scope is unknown.

getAttribute

public static Object getAttribute(WeaverExecutionContext context,
                                  String paramName,
                                  String paramScope)
                           throws WeaverException
Retrieve a scoped valued.

Parameters:
context - The context from which to retrieve the value.
paramName - The name of the value to retrieve.
paramScope - The scope from which to retrieve the value (if null the value is search for using context.findAttribute).
Returns:
The retrieved value - or null if the value is not found.
Throws:
WeaverException - Thrown if the given scope is unknown.

Copyright ©Paul Harvey