fr.expression4j.core.impl
Class CatalogImpl

java.lang.Object
  extended by fr.expression4j.core.impl.CatalogImpl
All Implemented Interfaces:
Catalog

public class CatalogImpl
extends java.lang.Object
implements Catalog

Implementation of catalog interface.

 All catalog store the default functions derived from java Math class:
        - abs(x)
  - acos(x)
  - asin(x)
  - atan(x)
  - ceil(x)
  - cos(x)
  - cosh(x)
  - exp(x)
  - floor(x)
  - log(x)
  - random()
  - sin(x)
  - sinh(x)
  - sqrt(x)
  - tan(x)  
 
 and default constant
  - pi = 3.14159 ...
  - e  = 2,71828182845904523536028747135266249
 
 

Author:
SGINER

Field Summary
protected  java.util.Map catalog
           
protected  java.util.Map constant
           
protected  java.lang.String name
           
 
Constructor Summary
CatalogImpl(java.lang.String catalogName)
           
 
Method Summary
 void addConstant(java.lang.String name, MathematicalElement value)
          Add a constant to the catalog.
 void addExpression(Expression expression)
          add an expression to catalog.
 MathematicalElement getConstant(java.lang.String name)
          Get a constant from the catalog
 Expression getExpression(java.lang.String name)
          Get an expression from the catalog.
 java.lang.String getName()
          Get the catalog name.
 java.util.List listConstant()
          List all constant stored in catalog.
 java.util.List listExpression()
          List the content of the catalog
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

catalog

protected java.util.Map catalog

constant

protected java.util.Map constant

name

protected java.lang.String name
Constructor Detail

CatalogImpl

public CatalogImpl(java.lang.String catalogName)
Method Detail

addExpression

public void addExpression(Expression expression)
Description copied from interface: Catalog
add an expression to catalog.

Specified by:
addExpression in interface Catalog
Parameters:
expression - expression to add.

getExpression

public Expression getExpression(java.lang.String name)
Description copied from interface: Catalog
Get an expression from the catalog.

Specified by:
getExpression in interface Catalog
Parameters:
name - name of the expression to get
Returns:
the expression if found, null otherwise.

listExpression

public java.util.List listExpression()
Description copied from interface: Catalog
List the content of the catalog

Specified by:
listExpression in interface Catalog
Returns:
list of functions name.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addConstant

public void addConstant(java.lang.String name,
                        MathematicalElement value)
Description copied from interface: Catalog
Add a constant to the catalog.

Specified by:
addConstant in interface Catalog
Parameters:
name - name of the constant.
value - value of the constant.

getConstant

public MathematicalElement getConstant(java.lang.String name)
Description copied from interface: Catalog
Get a constant from the catalog

Specified by:
getConstant in interface Catalog
Parameters:
name - constant name to get.
Returns:
the constant if found, null if not found.

listConstant

public java.util.List listConstant()
Description copied from interface: Catalog
List all constant stored in catalog.

Specified by:
listConstant in interface Catalog
Returns:
list of all constant stored in catalog a String.

getName

public java.lang.String getName()
Description copied from interface: Catalog
Get the catalog name.

Specified by:
getName in interface Catalog
Returns:
catalog name.