pnuts.ext
Class UnitSystem

java.lang.Object
  |
  +--pnuts.ext.UnitSystem
All Implemented Interfaces:
QuantityFactory, java.io.Serializable

public class UnitSystem
extends java.lang.Object
implements QuantityFactory, java.io.Serializable

This class defines a unit system in Pnuts. When an identifier follows a decimal number, the identifier should be one of the units symbols defined.

 UnitSystem(["cm", "m"], [1, 100])
 1cm + 1m  ==> 101.000cm
 

See Also:
Serialized Form

Constructor Summary
UnitSystem(java.lang.String[] units, java.lang.Number[] scale, Context context)
           
 
Method Summary
 void init(Context context)
           
 java.lang.Object make(java.lang.Number n, java.lang.String unit)
           
 void setPrecision(int prec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnitSystem

public UnitSystem(java.lang.String[] units,
                  java.lang.Number[] scale,
                  Context context)
Method Detail

init

public void init(Context context)

setPrecision

public void setPrecision(int prec)

make

public java.lang.Object make(java.lang.Number n,
                             java.lang.String unit)
Specified by:
make in interface QuantityFactory