JScience v4.3

org.jscience.mathematics.function
Class Variable.Global<X>

java.lang.Object
  extended by org.jscience.mathematics.function.Variable.Global<X>
All Implemented Interfaces:
javolution.lang.Reference<X>, Variable<X>
Enclosing interface:
Variable<X>

public static class Variable.Global<X>
extends java.lang.Object
implements Variable<X>

This class represents a simple Variable implementation with context-local values. Instances of this class can be set independently by multiple-threads as long as each concurrent thread executes within a LocalContext. For example:

 public abstract class Engine  {
     public static final Variable.Global<Amount<AngularVelocity>> RPM
         = new Variable.Global<Amount<AngularVelocity>>("rpm");
     public abstract Function<Amount<AngularVelocity>, Amount<Torque>> getTorque();    
 }
 ...
 LocalContext.enter(); 
 try {
     RPM.set(rpm);
     Amount<Torque> torque = myEngine.getTorque().evaluate();
 } finally {
     LocalContext.exit();
 }
It should be noted that parameterized evaluations are performed within a local context. Therefore, the example above could also be rewritten:
     Amount<Torque> torque = myEngine.getTorque().evaluate(rpm);
 


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jscience.mathematics.function.Variable
Variable.Global<X>, Variable.Local<X>
 
Constructor Summary
Variable.Global(java.lang.String symbol)
          Creates a new global variable with a unique symbol.
 
Method Summary
 X get()
           
 java.lang.String getSymbol()
          Returns the symbol for this variable.
 void set(X arg0)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Variable.Global

public Variable.Global(java.lang.String symbol)
Creates a new global variable with a unique symbol.

Parameters:
symbol - the variable symbol.
Method Detail

getSymbol

public java.lang.String getSymbol()
Description copied from interface: Variable
Returns the symbol for this variable.

Specified by:
getSymbol in interface Variable<X>
Returns:
this variable's symbol.

get

public X get()
Specified by:
get in interface javolution.lang.Reference<X>

set

public void set(X arg0)
Specified by:
set in interface javolution.lang.Reference<X>

JScience v4.3

Copyright © 2006 JScience.