# Package com.singularsys.jep.misc.boundvariable

This package allows the creation of Jep variables which are bound to java objects.

See: Description

- Interface Summary
  Interface | Description
  --- | ---
  VariableBinding | Bound variables will call these methods to interact with objects outside of Jep.
  VariableBindingMapper | Defines a method which translates a variable name into a variable binding.

- Class Summary
  Class | Description
  --- | ---
  BoundVariable | A variable bound to an object outside of Jep.
  BoundVariableFactory | A variable factory for creating bound variables.
  ChainedObjectVariableBindingMapper | Creates VariableBinding objects by translating the variable name into a chain of object references.
  FieldVariableBinding | A `VariableBinding` which binds variables to a particular field of an object.
  MutableDouble | A simple Mutable Double class.

## Package com.singularsys.jep.misc.boundvariable Description

This package allows the creation of Jep variables which are bound to java objects. For example a Jep variable can be bound to a field of an object, the value of the variable is found from the field and the value of the field will be changed when the jep variable is changed.

     public class MyObj {
         public Double a;
         public double b;
     }
     ...
     // Create Jep with a variable factory which allows bound variables
     Jep jep = new Jep(new BoundVariableFactory());
     // Create an object, with a Double field a and a double field b
     MyObj obj = new MyObj();
     obj.a = new Double(3.0);
     obj.b = 5.0;
     // Create binding objects for the two fields
     FieldVariableBinding bindA = new FieldVariableBinding(obj,"a");
     FieldVariableBinding bindB = new FieldVariableBinding(obj,"b");
     // Create variables bound to these fields
     jep.addVariable("a", bindA);
     jep.addVariable("b", bindB);
     // Parse an equation using these values
     Node n = jep.parse("b=4*a");
     Object res = jep.evaluate(n);
     System.out.println("Result is "+res+" value of field b is "+obj.b);

See Also:
  `BoundVariableTest`

Copyright © 2018 Singular Systems http://www.singularsys.com/jep