|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.lsmp.djep.xjep.TreeUtils
public class TreeUtils
A set of Utility functions for working with JEP expression trees. Main methods are
isConstant
test if its a constant. Many other is... methods.
getValue
extracts the value from a node without needing to cast and check types.
Field Summary | |
---|---|
protected static Complex |
CI
Complex i |
protected static Complex |
CMINUSI
Complex Minus i |
protected static Complex |
CMINUSONE
Complex Minus One |
protected static Complex |
CONE
Complex One |
protected static Complex |
CZERO
Complex Zero |
protected static java.lang.Double |
MINUSONE
Real Minus One |
protected static java.lang.Double |
NAN
Real NaN |
protected static java.lang.Double |
NegInf
Real NaN |
protected static java.lang.Double |
ONE
Real One |
protected static java.lang.Double |
PosInf
Real positive infinity |
protected static java.lang.Double |
ZERO
Real zero. |
Constructor Summary | |
---|---|
TreeUtils()
Default constructor. |
Method Summary | |
---|---|
Complex |
complexValue(Node node)
Returns the Complex value represented by node |
static Node |
copyChildrenIfNeeded(Node node,
Node[] children)
Sets the children of a node if they have changed for it current children. |
double |
doubleValue(Node node)
Returns the double value represented by node |
static Node[] |
getChildrenAsArray(Node node)
returns the children of a node as an array of nodes. |
java.lang.Object |
getCI()
|
java.lang.Object |
getCMINUSI()
|
java.lang.Object |
getCMINUSONE()
|
java.lang.Object |
getCONE()
|
java.lang.Object |
getCZERO()
|
java.lang.Object |
getMINUSONE()
|
java.lang.String |
getName(Node node)
Returns the value represented by node |
java.lang.Object |
getNAN()
|
java.lang.Object |
getNegativeInfinity()
|
java.lang.Object |
getNumber(double val)
|
java.lang.Object |
getONE()
|
Operator |
getOperator(Node node)
returns the operator for a node or null if it is not an operator node. |
java.lang.Object |
getPositiveInfinity()
|
java.lang.Object |
getValue(Node node)
Returns the value represented by node |
java.lang.Object |
getZERO()
|
int |
intValue(Node node)
Returns the int value represented by node |
boolean |
isBinaryOperator(Node node)
|
boolean |
isComplex(Node node)
returns true if node is an ASTConstant of type Complex |
boolean |
isConstant(Node node)
returns true if node is a ASTConstant |
boolean |
isFunction(Node node)
returns true if node is an ASTFunNode |
boolean |
isInfinity(Node node)
returns true if node is a ASTConstant with a Infinite component TODO do proper treatment of signed infinity |
boolean |
isInteger(Node node)
returns true if node is a ASTConstant with Double value representing an integer. |
boolean |
isMinusOne(Node node)
returns true if node is a ASTConstant with value Double(-1) or Complex(-1,0) |
boolean |
isNaN(Node node)
returns true if node is a ASTConstant with a NaN component |
boolean |
isNegative(Node node)
returns true if node is an ASTConstant with a negative Double value |
boolean |
isOne(Node node)
returns true if node is a ASTConstant with value Double(1) or Complex(1,0) |
boolean |
isOperator(Node node)
returns true if node is an ASTOpNode |
boolean |
isPositive(Node node)
returns true if node is an ASTConstant with a positive Double value |
boolean |
isReal(Node node)
returns true if node is a ASTConstant with Double value |
boolean |
isUnaryOperator(Node node)
|
boolean |
isVariable(Node node)
returns true if node is an ASTVarNode |
boolean |
isZero(Node node)
returns true if node is a ASTConstant with value Double(0) or Complex(0,0) |
boolean |
isZero(Node node,
double tol)
returns true if node is a ASTConstant with value Double(0) or Complex(0,0) |
long |
longValue(Node node)
Returns the long value represented by node |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.lang.Double ZERO
protected static java.lang.Double ONE
protected static java.lang.Double MINUSONE
protected static Complex CZERO
protected static Complex CONE
protected static Complex CI
protected static Complex CMINUSONE
protected static Complex CMINUSI
protected static java.lang.Double NAN
protected static java.lang.Double PosInf
protected static java.lang.Double NegInf
Constructor Detail |
---|
public TreeUtils()
Method Detail |
---|
public java.lang.String getName(Node node) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if given something which is not an ASTConstantpublic java.lang.Object getValue(Node node) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if given something which is not an ASTConstantpublic double doubleValue(Node node) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if given something which is not an ASTConstant with a Double valuepublic long longValue(Node node) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if given something which is not an ASTConstant with a Double valuepublic int intValue(Node node) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if given something which is not an ASTConstant with a Double valuepublic Complex complexValue(Node node) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if given something which is not an ASTConstant with a Complex valuepublic boolean isConstant(Node node)
public boolean isReal(Node node)
public boolean isInteger(Node node)
public boolean isZero(Node node)
public boolean isZero(Node node, double tol)
tol
- tolerance for testing for zeropublic boolean isOne(Node node)
public boolean isMinusOne(Node node)
public boolean isInfinity(Node node)
public boolean isNaN(Node node)
public boolean isNegative(Node node)
public boolean isPositive(Node node)
public boolean isComplex(Node node)
public boolean isVariable(Node node)
public boolean isOperator(Node node)
public boolean isBinaryOperator(Node node)
public boolean isUnaryOperator(Node node)
public Operator getOperator(Node node)
public boolean isFunction(Node node)
public static Node copyChildrenIfNeeded(Node node, Node[] children) throws ParseException
ParseException
public static Node[] getChildrenAsArray(Node node)
public java.lang.Object getCI()
public java.lang.Object getCMINUSI()
public java.lang.Object getCMINUSONE()
public java.lang.Object getCONE()
public java.lang.Object getCZERO()
public java.lang.Object getMINUSONE()
public java.lang.Object getONE()
public java.lang.Object getZERO()
public java.lang.Object getNAN()
public java.lang.Object getPositiveInfinity()
public java.lang.Object getNegativeInfinity()
public java.lang.Object getNumber(double val)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |