Class BrowserLocal<T>
java.lang.Object
org.jboss.arquillian.graphene.context.BrowserLocal<T>
This class provides browser-local variables. These variables differ from
their normal counterparts in that each browser context that accesses one (via its
get or set method) has its own, independently initialized
copy of the variable. BrowserLocal instances are typically private
static fields in classes that wish to associate state with a browser context.
- Author:
- Jan Papousek
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget()Returns the value in the current browser context's copy of this browser-local variable.getLast()Returns the value in the last browser context's copy of this browser-local variable.protected TReturns the current browser context's "initial value" for this browser-local variable.voidremove()Removes the current browser context's value for this browser-local variable.voidSets the current browser context's copy of this browser-local variable to the specified value.
-
Constructor Details
-
BrowserLocal
public BrowserLocal()
-
-
Method Details
-
get
Returns the value in the current browser context's copy of this browser-local variable. If the variable has no value for the current browser context, it is first initialized to the value returned by an invocation of theinitialValue()method.- Returns:
- the current browser context's value of this browser-local
- Throws:
IllegalStateException- if there is no active browser context
-
getLast
Returns the value in the last browser context's copy of this browser-local variable. If the variable has no value for the last browser context, it is first initialized to the value returned by an invocation of theinitialValue()method.If the last browser context is not available, null is returned.
- Returns:
- the last browser context's value of this browser-local
-
initialValue
Returns the current browser context's "initial value" for this browser-local variable. This method will be invoked the first time a browser context accesses the variable with theget()method, unless the browser context previously invoked theset(T)method, in which case the initialValue method will not be invoked for the browser context. Normally, this method is invoked at most once per browser context, but it may be invoked again in case of subsequent invocations ofremove()followed byget().This implementation simply returns null; if the programmer desires browser-local variables to have an initial value other than null, BrowserLocal must be subclassed, and this method overridden. Typically, an anonymous inner class will be used.
- Returns:
- the initial value for this browser-local
-
remove
public void remove()Removes the current browser context's value for this browser-local variable. If this browser-local variable is subsequently read by the current browser context, its value will be reinitialized by invoking itsinitialValue()method, unless its value is set by the current browser context in the interim. This may result in multiple invocations of the initialValue method in the current browser context.- Throws:
IllegalStateException- if there is no active browser context
-
set
Sets the current browser context's copy of this browser-local variable to the specified value. Most subclasses will have no need to override this method, relying solely on theinitialValue()method to set the values of browser-locals.- Parameters:
value- the value to be stored in the current browser context's copy of this browser-local.- Throws:
IllegalStateException- if there is no active browser context
-