fr.expression4j.core
Interface ExpressionModel

All Known Implementing Classes:
ExpressionModelImpl

public interface ExpressionModel


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.
 

Method Detail

getName

java.lang.String getName()
get the name of the expression model

Returns:
expression model name.

addUnaryOperator

void addUnaryOperator(Operator operator)
                      throws ModelException
Add unary operator to the model

Parameters:
operator - operator to add
Throws:
ModelException - if operator is not an unary operator

addBinaryOperator

void addBinaryOperator(Operator operator,
                       int priority)
                       throws ModelException
Add a binary operator

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

void addExpressionElement(ExpressionElement expressionElement,
                          int priority)
                          throws ModelException
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.

Parameters:
expressionElement - element to add.
priority - order to manage element (from 1 to ...)
Throws:
ModelException - if priority is not consecutive to others priority.

getMaxOperatorPriority

int getMaxOperatorPriority()
Get the max binary operator priority.

Returns:
max binary operator priority.

getMaxExpressionElementPriority

int getMaxExpressionElementPriority()
Get the max element priority.

Returns:
max element operator priority.

getUnaryOperators

java.util.List getUnaryOperators()
Get the list of unary operators.

Returns:
list of unary operator as String object.

getBinaryOperators

java.util.List getBinaryOperators(int priority)
Get the list of binary operator for a given priority.

Parameters:
priority - priority operator to get.
Returns:
list of binary operator as Operator object.

getExpressionElement

ExpressionElement getExpressionElement(int priority)
Get expression element for a given priority.

Parameters:
priority - priority expression element to get.
Returns:
expression element or null if not found.

getExpressionElement

ExpressionElement getExpressionElement(java.lang.String name)
Get expression element for a given name.

Parameters:
name - name of expression element to get.
Returns:
expression element or null if not found.

getOperator

Operator getOperator(java.lang.String name)
Get the named operator.

Parameters:
name - name of the operator.
Returns:
the operator if found, null otherwise.

getOperatorLevel

int getOperatorLevel(Operator operator)
Get the level associated to a given operator.

Parameters:
operator - operator to get the level.
Returns:
the requested level.