public class ExpressionCombiner
extends java.lang.Object
replace(Expression, java.lang.String, Expression)
:
Change a value in an Expression. The change consist in replacing a Variable by an Expression, which may contain Variables.add(Expression, Expression)
: Add two expressions.substract(Expression, Expression)
: Substract two expressions.multiply(Expression, Expression)
: Multiply two expressions.divide(Expression, Expression)
: Divide two expressions.Modifier and Type | Field and Description |
---|---|
static int |
DEEP_COPY |
static int |
DONT_COPY |
static int |
SHALLOW_COPY |
Constructor and Description |
---|
ExpressionCombiner() |
Modifier and Type | Method and Description |
---|---|
Expression |
add(Expression expr1,
Expression expr2)
Add an expression to another.
|
Expression |
add(Expression expr,
float value)
Add an expression and a float constant.
|
Expression |
add(Expression expr,
int value)
Add an expression and an integer constant.
|
Expression |
add(Expression expr,
java.lang.String value)
Add an expression and a String constant.
|
Expression |
createArray(Expression... exprs)
Create an array expression.
|
Expression |
divide(Expression expr1,
Expression expr2)
Divide an expression by another.
|
Expression |
divide(Expression expr,
float value)
Divide an expression by a float constant.
|
Expression |
divide(Expression expr,
int value)
Divide an expression by an integer constant.
|
int |
getCopyBehavior()
Return the copy behavior of this ExpressionCombiner.
|
Expression |
multiply(Expression expr1,
Expression expr2)
Multiply an expression with another.
|
Expression |
multiply(Expression expr,
float value)
Multiply an expression by a float constant.
|
Expression |
multiply(Expression expr,
int value)
Multiply an expression by an integer constant.
|
Expression |
replace(Expression expr,
java.lang.String varName,
Expression replacedExpr)
Replace a variable in an expression by another sub-expression.
|
Expression |
replaceVariable(Expression expr,
java.lang.String varName,
java.lang.String varToReplace)
Replace a variable in an expression by another variable.
|
void |
setCopyBehavior(int copyBehavior)
Set the copy behavior of this ExpressionCombiner.
|
Expression |
substract(Expression expr1,
Expression expr2)
Subtract an expression to another.
|
Expression |
substract(Expression expr,
float value)
Subtract an expression by a float constant.
|
Expression |
substract(Expression expr,
int value)
Subtract an expression and an integer constant.
|
public static final int DONT_COPY
public static final int SHALLOW_COPY
public static final int DEEP_COPY
public void setCopyBehavior(int copyBehavior)
DONT_COPY
: return the expression (no copy)SHALLOW_COPY
: return a shallow copy of the expressionDEEP_COPY
: return a deep copy of the expressioncopyBehavior
- the copy behaviorpublic int getCopyBehavior()
setCopyBehavior(int)
public Expression add(Expression expr, int value)
expr
- the expressionvalue
- the integer constantpublic Expression add(Expression expr, float value)
expr
- the expressionvalue
- the float constantpublic Expression add(Expression expr, java.lang.String value)
expr
- the expressionvalue
- the String constantpublic Expression substract(Expression expr, int value)
expr
- the expressionvalue
- the integer constantpublic Expression substract(Expression expr, float value)
expr
- the expressionvalue
- the float constantpublic Expression multiply(Expression expr, int value)
expr
- the expressionvalue
- the int constantpublic Expression multiply(Expression expr, float value)
expr
- the expressionvalue
- the float constantpublic Expression divide(Expression expr, int value)
expr
- the expressionvalue
- the int constantpublic Expression divide(Expression expr, float value)
expr
- the expressionvalue
- the float constantpublic Expression createArray(Expression... exprs)
exprs
- the expressionspublic Expression add(Expression expr1, Expression expr2)
expr1
- the first expressionexpr2
- the expression to addpublic Expression substract(Expression expr1, Expression expr2)
expr1
- the first expressionexpr2
- the expression to substractpublic Expression multiply(Expression expr1, Expression expr2)
expr1
- the first expressionexpr2
- the expression to multiplypublic Expression divide(Expression expr1, Expression expr2)
expr1
- the first expressionexpr2
- the expression to dividepublic Expression replaceVariable(Expression expr, java.lang.String varName, java.lang.String varToReplace)
expr = sin(a + b) varName = a varToReplace = bthen the result is
sin(b + b)
Note that:
expr
- the expressionvarName
- the name of the variable which must be replacedvarToReplace
- the name of the variable to usepublic Expression replace(Expression expr, java.lang.String varName, Expression replacedExpr)
expr = sin(a + 2) varName = a replacedExpr = b * cthen the result is
sin((b * c) + 2)
Note that:
expr
- the expressionvarName
- the name of the variable which must be replacedreplacedExpr
- the expression which must replace the variableCopyright © 2018 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence