fr.expression4j.core.impl
Class ExpressionModelImpl

java.lang.Object
  extended by fr.expression4j.core.impl.ExpressionModelImpl
All Implemented Interfaces:
ExpressionModel

public class ExpressionModelImpl
extends java.lang.Object
implements ExpressionModel


Constructor Summary
ExpressionModelImpl(java.lang.String name)
           
 
Method Summary
 void addBinaryOperator(Operator operator, int priority)
          Add a binary operator
 void addExpressionElement(ExpressionElement expressionElement, int priority)
          Add expression element to the model.
 void addUnaryOperator(Operator operator)
          Add unary operator to the model
 java.util.List getBinaryOperators(int priority)
          Get the list of binary operator for a given priority.
 ExpressionElement getExpressionElement(int priority)
          Get expression element for a given priority.
 ExpressionElement getExpressionElement(java.lang.String name)
          Get expression element for a given name.
 int getMaxExpressionElementPriority()
          Get the max element priority.
 int getMaxOperatorPriority()
          Get the max binary operator priority.
 java.lang.String getName()
          get the name of the expression model
 Operator getOperator(java.lang.String name)
          Get the named operator.
 int getOperatorLevel(Operator operator)
          Get the level associated to a given operator.
 java.util.List getUnaryOperators()
          Get the list of unary operators.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionModelImpl

public ExpressionModelImpl(java.lang.String name)
Method Detail

addUnaryOperator

public void addUnaryOperator(Operator operator)
                      throws ModelException
Description copied from interface: ExpressionModel
Add unary operator to the model

Specified by:
addUnaryOperator in interface ExpressionModel
Parameters:
operator - operator to add
Throws:
ModelException - if operator is not an unary operator

addBinaryOperator

public void addBinaryOperator(Operator operator,
                              int priority)
                       throws ModelException
Description copied from interface: ExpressionModel
Add a binary operator

Specified by:
addBinaryOperator in interface ExpressionModel
Parameters:
operator - operator to add
priority - operator priority (from 1 to ... depend of your model)
Throws:
ModelException - if operator is not a binary operator

addExpressionElement

public void addExpressionElement(ExpressionElement expressionElement,
                                 int priority)
                          throws ModelException
Description copied from interface: ExpressionModel
Add expression element to the model. ExpressionElement is an object who know how to parse an element of an expression (real or integer for example). If priority alredy exist in model, the new element step up others.

Specified by:
addExpressionElement in interface ExpressionModel
Parameters:
expressionElement - element to add.
priority - order to manage element (from 1 to ...)
Throws:
ModelException - if priority is not consecutive to others priority.

getMaxOperatorPriority

public int getMaxOperatorPriority()
Description copied from interface: ExpressionModel
Get the max binary operator priority.

Specified by:
getMaxOperatorPriority in interface ExpressionModel
Returns:
max binary operator priority.

getMaxExpressionElementPriority

public int getMaxExpressionElementPriority()
Description copied from interface: ExpressionModel
Get the max element priority.

Specified by:
getMaxExpressionElementPriority in interface ExpressionModel
Returns:
max element operator priority.

getUnaryOperators

public java.util.List getUnaryOperators()
Description copied from interface: ExpressionModel
Get the list of unary operators.

Specified by:
getUnaryOperators in interface ExpressionModel
Returns:
list of unary operator as String object.

getBinaryOperators

public java.util.List getBinaryOperators(int priority)
Description copied from interface: ExpressionModel
Get the list of binary operator for a given priority.

Specified by:
getBinaryOperators in interface ExpressionModel
Parameters:
priority - priority operator to get.
Returns:
list of binary operator as Operator object.

getExpressionElement

public ExpressionElement getExpressionElement(int priority)
Description copied from interface: ExpressionModel
Get expression element for a given priority.

Specified by:
getExpressionElement in interface ExpressionModel
Parameters:
priority - priority expression element to get.
Returns:
expression element or null if not found.

getExpressionElement

public ExpressionElement getExpressionElement(java.lang.String name)
Description copied from interface: ExpressionModel
Get expression element for a given name.

Specified by:
getExpressionElement in interface ExpressionModel
Parameters:
name - name of expression element to get.
Returns:
expression element or null if not found.

getOperator

public Operator getOperator(java.lang.String name)
Description copied from interface: ExpressionModel
Get the named operator.

Specified by:
getOperator in interface ExpressionModel
Parameters:
name - name of the operator.
Returns:
the operator if found, null otherwise.

getOperatorLevel

public int getOperatorLevel(Operator operator)
Description copied from interface: ExpressionModel
Get the level associated to a given operator.

Specified by:
getOperatorLevel in interface ExpressionModel
Parameters:
operator - operator to get the level.
Returns:
the requested level.

getName

public java.lang.String getName()
Description copied from interface: ExpressionModel
get the name of the expression model

Specified by:
getName in interface ExpressionModel
Returns:
expression model name.