org.iqual.chaplin.prop
Class Var<T>

java.lang.Object
  extended by org.iqual.chaplin.prop.Var<T>
All Implemented Interfaces:
Property<T>

public class Var<T>
extends Object
implements Property<T>

This class represents a variable which can be bound to three scopes: global, thread-local and local. The same instance can be bound to one or more scopes whereas the value is taken from the most local one. The most local scope is local, then thread-local and then global.

A value stored in the global scope is visible from all threads and all methods which have the visibility of the Var object. One uses def method for setting a value to this scope.

A value stored in the thread-local scope is visible only to the thread from which the value was set. One calls bind method for setting a value to the thread-local scope.

A value stored in the local local scope is visible only within the method invocation from which the value was set. One calls method let for setting a value to the local scope.

Since:
21.11.2009 15:49:21
Author:
Zbynek Slajchrt

Nested Class Summary
static class Var.UndefinedValueException
           
 
Constructor Summary
Var()
           
 
Method Summary
 void bind(T val)
          Binds the value to the thread-local scope.
 void def(T val)
          Binds the value to the global scope.
 T get()
          Retrieves the value of this variable.
 void let(T val)
          Binds the value to the local scope.
 void set(T val)
          Alias for def.
 void unbind()
          Unbinds any value from the thread-local scope.
 void undef()
          Unbinds any value from the global scope.
 void unlet()
          Unbinds any value from the local scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Var

public Var()
Method Detail

get

public T get()
Retrieves the value of this variable. It first tries to get the value from the local scope, then from the thread-local scope and then from the global scope.

Specified by:
get in interface Property<T>
Returns:

set

public void set(T val)
Alias for def.

Specified by:
set in interface Property<T>
Parameters:
val - the value

def

public void def(T val)
Binds the value to the global scope.

Parameters:
val -

undef

public void undef()
Unbinds any value from the global scope.


bind

public void bind(T val)
Binds the value to the thread-local scope.

Parameters:
val -

unbind

public void unbind()
Unbinds any value from the thread-local scope.


unlet

public void unlet()
Unbinds any value from the local scope.


let

public void let(T val)
Binds the value to the local scope.

Parameters:
val -


Copyright © 2009 iquality.org. All Rights Reserved.