public class ASTFactory
extends java.lang.Object
| Constructor and Description |
|---|
ASTFactory() |
| Modifier and Type | Method and Description |
|---|---|
static ASTLogicalOperatorNode |
and(ASTNode2... ast)
Creates an
ASTLogicalOperatorNode of type ASTNode.Type.LOGICAL_AND and
adds the given nodes as children. |
static ASTArithmeticOperatorNode |
arithmeticOperation(ASTNode.Type operator,
ASTNode2... list)
Creates a new
ASTArithmeticOperatorNode of type operator and adds
the given nodes as children. |
static int |
countType(ASTNode2 node,
ASTNode.Type type)
Counts the number of nodes that have
ASTNode.Type type
in the tree rooted at node. |
static ASTArithmeticOperatorNode |
diff(ASTNode2... ast)
Creates a new
ASTArithmeticOperatorNode of type MINUS and adds the given nodes as children. |
static ASTDivideNode |
divideBy(ASTNode2 numerator,
ASTNode2 denominator)
|
static ASTRelationalOperatorNode |
eq(ASTNode2 left,
ASTNode2 right)
Creates a new
ASTRelationalOperatorNode of type RELATIONAL_EQ. |
static ASTPowerNode |
exp(ASTNode2 exponent)
Returns a new
ASTPowerNode that represents Euler's constant raised by the
power of the given exponent. |
static java.lang.String |
formulaToString(ASTNode2 tree)
Returns the formula from the given ASTNode2 as an SBML Level 1 text-string
mathematical formula.
|
static ASTDivideNode |
frac(ASTNode2 numerator,
ASTNode2 denominator)
Creates a new
ASTDivideNode with the given nodes as children. |
static ASTDivideNode |
frac(int numerator,
ASTNode2 denominator)
Creates a new
ASTDivideNode with the given numerator
and denominator. |
static ASTRelationalOperatorNode |
geq(ASTNode2 left,
ASTNode2 right)
Creates an
ASTRelationalOperatorNode representing greater or equal for
the two given nodes. |
static ASTRelationalOperatorNode |
gt(ASTNode2 left,
ASTNode2 right)
Creates an
ASTRelationalOperatorNode representing greater than for
the two given left and right child. |
static ASTRelationalOperatorNode |
leq(ASTNode2 left,
ASTNode2 right)
Creates an
ASTRelationalOperatorNode representing less or equal for
the two given left and right child. |
static ASTLogarithmNode |
log(ASTNode2 value)
Creates an
ASTLogarithmNode representing a logarithm to base 10 of the given value. |
static ASTLogarithmNode |
log(ASTNode2 base,
ASTNode2 value)
Creates an
ASTLogarithmNode that represents the logarithm function with
the given base and value. |
static ASTRelationalOperatorNode |
lt(ASTNode2 left,
ASTNode2 right)
Creates a
ASTRelationalOperatorNode that performs a less than comparison between
two ASTNode2s. |
static ASTRelationalOperatorNode |
lt(java.lang.String variable,
ASTNode2 node)
Creates an
ASTRelationalOperatorNode that performs a less than comparison between a
variable and another ASTNode2. |
static ASTMinusNode |
minus(ASTNode2 node1,
ASTNode2 node2)
|
static ASTMinusNode |
minus(ASTNode2 node,
double real)
Subtracts the given number from an
ASTNode2 |
static ASTMinusNode |
minus(ASTNode2 node,
int integer)
Subtracts an integer number from
ASTNode2. |
static ASTMinusNode |
minus(ASTNode2 node,
int integer,
java.lang.String unitsID)
Subtracts an integer number from
ASTNode2 and sets
the units of ASTCnIntegerNode to the specified unitsID. |
static ASTArithmeticOperatorNode |
multiplyWith(ASTNode2... nodes)
Multiplies an
ASTNode2 with the given nodes, i.e., all given nodes
will be children of this ASTArithmeticOperatorNode, whose type will
be set to ASTNode.Type.TIMES. |
static ASTTimesNode |
multiplyWith(ASTNode2 node1,
ASTNode2 node2)
|
static ASTRelationalOperatorNode |
neq(ASTNode2 left,
ASTNode2 right)
|
static ASTLogicalOperatorNode |
not(ASTNode2... ast)
Creates an
ASTLogicalOperatorNode of type ASTNode.Type.LOGICAL_NOT and
adds the given nodes as children. |
static ASTLogicalOperatorNode |
or(ASTNode2... ast)
Creates an
ASTLogicalOperatorNode of type ASTNode.Type.LOGICAL_OR and
adds the given nodes as children. |
static ASTNode2 |
parseFormula(java.lang.String formula)
Parses a text-string mathematical formula and an Abstract Syntax Tree
representation.
|
static java.lang.String |
parseMathML(java.lang.String fileName)
Return String representation of specified MathML file
|
static ASTPiecewiseFunctionNode |
piecewise(ASTQualifierNode node,
ASTQualifierNode... nodes)
Creates a piecewise
ASTPiecewiseFunctionNode. |
static ASTPlusNode |
plus(ASTNode2 node1,
ASTNode2 node2)
|
static ASTPlusNode |
plus(ASTNode2 node,
double real)
Adds a real number to
ASTNode2. |
static ASTPlusNode |
plus(ASTNode2 node,
int integer)
Adds an integer number to
ASTNode2. |
static ASTPowerNode |
pow(ASTNode2 basis,
ASTNode2 exponent)
Creates a power
ASTNode2. |
static ASTPowerNode |
pow(ASTNode2 basis,
double exponent)
Creates a power
ASTPowerNode with an ASTNode2
basis and a real exponent. |
static ASTPowerNode |
pow(ASTNode2 basis,
int exponent)
Creates a power
ASTPowerNode with an ASTNode2
basis and an integer exponent. |
static ASTArithmeticOperatorNode |
product(ASTNode2... ast)
Creates an
ASTArithmeticOperatorNode of type ASTNode.Type.PRODUCT and
adds the given nodes as children. |
static ASTBinaryFunctionNode |
reduceToBinary(ASTFunction node)
Reduces an
ASTFunction to a binary tree, e.g., if the formula in the
ASTFunction is and(x, y, z) then the formula of the reduced node would
be and(and(x, y), z). |
static ASTRelationalOperatorNode |
relational(ASTNode.Type type,
ASTNode2 a,
ASTNode2 b)
Creates a relational
ASTRelationalOperatorNode of the given type with
the two given children left and right. |
static ASTRootNode |
root(ASTNode2 rootExponent,
ASTNode2 radicand)
Creates a root of type
ASTNode2. |
static void |
setParentSBMLObject(ASTNode2 node,
MathContainer parent)
Sets the Parent of the node and its children to the given value
|
static ASTRootNode |
sqrt(ASTNode2 radicand)
Creates a square root of type
ASTRootNode with the
specified radicand of type ASTNode2. |
static ASTArithmeticOperatorNode |
sum(ASTNode2... ast)
Creates an
ASTArithmeticOperatorNode of type ASTNode.Type.SUM and adds
the given nodes as children. |
static ASTTimesNode |
times(ASTNode2 node1,
ASTNode2 node2)
Creates a new
ASTTimesNode with exactly two children |
static ASTTimesNode |
times(ASTNode2 node1,
double real)
Adds a real number to
ASTNode2 |
static ASTTimesNode |
times(ASTNode2 node1,
int integer)
Adds an integer to
ASTNode2 |
static ASTNode |
toASTNode(ASTNode2 astNode2)
|
static ASTNode2 |
toASTNode2(ASTNode astNode) |
static ASTMinusNode |
uMinus(ASTNode2 ast)
Creates a new
ASTMinusNode that has exactly one child and
which is of type ASTNode.Type.MINUS, i.e., this negates what is encoded in ast. |
static ASTLogicalOperatorNode |
xor(ASTNode2... ast)
Creates an
ASTLogicalOperatorNode of type ASTNode.Type.LOGICAL_XOR and
adds the given nodes as children. |
public static ASTLogicalOperatorNode and(ASTNode2... ast)
ASTLogicalOperatorNode of type ASTNode.Type.LOGICAL_AND and
adds the given nodes as children.ast - ASTLogicalOperatorNode with the given nodes as children.public static ASTArithmeticOperatorNode arithmeticOperation(ASTNode.Type operator, ASTNode2... list)
ASTArithmeticOperatorNode of type operator and adds
the given nodes as children.public static int countType(ASTNode2 node, ASTNode.Type type)
ASTNode.Type type
in the tree rooted at node.node - ASTNode2type - ASTNode.Typepublic static ASTArithmeticOperatorNode diff(ASTNode2... ast)
ASTArithmeticOperatorNode of type MINUS and adds the given nodes as children.
Resulting abstract syntax tree will be reduced to binary form.ast - the children of the new ASTNodeASTArithmeticOperatorNode of type MINUS and adds the given nodes as childrenpublic static ASTDivideNode divideBy(ASTNode2 numerator, ASTNode2 denominator)
numerator - ASTNode2denominator - ASTNode2ASTDivideNodepublic static ASTRelationalOperatorNode eq(ASTNode2 left, ASTNode2 right)
ASTRelationalOperatorNode of type RELATIONAL_EQ.left - the left child.right - the right child.ASTRelationalOperatorNode of type RELATIONAL_EQ.public static ASTPowerNode exp(ASTNode2 exponent)
ASTPowerNode that represents Euler's constant raised by the
power of the given exponent.exponent - the exponentASTPowerNode that represents Euler's constant raised by the
power of the given exponent.public static java.lang.String formulaToString(ASTNode2 tree) throws SBMLException
tree - the root of the ASTNode2 formula expression treenull is
returned if the given argument is null.SBMLExceptionpublic static ASTDivideNode frac(ASTNode2 numerator, ASTNode2 denominator)
ASTDivideNode with the given nodes as children.numerator - the numerator ASTNode2denominator - the denominator ASTNode2ASTDivideNode with the given nodes as children.public static ASTDivideNode frac(int numerator, ASTNode2 denominator)
ASTDivideNode with the given numerator
and denominator.numerator - the integer numeratordenominator - the denominator ASTNode2ASTDivideNode with the given numerator
and denominator.public static ASTRelationalOperatorNode geq(ASTNode2 left, ASTNode2 right)
ASTRelationalOperatorNode representing greater or equal for
the two given nodes.left - the left child.right - the right child.ASTRelationalOperatorNode representing greater or equal.public static ASTRelationalOperatorNode gt(ASTNode2 left, ASTNode2 right)
ASTRelationalOperatorNode representing greater than for
the two given left and right child.left - the left child.right - the right child.ASTRelationalOperatorNode representing greater than for
the two given left and right child.public static ASTRelationalOperatorNode leq(ASTNode2 left, ASTNode2 right)
ASTRelationalOperatorNode representing less or equal for
the two given left and right child.left - the left child.right - the right child.ASTRelationalOperatorNode representing less or equal for
the two given left and right child.public static ASTLogarithmNode log(ASTNode2 value)
ASTLogarithmNode representing a logarithm to base 10 of the given value.value - the value which is the argument of the logarithm.ASTLogarithmNode representing a logarithm to base 10 of the given value.public static ASTLogarithmNode log(ASTNode2 base, ASTNode2 value)
ASTLogarithmNode that represents the logarithm function with
the given base and value. The parent SBML object will be taken from the
ASTNode2 value.base - The basis of this logarithm. Can be null; then a base of 10
will be assumed.value - Must not be null.ASTLogarithmNode representing the logarithm of the given value
with respect to the given base or to the base 10 if base is null.public static ASTRelationalOperatorNode lt(ASTNode2 left, ASTNode2 right)
ASTRelationalOperatorNode that performs a less than comparison between
two ASTNode2s. The parent SBML object of the resulting node will
be taken from the left node.left - the left child.right - the right child.ASTRelationalOperatorNode that performs a less than comparison between
two ASTNode2s.public static ASTRelationalOperatorNode lt(java.lang.String variable, ASTNode2 node)
ASTRelationalOperatorNode that performs a less than comparison between a
variable and another ASTNode2. The parent SBML object will be
taken from the given ASTNode2.variable - the left child.node - the right child.ASTRelationalOperatorNode that performs a less than comparison between a
variable and another ASTNode2.public static ASTMinusNode minus(ASTNode2 node1, ASTNode2 node2)
node1 - ASTNode2node2 - ASTNode2ASTMinusNodepublic static ASTMinusNode minus(ASTNode2 node, double real)
ASTNode2node - ASTNode2real - double valueASTMinusNodepublic static ASTMinusNode minus(ASTNode2 node, int integer)
ASTNode2.node - ASTNode2integer - intASTMinusNodepublic static ASTMinusNode minus(ASTNode2 node, int integer, java.lang.String unitsID)
ASTNode2 and sets
the units of ASTCnIntegerNode to the specified unitsID.node - ASTNode2integer - intunitsID - StringASTMinusNodepublic static ASTArithmeticOperatorNode multiplyWith(ASTNode2... nodes)
ASTNode2 with the given nodes, i.e., all given nodes
will be children of this ASTArithmeticOperatorNode, whose type will
be set to ASTNode.Type.TIMES. Resulting abstract syntax tree will be reduced
to binary form.nodes - some ASTNode2ASTArithmeticOperatorNodepublic static ASTTimesNode multiplyWith(ASTNode2 node1, ASTNode2 node2)
node1 - ASTNode2node2 - ASTNode2ASTTimesNodepublic static ASTRelationalOperatorNode neq(ASTNode2 left, ASTNode2 right)
left - the left child.right - the right child.ASTRelationalOperatorNode that performs a not equal comparison between
two ASTNode2s.public static ASTLogicalOperatorNode not(ASTNode2... ast)
ASTLogicalOperatorNode of type ASTNode.Type.LOGICAL_NOT and
adds the given nodes as children.ast - ASTLogicalOperatorNode with the given nodes as children.public static ASTLogicalOperatorNode or(ASTNode2... ast)
ASTLogicalOperatorNode of type ASTNode.Type.LOGICAL_OR and
adds the given nodes as children.ast - ASTLogicalOperatorNode with the given nodes as children.public static ASTNode2 parseFormula(java.lang.String formula) throws ParseException
formula - a text-string mathematical formula.ASTNode2 representing the formula.ParseException - If the given formula is not of valid format or cannot be
parsed for other reasons.public static java.lang.String parseMathML(java.lang.String fileName)
fileName - public static ASTPiecewiseFunctionNode piecewise(ASTQualifierNode node, ASTQualifierNode... nodes)
ASTPiecewiseFunctionNode.
At least one ASTQualifierNode must be given
as a child. The parent SBML object of this first node will be the parent
of the resulting ASTPiecewiseFunctionNode.
node - the parent SBML object of this node will be the parent
of the resulting ASTPiecewiseFunctionNode.nodes - the children of the new piecewise ASTNode2ASTPiecewiseFunctionNode.public static ASTPlusNode plus(ASTNode2 node1, ASTNode2 node2)
node1 - ASTNode2node2 - ASTNode2ASTArithmeticOperatorNodepublic static ASTPlusNode plus(ASTNode2 node, double real)
ASTNode2.node - ASTNode2real - double valueASTPlusNodepublic static ASTPlusNode plus(ASTNode2 node, int integer)
ASTNode2.node - ASTNode2integer - intASTPlusNodepublic static ASTPowerNode pow(ASTNode2 basis, ASTNode2 exponent)
ASTNode2.basis - the basisexponent - the exponentASTPowerNode.public static ASTPowerNode pow(ASTNode2 basis, double exponent)
ASTPowerNode with an ASTNode2
basis and a real exponent.basis - the basisexponent - the exponentASTPowerNode.public static ASTPowerNode pow(ASTNode2 basis, int exponent)
ASTPowerNode with an ASTNode2
basis and an integer exponent.basis - the basisexponent - the exponentASTPowerNode.public static ASTArithmeticOperatorNode product(ASTNode2... ast)
ASTArithmeticOperatorNode of type ASTNode.Type.PRODUCT and
adds the given nodes as children.ast - ASTArithmeticOperatorNode with the given nodes as children.public static ASTBinaryFunctionNode reduceToBinary(ASTFunction node)
Reduces an ASTFunction to a binary tree, e.g., if the formula in the
ASTFunction is and(x, y, z) then the formula of the reduced node would
be and(and(x, y), z).
node - ASTFunctionASTBinaryFunctionNodepublic static ASTRelationalOperatorNode relational(ASTNode.Type type, ASTNode2 a, ASTNode2 b)
ASTRelationalOperatorNode of the given type with
the two given children left and right.
Sets the parent SBML object of all nodes to the one provided by the left child.
type - the type of relational node.a - the left child.b - the right child.ASTRelationalOperatorNode of the given type with
the two given children left and right.public static ASTRootNode root(ASTNode2 rootExponent, ASTNode2 radicand)
ASTNode2.radicand - the radicand ASTNode2rootExponent - the exponent of the root element ASTNode2ASTRootNode.public static void setParentSBMLObject(ASTNode2 node, MathContainer parent)
node - the orphan nodeparent - the parentpublic static ASTRootNode sqrt(ASTNode2 radicand)
ASTRootNode with the
specified radicand of type ASTNode2.radicand - ASTNode2ASTRootNode.public static ASTArithmeticOperatorNode sum(ASTNode2... ast)
ASTArithmeticOperatorNode of type ASTNode.Type.SUM and adds
the given nodes as children.ast - ASTArithmeticOperatorNode with the given nodes as children.public static ASTTimesNode times(ASTNode2 node1, ASTNode2 node2)
ASTTimesNode with exactly two childrennode1 - ASTNode2node2 - ASTNode2ASTTimesNode that has exactly two childrenpublic static ASTTimesNode times(ASTNode2 node1, double real)
ASTNode2node1 - ASTNode2real - doubleASTTimesNode that has exactly two childrenpublic static ASTTimesNode times(ASTNode2 node1, int integer)
ASTNode2node1 - ASTNode2integer - intASTTimesNode that has exactly two childrenpublic static ASTMinusNode uMinus(ASTNode2 ast)
ASTMinusNode that has exactly one child and
which is of type ASTNode.Type.MINUS, i.e., this negates what is encoded in ast.ast - ASTNode2ASTMinusNode that has exactly one child and
which is of type minus, i.e., this negates what is encoded in ast.public static ASTLogicalOperatorNode xor(ASTNode2... ast)
ASTLogicalOperatorNode of type ASTNode.Type.LOGICAL_XOR and
adds the given nodes as children.ast - ASTLogicalOperatorNode with the given nodes as children.