public class TreeUtils extends Object
isConstant
test if its a constant. Many other is... methods.
getValue
extracts the value from a node without needing to cast and check types.
Constructor and Description |
---|
TreeUtils()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
Object |
getCI() |
Object |
getCMINUSI() |
Object |
getCMINUSONE() |
Object |
getCONE() |
Object |
getCZERO() |
Object |
getMINUSONE() |
String |
getName(Node node)
Returns the value represented by node
|
Object |
getNAN() |
Object |
getNegativeInfinity() |
Object |
getNumber(double val) |
Object |
getONE() |
Operator |
getOperator(Node node)
returns the operator for a node or null if it is not an operator node.
|
Object |
getPositiveInfinity() |
Object |
getValue(Node node)
Returns the value represented by node
|
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
|
public TreeUtils()
public String getName(Node node) throws IllegalArgumentException
IllegalArgumentException
- if given something which is not an ASTConstantpublic Object getValue(Node node) throws IllegalArgumentException
IllegalArgumentException
- if given something which is not an ASTConstantpublic double doubleValue(Node node) throws IllegalArgumentException
IllegalArgumentException
- if given something which is not an ASTConstant with a Double valuepublic long longValue(Node node) throws IllegalArgumentException
IllegalArgumentException
- if given something which is not an ASTConstant with a Double valuepublic int intValue(Node node) throws IllegalArgumentException
IllegalArgumentException
- if given something which is not an ASTConstant with a Double valuepublic Complex complexValue(Node node) throws IllegalArgumentException
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 Object getCI()
public Object getCMINUSI()
public Object getCMINUSONE()
public Object getCONE()
public Object getCZERO()
public Object getMINUSONE()
public Object getONE()
public Object getZERO()
public Object getNAN()
public Object getPositiveInfinity()
public Object getNegativeInfinity()
public Object getNumber(double val)
Jas4pp 1.5 © Java Analysis Studio for Particle Physics