java.io.Serializable, java.lang.Cloneable, javax.swing.tree.TreeNode, TreeNodeWithChangeSupportpublic class ASTNode extends AbstractTreeNode
| Modifier and Type | Class | Description |
|---|---|---|
static class |
ASTNode.Type |
An enumeration of all possible types that can be represented by an
abstract syntax tree node.
|
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
IMPLEMENTATION_ASTNODE2 |
The String representing the facade implementation for the new
ASTNode2 implementation. |
static java.lang.String |
IMPLEMENTATION_HISTORIC |
The String representing the first implementation of the ASTNode, since 0.8.
|
static java.lang.String |
IMPLEMENTATION_VERSION |
The String representing the actual implementation of this class, values can be
IMPLEMENTATION_HISTORIC
or IMPLEMENTATION_ASTNODE2. |
static java.lang.String |
URI_AVOGADRO_DEFINITION |
The URI for the definition of the csymbol for avogadro.
|
static java.lang.String |
URI_DELAY_DEFINITION |
The URI for the definition of the csymbol for delay.
|
static java.lang.String |
URI_MATHML_DEFINITION |
URI for the definition of MathML.
|
static java.lang.String |
URI_MATHML_PREFIX |
URI prefix for the definition of MathML, it will be used to write the sbml file
|
static java.lang.String |
URI_RATE_OF_DEFINITION |
The URI for the definition of the csymbol for rateOf.
|
static java.lang.String |
URI_TIME_DEFINITION |
The URI for the definition of the csymbol for time.
|
| Constructor | Description |
|---|---|
ASTNode() |
Creates a new
ASTNode of unspecified type and without a pointer
to its containing MathContainer. |
ASTNode(char operator) |
Creates a new
ASTNode representing an operator, i.e., an internal
node. |
ASTNode(char operator,
MathContainer parent) |
Creates a new
ASTNode representing an operator, i.e., an internal
node. |
ASTNode(double real) |
Creates and returns a new
ASTNode. |
ASTNode(double mantissa,
int exponent) |
Creates and returns a new
ASTNode. |
ASTNode(double mantissa,
int exponent,
MathContainer parent) |
Creates and returns a new
ASTNode. |
ASTNode(double real,
MathContainer parent) |
Creates and returns a new
ASTNode. |
ASTNode(int integer) |
Creates and returns a new
ASTNode with the given integer value. |
ASTNode(int integer,
java.lang.String unitsID,
MathContainer parent) |
Creates and returns a new
ASTNode with the given integer value with
the given associated unitId for the
given MathContainer as its parent SBML object. |
ASTNode(int integer,
MathContainer parent) |
Creates and returns a new
ASTNode with the given integer value for
the
given MathContainer as its parent SBML object. |
ASTNode(java.lang.String name) |
Creates and returns a new
ASTNode with the given name. |
ASTNode(java.lang.String name,
MathContainer parent) |
Creates and returns a new
ASTNode with the given name. |
ASTNode(ASTNode astNode) |
Copy constructor; Creates a deep copy of the given
ASTNode. |
ASTNode(ASTNode.Type type) |
|
ASTNode(ASTNode.Type type,
MathContainer parent) |
Creates and returns a new
ASTNode. |
ASTNode(CallableSBase nsb) |
Creates and returns a new
ASTNode referring to the given CallableSBase. |
ASTNode(CallableSBase nsb,
MathContainer parent) |
Creates and returns a new
ASTNode referring to the given CallableSBase. |
ASTNode(ASTNode2 node) |
|
ASTNode(MathContainer parent) |
Creates and returns a new
ASTNode. |
| Modifier and Type | Method | Description |
|---|---|---|
static ASTNode |
abs(double d,
MathContainer parent) |
Creates and returns an
ASTNode that computes the absolute value
of the given double value. |
static ASTNode |
abs(int integer,
MathContainer parent) |
Creates and returns an
ASTNode that computes the absolute value
of the given integer value. |
void |
addChild(ASTNode child) |
Adds a child to this node.
|
void |
addExtension(java.lang.String nameOrUri,
ASTNodePlugin sbasePlugin) |
Adds a
ASTNodePlugin object to this ASTNode. |
void |
addPlugin(java.lang.String nameOrUri,
ASTNodePlugin sbasePlugin) |
Adds a
ASTNodePlugin object to this ASTNode. |
XMLNode |
addSemanticsAnnotation(XMLNode semanticsAnnotation) |
|
static java.lang.String |
astNodeToTree(ASTNode n,
java.lang.String tree,
java.lang.String indent) |
Returns a simple tree view of the ASTNode internal, including mainly
node type and hierarchy.
|
ASTNode |
clone() |
|
ASTNodeValue |
compile(ASTNodeCompiler compiler) |
Compiles this
ASTNode and returns the result. |
boolean |
containsUndeclaredUnits() |
Returns
true or false depending on whether this
ASTNode refers to elements such as parameters or numbers with
undeclared units. |
ASTNodePlugin |
createPlugin(java.lang.String nameOrUri) |
Creates a new
ASTNodePlugin for the given package name or URI
and adds it to this ASTNode. |
UnitDefinition |
deriveUnit() |
Evaluates recursively this ASTNode and creates a new UnitDefinition with
respect of all referenced elements.
|
static ASTNode |
diff(ASTNode... ast) |
Creates a new
ASTNode of type MINUS and adds the given nodes as children |
void |
disablePackage(java.lang.String packageURIOrName) |
Disables the given SBML Level 3 package on this
SBMLDocument. |
ASTNode |
divideBy(ASTNode ast) |
Divides this node by the given node
|
ASTNode |
divideBy(CallableSBase namedSBase) |
Divides this node by the given SBML element.
|
void |
enablePackage(java.lang.String packageURIOrName) |
Enables the given SBML Level 3 package on this
SBMLDocument. |
void |
enablePackage(java.lang.String packageURIOrName,
boolean enabled) |
Enables or disables the given SBML Level 3 package on this
SBMLDocument. |
static ASTNode |
eq(ASTNode left,
ASTNode right) |
Creates a new
ASTNode of type RELATIONAL_EQ. |
boolean |
equals(java.lang.Object object) |
|
static ASTNode |
exp(ASTNode exponent) |
Returns a new
ASTNode that represents Euler's constant raised by the
power of the given exponent. |
java.util.List<Parameter> |
findReferencedGlobalParameters() |
Goes through the formula and identifies all global parameters that are
referenced by this rate equation.
|
static java.lang.String |
formulaToString(ASTNode tree) |
Returns the formula from the given ASTNode as an SBML Level 1 text-string
mathematical formula.
|
static java.lang.String |
formulaToString(ASTNode tree,
FormulaCompiler compiler) |
Returns the formula from the given
ASTNode as an
infix mathematical formula produce by the given FormulaCompiler. |
static ASTNode |
frac(int numerator,
ASTNode denominator) |
Creates a new
ASTNode that of type DIVIDE with the given numerator and
denominator. |
static ASTNode |
frac(ASTNode numerator,
ASTNode denominator) |
Creates a new
ASTNode of type DIVIDE with the given nodes as children. |
static ASTNode |
frac(MathContainer container,
java.lang.String numeratorId,
java.lang.String denominatorId) |
Returns a new
ASTNode that of type DIVIDE with the two entities as numerator and denominator. |
static ASTNode |
frac(MathContainer container,
CallableSBase numerator,
CallableSBase denominator) |
Creates a new
ASTNode that divides two CallableSBase objects. |
static ASTNode |
geq(ASTNode left,
ASTNode right) |
Creates an
ASTNode representing greater or equal for
the two given nodes. |
boolean |
getAllowsChildren() |
|
char |
getCharacter() |
Gets the value of this node as a single character.
|
ASTNode |
getChild(int index) |
Gets a child of this node according to an index number.
|
javax.swing.tree.TreeNode |
getChildAt(int i) |
|
int |
getChildCount() |
|
java.util.List<ASTNode> |
getChildren() |
Returns the list of children of the current ASTNode.
|
java.lang.String |
getClassName() |
Returns the class name of the mathML element represented by this ASTNode.
|
java.lang.String |
getDefinitionURL() |
Returns the definitionURL
|
int |
getDenominator() |
Gets the value of the denominator of this node.
|
java.lang.String |
getEncoding() |
Returns the encoding of the mathML element represented by this ASTNode.
|
int |
getExponent() |
Gets the exponent value of this ASTNode.
|
ASTNodePlugin |
getExtension(java.lang.String nameOrUri) |
Returns the
ASTNodePlugin object which matches this package
name or URI. |
int |
getExtensionCount() |
Returns the number of
ASTNodePlugins of this ASTNode. |
java.util.Map<java.lang.String,ASTNodePlugin> |
getExtensionPackages() |
Returns the map containing all the
ASTNodePlugin extension objects
of this ASTNode. |
java.lang.String |
getId() |
Returns the id of the mathML element represented by this ASTNode.
|
int |
getInteger() |
Gets the value of this node as an integer.
|
ASTNode |
getLeftChild() |
Gets the left child of this node.
|
java.util.List<ASTNode> |
getListOfNodes() |
Returns the list of children of the current ASTNode.
|
java.util.List<ASTNode> |
getListOfNodes(Filter filter) |
Returns the list of children of the current ASTNode that satisfy the
given filter.
|
java.util.List<XMLNode> |
getListOfSemanticsAnnotations() |
Returns the list of semantics annotations of this node.
|
double |
getMantissa() |
Gets the mantissa value of this node.
|
java.lang.String |
getName() |
Gets the name of this node.
|
int |
getNumerator() |
Gets the value of the numerator of this node.
|
int |
getNumPlugins() |
Returns the number of
ASTNodePlugins of this ASTNode. |
int |
getNumSemanticsAnnotations() |
Gets the number of semantic annotation elements inside this node.
|
javax.swing.tree.TreeNode |
getParent() |
|
MathContainer |
getParentSBMLObject() |
This method is convenient when holding an object nested inside other
objects in an SBML model.
|
ASTNodePlugin |
getPlugin(java.lang.String nameOrUri) |
Returns an
ASTNodePlugin for an SBML Level 3 package extension
with the given package name or URI. |
double |
getReal() |
Gets the real-numbered value of this node.
|
java.util.Set<SBase> |
getReferencedNamedSBases() |
Returns a set of all the
NamedSBase referenced on this node and
all his descendant. |
ASTNode |
getRightChild() |
Returns the last child in the list of children of this node.
|
XMLNode |
getSemanticsAnnotation(int n) |
Gets the nth
<semantics> annotation of this node. |
java.lang.String |
getStyle() |
Returns the style of the mathML element represented by this ASTNode.
|
ASTNode.Type |
getType() |
Returns the type of this node.
|
java.lang.String |
getUnits() |
Returns the units attribute.
|
UnitDefinition |
getUnitsInstance() |
Creates or obtains a
UnitDefinition corresponding to the unit
that has been set for this ASTNode and returns a pointer to it. |
CallableSBase |
getVariable() |
Returns the variable of this node.
|
static ASTNode |
gt(ASTNode left,
ASTNode right) |
Creates an
ASTNode representing greater than for
the two given left and right child. |
int |
hashCode() |
|
boolean |
hasUnits() |
Returns
true if the current ASTNode or any of his descendant has a unit
defined. |
void |
insertChild(int n,
ASTNode newChild) |
|
boolean |
isBoolean() |
Returns
true if this node has a boolean type (a logical operator, a
relational operator, or the constants true or false). |
boolean |
isConstant() |
Returns
true if this node represents a MathML constant (e.g., true, Pi). |
boolean |
isDifference() |
Checks if this
ASTNode represents a difference. |
boolean |
isExtendedByOtherPackages() |
Returns
true if this object is extended by other packages. |
boolean |
isFunction() |
Returns
true if this node represents a function. |
boolean |
isInfinity() |
Returns
true if this node represents the special IEEE 754 value infinity,
false otherwise. |
boolean |
isInteger() |
Returns
true if this node contains an integer value, false otherwise. |
boolean |
isLambda() |
Returns
true if this node is a MathML <lambda>, false otherwise. |
boolean |
isLiteral() |
Returns
true if this node is constant or of type INTEGER, REAL or RATIONAL, false otherwise. |
boolean |
isLog10() |
Returns
true if this node represents a log10() function, false otherwise. |
boolean |
isLogical() |
Returns
true if this node is a MathML logical operator (i.e., and, or,
not, xor). |
boolean |
isMinusOne() |
Returns
true if this astnode represents the number minus one (either as
integer or as real value). |
boolean |
isName() |
Returns
true if this node is a user-defined Variable name in SBML L1, L2
(MathML), or the special symbols time, Avogadro or rateOf. |
boolean |
isNaN() |
Returns
true if this node is a type Real and represents the special IEEE
754 value 'not a number' Double.NaN, false otherwise. |
boolean |
isNegInfinity() |
Returns
true if this node represents the special IEEE 754 value 'negative
infinity' Double.NEGATIVE_INFINITY, false otherwise. |
boolean |
isNumber() |
Returns
true if this node contains a number, false otherwise. |
boolean |
isOne() |
Returns
true if this ASTNode represents the number one (either as
integer or as real value). |
boolean |
isOperator() |
Returns
true if this node is a mathematical operator, meaning, +, -, *, /
or ^ (power). |
boolean |
isPackageEnabled(java.lang.String packageURIOrName) |
Returns
true if the given SBML Level 3 package is enabled within
the containing SBMLDocument. |
boolean |
isPackageURIEnabled(java.lang.String packageURIOrName) |
Returns
true if the given SBML Level 3 package is enabled within
the containing SBMLDocument. |
boolean |
isPiecewise() |
Returns
true if this node is the MathML <piecewise> construct,
false otherwise. |
boolean |
isRational() |
Returns
true if this node represents a rational number, false otherwise. |
boolean |
isReal() |
Returns
true if this node can represent a real number, false otherwise. |
boolean |
isRelational() |
Returns
true if this node is a MathML relational operator, meaning ==,
>=, >, <, <=, and ! |
boolean |
isSemantics() |
Return true if this node contain some semantics annotations.
|
boolean |
isSetClassName() |
|
boolean |
isSetDefinitionURL() |
|
boolean |
isSetEncoding() |
|
boolean |
isSetId() |
|
boolean |
isSetName() |
|
boolean |
isSetNumberType() |
Returns
true if the number type is set. |
boolean |
isSetParentSBMLObject() |
Checks if a parent SBML object, i.e., a
MathContainer, is set as a
parent SBML object for this ASTNode. |
boolean |
isSetPlugin(java.lang.String nameOrUri) |
Returns
true if an ASTNodePlugin is defined
for the given package. |
boolean |
isSetStyle() |
|
boolean |
isSetUnits() |
Returns
true if a unit is defined on this node. |
boolean |
isSqrt() |
Returns
true if this node represents a square root function, false
otherwise. |
boolean |
isString() |
Returns
true if this node is a name or refers to a
FunctionDefinition. |
boolean |
isSum() |
Checks if this
ASTNode represents a sum. |
boolean |
isUMinus() |
Returns
true if this node is a unary minus operator, false otherwise. |
boolean |
isUnary() |
Checks whether the number of child nodes is exactly one.
|
boolean |
isUnknown() |
Returns
true if this node has an ASTNode.Type.UNKNOWN type. |
boolean |
isVariable() |
Returns
true if this node represents a Variable. |
boolean |
isVector() |
Checks if this
ASTNode represents a vector. |
boolean |
isZero() |
Returns
true if this node represents the number zero (either as integer
or as real value). |
static ASTNode |
leq(ASTNode left,
ASTNode right) |
Creates an
ASTNode representing less or equal for
the two given left and right child. |
static ASTNode |
log(ASTNode value) |
Creates an
ASTNode representing a logarithm to base 10 of the given value. |
static ASTNode |
log(ASTNode base,
ASTNode value) |
Creates an
ASTNode that represents the logarithm function with
the given base and value. |
static ASTNode |
lt(java.lang.String variable,
ASTNode node) |
|
static ASTNode |
lt(ASTNode left,
ASTNode right) |
|
ASTNode |
minus(double real) |
Subtracts the given number from this node.
|
ASTNode |
minus(int integer) |
Subtracts the given integer from this node.
|
ASTNode |
minus(int integer,
java.lang.String unitsID) |
|
ASTNode |
minus(ASTNode ast) |
Subtracts the given ASTNode from this node.
|
ASTNode |
multiplyWith(ASTNode ast) |
Multiplies this
ASTNode with the given node |
ASTNode |
multiplyWith(ASTNode... nodes) |
Multiplies this
ASTNode with the given nodes, i.e., all given nodes
will be children of this node, whose type will be set to ASTNode.Type.TIMES. |
ASTNode |
multiplyWith(CallableSBase nsb) |
Multiplies this
ASTNode with the given SBML element. |
static ASTNode |
neq(ASTNode left,
ASTNode right) |
|
static ASTNode |
parseFormula(java.lang.String formula) |
Parses a text-string mathematical formula and returns a representation as
an Abstract Syntax Tree.
|
static ASTNode |
parseFormula(java.lang.String formula,
IFormulaParser parser) |
Parses a text-string mathematical formula, using the given
IFormulaParser and returns a representation as
an Abstract Syntax Tree. |
static ASTNode |
parseMathML(java.lang.String mathML) |
|
static ASTNode |
piecewise(ASTNode node,
ASTNode... nodes) |
Creates a piecewise
ASTNode. |
static ASTNode |
piecewise(MathContainer parentSBMLObject,
ASTNode[] nodes) |
|
ASTNode |
plus(double real) |
Adds a number to this node.
|
ASTNode |
plus(int integer) |
Adds an integer number to this node.
|
ASTNode |
plus(ASTNode ast) |
Adds a given node to this node.
|
ASTNode |
plus(CallableSBase nsb) |
Adds an SBML element to this node.
|
static ASTNode |
pow(ASTNode basis,
double exponent) |
Creates a power
ASTNode. |
static ASTNode |
pow(ASTNode basis,
int exponent) |
Creates a power
ASTNode. |
static ASTNode |
pow(ASTNode basis,
ASTNode exponent) |
Creates a power
ASTNode. |
static ASTNode |
pow(MathContainer container,
CallableSBase basis,
CallableSBase exponent) |
Raises the given basis by the power of the given exponent.
|
void |
prependChild(ASTNode child) |
Adds the given node as a child of this ASTNode.
|
java.lang.String |
printASTNode() |
Returns the infix formula representing this ASTNode or an empty String if there was
a problem to construct the formula.
|
ASTNode |
raiseByThePowerOf(double exponent) |
Raises this
ASTNode by the power of the given number. |
ASTNode |
raiseByThePowerOf(ASTNode exponent) |
Raises this ASTNode by the power of the value of the given node.
|
ASTNode |
raiseByThePowerOf(CallableSBase nsb) |
Raises this ASTNode by the power of the value of this named SBase object.
|
static ASTNode |
readMathMLFromString(java.lang.String xml) |
Reads the MathML from the given XML string.
|
boolean |
refersTo(java.lang.String id) |
Returns
true if this node or one of its descendants contains some
identifier with the given id. |
boolean |
removeChild(int n) |
Removes child n of this ASTNode.
|
void |
replaceArgument(java.lang.String bvar,
ASTNode arg) |
Replaces occurrences of a name within this ASTNode with the
name/value/formula represented by the second argument ASTNode, e.g., if
the formula in this ASTNode is x + y; bvar is x and arg is an ASTNode
representing the real value 3 ReplaceArgument substitutes 3 for x within
this ASTNode.
|
ASTNode |
replaceChild(int n,
ASTNode newChild) |
Replaces the nth child of this ASTNode with the given ASTNode.
|
static ASTNode |
root(ASTNode rootExponent,
ASTNode radicand) |
Creates a root
ASTNode. |
void |
setCharacter(char value) |
Sets the value of this ASTNode to the given character.
|
void |
setClassName(java.lang.String className) |
Sets the class name of the mathML element represented by this ASTNode.
|
void |
setDefinitionURL(java.lang.String definitionURL) |
|
void |
setEncoding(java.lang.String encoding) |
Sets the encoding of the mathML element represented by this ASTNode.
|
void |
setId(java.lang.String id) |
Sets the id of the mathML element represented by this ASTNode.
|
void |
setIsSetNumberType(boolean isSetNumberType) |
|
void |
setName(java.lang.String name) |
Sets the value of this
ASTNode to the given name. |
static void |
setParentSBMLObject(ASTNode node,
MathContainer parent) |
Sets the Parent of the node and its children to the given value
|
void |
setParentSBMLObject(MathContainer parent) |
Sets the Parent of the node to the given value
|
void |
setStyle(java.lang.String style) |
Sets the style of the mathML element represented by this
ASTNode. |
void |
setType(java.lang.String typeStr) |
Sets the type from a String.
|
void |
setType(ASTNode.Type type) |
Sets the type of this ASTNode to the given Type.
|
void |
setUnits(java.lang.String unitId) |
Sets the units attribute.
|
void |
setUnits(Unit.Kind unit) |
|
void |
setUnits(UnitDefinition ud) |
|
void |
setValue(double value) |
Sets the value of this ASTNode to the given double number and sets the
node type to REAL.
|
void |
setValue(double mantissa,
int exponent) |
Sets the value of this ASTNode to the given real (double) in two parts:
the mantissa and the exponent.
|
void |
setValue(int value) |
Sets the value of this ASTNode to the given (long) integer and sets the
node type to INTEGER.
|
void |
setValue(int numerator,
int denominator) |
Sets the value of this ASTNode to the given rational in two parts: the
numerator and denominator.
|
void |
setVariable(CallableSBase variable) |
Allows you to directly set an instance of
CallableSBase as the
variable of this ASTNode. |
ASTNode |
sqrt() |
Applies the square root function on this syntax tree and returns the
resulting tree.
|
static ASTNode |
sqrt(ASTNode radicand) |
Creates a root
ASTNode. |
static ASTNode |
sum(ASTNode... ast) |
Creates a new
ASTNode of type Plus with the given nodes as children. |
static ASTNode |
sum(MathContainer parent,
CallableSBase... sbase) |
Sum of several NamedSBase objects.
|
void |
swapChildren(ASTNode that) |
|
static ASTNode |
times(ASTNode... ast) |
Creates an
ASTNode of type times and adds the given nodes as children. |
static ASTNode |
times(MathContainer parent,
CallableSBase... sbase) |
Multiplies several
CallableSBase objects. |
ASTNode2 |
toASTNode2() |
|
java.lang.String |
toFormula() |
Converts this
ASTNode to a text string using a specific syntax for
mathematical formulas. |
java.lang.String |
toFormula(FormulaCompiler compiler) |
Converts this
ASTNode to a text string using a specific FormulaCompiler. |
java.lang.String |
toLaTeX() |
Converts this node recursively into a LaTeX formatted String.
|
java.lang.String |
toMathML() |
Converts this node recursively into a MathML string that corresponds to
the subset of MathML defined in the SBML specification.
|
java.lang.String |
toSimpleString() |
Returns a simple String representing the content of the ASTNode.
|
java.lang.String |
toString() |
|
static ASTNode |
uMinus(ASTNode ast) |
Creates a new
ASTNode that has exactly one child and which is of type
minus, i.e., this negates what is encoded in ast. |
static ASTNode |
uMinus(MathContainer container,
CallableSBase sbase) |
Creates a new
ASTNode that has exactly one child and which is of type
minus, i.e., this negates what is encoded in ast. |
void |
unsetExtension(java.lang.String nameOrUri) |
Unsets the
ASTNodePlugin extension object which matches this package
name or URI. |
void |
unsetPlugin(java.lang.String nameOrUri) |
Unsets the
ASTNodePlugin plugin object which matches this package
name or URI. |
void |
unsetUnits() |
Unset the units attribute.
|
void |
updateVariables() |
For a better performance
ASTNodes can store a direct pointer to a
variable element. |
addAllChangeListeners, addAllChangeListeners, addTreeNodeChangeListener, addTreeNodeChangeListener, children, clearUserObjects, containsUserObjectKey, filter, filter, filter, fireNodeAddedEvent, fireNodeRemovedEvent, firePropertyChange, getIndex, getListOfTreeNodeChangeListeners, getNumChildren, getRoot, getTreeNodeChangeListenerCount, getUserObject, indexOf, isLeaf, isRoot, isSetParent, isSetUserObjects, putUserObject, removeAllTreeNodeChangeListeners, removeAllTreeNodeChangeListeners, removeFromParent, removeTreeNodeChangeListener, removeTreeNodeChangeListener, removeUserObject, setParent, userObjectKeySetpublic static final transient java.lang.String URI_AVOGADRO_DEFINITION
public static final transient java.lang.String URI_DELAY_DEFINITION
public static final transient java.lang.String URI_MATHML_DEFINITION
public static final java.lang.String URI_MATHML_PREFIX
public static final transient java.lang.String URI_RATE_OF_DEFINITION
public static final transient java.lang.String URI_TIME_DEFINITION
public static final java.lang.String IMPLEMENTATION_HISTORIC
public static final java.lang.String IMPLEMENTATION_ASTNODE2
ASTNode2 implementation.public static final java.lang.String IMPLEMENTATION_VERSION
IMPLEMENTATION_HISTORIC
or IMPLEMENTATION_ASTNODE2.public ASTNode()
ASTNode of unspecified type and without a pointer
to its containing MathContainer.public ASTNode(ASTNode astNode)
ASTNode.astNode - the ASTNode to be copied.public ASTNode(CallableSBase nsb)
ASTNode referring to the given CallableSBase.nsb - public ASTNode(CallableSBase nsb, MathContainer parent)
ASTNode referring to the given CallableSBase.nsb - parent - public ASTNode(char operator)
ASTNode representing an operator, i.e., an internal
node.operator - public ASTNode(char operator,
MathContainer parent)
ASTNode representing an operator, i.e., an internal
node.operator - parent - public ASTNode(double real)
ASTNode.real - public ASTNode(double mantissa,
int exponent)
ASTNode.mantissa - exponent - public ASTNode(double mantissa,
int exponent,
MathContainer parent)
ASTNode.mantissa - exponent - parent - public ASTNode(double real,
MathContainer parent)
ASTNode.real - parent - public ASTNode(int integer)
ASTNode with the given integer value.integer - public ASTNode(int integer,
MathContainer parent)
ASTNode with the given integer value for
the
given MathContainer as its parent SBML object.integer - parent - public ASTNode(int integer,
java.lang.String unitsID,
MathContainer parent)
ASTNode with the given integer value with
the given associated unitId for the
given MathContainer as its parent SBML object.integer - unitsID - parent - public ASTNode(MathContainer parent)
ASTNode.
By default, the returned node will have a type of ASTNode.Type.UNKNOWN.
The calling code should set the node type to something else as soon as
possible using setType(int)parent - the parent SBML objectpublic ASTNode(java.lang.String name)
ASTNode with the given name.name - the name of this ASTNodepublic ASTNode(java.lang.String name,
MathContainer parent)
ASTNode with the given name.name - the name of this ASTNodeparent - the parent SBML object.public ASTNode(ASTNode.Type type)
type - public ASTNode(ASTNode.Type type, MathContainer parent)
ASTNode.type - the type of the ASTNode to create.parent - the parent SBML object.public static ASTNode abs(double d, MathContainer parent)
ASTNode that computes the absolute value
of the given double value.public static ASTNode abs(int integer, MathContainer parent)
ASTNode that computes the absolute value
of the given integer value.public static ASTNode diff(ASTNode... ast)
ASTNode of type MINUS and adds the given nodes as childrenast - the children of the new ASTNodeASTNode of type MINUS and adds the given nodes as childrenpublic static ASTNode eq(ASTNode left, ASTNode right)
ASTNode of type RELATIONAL_EQ.left - the left child.right - the right child.ASTNode of type RELATIONAL_EQ.public static ASTNode exp(ASTNode exponent)
ASTNode that represents Euler's constant raised by the
power of the given exponent.exponent - the exponentASTNode that represents Euler's constant raised by the
power of the given exponent.public static java.lang.String formulaToString(ASTNode tree) throws SBMLException
tree - the root of the ASTNode formula expression treenull is
returned if the given argument is null.SBMLException - if the ASTNode is not well formed.toFormula()public static java.lang.String formulaToString(ASTNode tree, FormulaCompiler compiler) throws SBMLException
ASTNode as an
infix mathematical formula produce by the given FormulaCompiler.tree - the root of the ASTNode formula expression treecompiler - the FormulaCompiler to usenull is
returned if one of the given arguments is null.SBMLException - if the ASTNode is not well formed.toFormula(),
FormulaCompiler,
FormulaCompilerLibSBMLpublic static ASTNode frac(ASTNode numerator, ASTNode denominator)
ASTNode of type DIVIDE with the given nodes as children.numerator - the numeratordenominator - the denominatorASTNode of type DIVIDE with the given nodes as children.public static ASTNode frac(int numerator, ASTNode denominator)
ASTNode that of type DIVIDE with the given numerator and
denominator.numerator - the numeratordenominator - the denominatorASTNode that of type DIVIDE with the given numerator and
denominator.public static ASTNode frac(MathContainer container, CallableSBase numerator, CallableSBase denominator)
ASTNode that divides two CallableSBase objects.container - the parent objectnumerator - the numeratordenominator - the denominatorASTNode that divides two CallableSBase objects.public static ASTNode frac(MathContainer container, java.lang.String numeratorId, java.lang.String denominatorId)
ASTNode that of type DIVIDE with the two entities as numerator and denominator.container - the parent objectnumeratorId - the numeratordenominatorId - the numeratorASTNode that of type DIVIDE with the two entities as numerator and denominator.public static ASTNode geq(ASTNode left, ASTNode right)
ASTNode representing greater or equal for
the two given nodes.left - the left child.right - the right child.ASTNode representing greater or equal.public static ASTNode gt(ASTNode left, ASTNode right)
ASTNode representing greater than for
the two given left and right child.left - the left child.right - the right child.ASTNode representing greater than for
the two given left and right child.public static ASTNode leq(ASTNode left, ASTNode right)
ASTNode representing less or equal for
the two given left and right child.left - the left child.right - the right child.ASTNode representing less or equal for
the two given left and right child.public static ASTNode log(ASTNode value)
ASTNode representing a logarithm to base 10 of the given value.value - the value which is the argument of the logarithm.ASTNode representing a logarithm to base 10 of the given value.public static ASTNode log(ASTNode base, ASTNode value)
ASTNode that represents the logarithm function with
the given base and value. The parent SBML object will be taken from the
ASTNode value.base - The basis of this logarithm. Can be null; then a base of 10
will be assumed.value - Must not be null.ASTNode representing the logarithm of the given value
with respect to the given base or to the base 10 if base is null.public static ASTNode parseFormula(java.lang.String formula) throws ParseException
Support the syntax defined in FormulaParserLL3 which is almost the same syntax as defined in
the LibSBML L3 parser. The things not supported for now are the units associated with numbers.
Parsing of the various MathML functions and constants are all
case-sensitive by default: names such as
Cos and COS are not parsed as the MathML cosine
operator, <cos>. As well, if you have an SBML entities (species, parameter, ...) that
has an id identical to one of the supported mathML element, the parser will interpret the String as the
mathML element and not the SBML entity.
You can change this behaviour by using the FormulaParserLL3.setCaseSensitive(boolean)
method and using the parseFormula(String, IFormulaParser) method instead of this one:
FormulaParserLL3 caseSensitiveParser = new FormulaParserLL3(new StringReader(""));
caseInsensitiveParser.setCaseSensitive(false);
ASTNode n = ASTNode.parseFormula("Cos(x)", caseInsensitiveParser);
This method has a different behaviour since JSBML-1.0 compare to JSBML-0.8. There is a different
operator precedence, the parsing is now case sensitive for mathML elements and boolean operators are
now differently interpreted: '&&' and '||' are used instead of 'and' and 'or'.
If you want to use the parser used in JSBML-0.8, you can do that by using the FormulaParser
parser class and using the parseFormula(String, IFormulaParser) method instead of this one:
FormulaParser oldParser = new FormulaParser(new StringReader(""));
ASTNode n = ASTNode.parseFormula("x and y", oldParser);
If you are not satisfied with the behavior of the existing parsers, you can create
your own, you just need to implement the IFormulaParser interface.
formula - a text-string mathematical formula.ASTNode representing the formula.ParseException - If the given formula is not of valid format or cannot be
parsed for other reasons.parseFormula(String, IFormulaParser),
FormulaParserLL3,
FormulaParserpublic static ASTNode parseFormula(java.lang.String formula, IFormulaParser parser) throws ParseException
IFormulaParser and returns a representation as
an Abstract Syntax Tree.
Support the syntax defined in the IFormulaParser provided.
You can for example use you own parser or use an existing parser with different options.
For example, you can change the behaviour of the FormulaParserLL3 class by using the
FormulaParserLL3.setCaseSensitive(boolean) method:
FormulaParserLL3 caseSensitiveParser = new FormulaParserLL3(new StringReader(""));
caseInsensitiveParser.setCaseSensitive(false);
ASTNode n = ASTNode.parseFormula("Cos(x)", caseInsensitiveParser);
You can as well use the FormulaParser class to get the same parsing behaviour as in JSBML-0.8:
FormulaParser oldParser = new FormulaParser(new StringReader(""));
ASTNode n = ASTNode.parseFormula("x and y", oldParser);
If you are not satisfied with the behaviour of the existing parsers, you can create
your own, you just need to implement the IFormulaParser interface.
formula - a text-string mathematical formula.parser - a formula parser.ASTNode representing the formula.ParseException - If the given formula is not of valid format or cannot be
parsed for other reasons.parseFormula(String),
FormulaParserLL3,
FormulaParserpublic static ASTNode parseMathML(java.lang.String mathML)
mathML - a String in MathML format.ASTNode representation of the given MathML String.readMathMLFromString(String)public static ASTNode piecewise(MathContainer parentSBMLObject, ASTNode[] nodes)
parentSBMLObject - a link to the container in which this ASTNode will be
inserted. This can be useful if complex operations on units,
species, etc. are necessary when creating this formula.
Can be null.nodes - piecewise(ASTNode, ASTNode...)public static ASTNode pow(ASTNode basis, ASTNode exponent)
ASTNode.basis - the basisexponent - the exponentASTNode.public static ASTNode pow(ASTNode basis, double exponent)
ASTNode.basis - the basisexponent - the exponentASTNode.public static ASTNode pow(ASTNode basis, int exponent)
ASTNode.basis - the basisexponent - the exponentASTNode.public static ASTNode pow(MathContainer container, CallableSBase basis, CallableSBase exponent)
container - the parent objectbasis - the basisexponent - the exponentASTNode.public static ASTNode readMathMLFromString(java.lang.String xml)
Constructs a corresponding abstract syntax tree, and returns a pointer to the root of the tree.
xml - the MathML XML string.ASTNodepublic static ASTNode root(ASTNode rootExponent, ASTNode radicand)
ASTNode.radicand - the radicandrootExponent - the exponent of the root element.ASTNode.public static void setParentSBMLObject(ASTNode node, MathContainer parent)
node - the orphan nodeparent - the parentpublic static ASTNode sqrt(ASTNode radicand)
ASTNode.radicand - ASTNode.public static ASTNode sum(ASTNode... ast)
ASTNode of type Plus with the given nodes as children.ast - the children nodes.ASTNode of type Plus with the given nodes as children.public static ASTNode sum(MathContainer parent, CallableSBase... sbase)
parent - the parentsbase - public static ASTNode times(ASTNode... ast)
ASTNode of type times and adds the given nodes as children.ast - ASTNode of type times and adds the given nodes as children.public static ASTNode times(MathContainer parent, CallableSBase... sbase)
CallableSBase objects.parent - sbase - CallableSBase objects.public static ASTNode uMinus(ASTNode ast)
ASTNode that has exactly one child and which is of type
minus, i.e., this negates what is encoded in ast.ast - ASTNode that has exactly one child and which is of type
minus, i.e., this negates what is encoded in ast.public static ASTNode uMinus(MathContainer container, CallableSBase sbase)
ASTNode that has exactly one child and which is of type
minus, i.e., this negates what is encoded in ast.container - sbase - ASTNode that has exactly one child and which is of type
minus, i.e., this negates what is encoded in ast.public void addChild(ASTNode child)
child - the node to add as child.public ASTNode clone()
clone in class AbstractTreeNodepublic ASTNodeValue compile(ASTNodeCompiler compiler) throws SBMLException
ASTNode and returns the result.compiler - An instance of an ASTNodeCompiler that provides
methods to translate this ASTNode into something
different.ASTNodeValue. The content of the
wrapper depends on the ASTNodeCompiler used to create it.
However, this ASTNode will ensure that level and version
are set appropriately according to this node's parent SBML
object.SBMLException - Thrown if an error occurs during the compilation process.public boolean containsUndeclaredUnits()
true or false depending on whether this
ASTNode refers to elements such as parameters or numbers with
undeclared units.
A return value of true indicates that the UnitDefinition
returned by SBaseWithDerivedUnit.getDerivedUnitDefinition() may not accurately
represent the units of the expression.true if the math expression of this ASTNode
includes parameters/numbers with undeclared units,
false otherwise.public UnitDefinition deriveUnit() throws SBMLException
SBMLException - if they are problems going through the ASTNode tree.public ASTNode divideBy(ASTNode ast)
ast - an ASTNodepublic ASTNode divideBy(CallableSBase namedSBase)
namedSBase - an SBML element that can be represented by a value.public boolean equals(java.lang.Object object)
equals in class AbstractTreeNodepublic java.util.List<Parameter> findReferencedGlobalParameters()
public boolean getAllowsChildren()
public char getCharacter()
java.lang.IllegalArgumentException - if the type of the node is not one of PLUS, MINUS, TIMES,
DIVIDE or POWER.public ASTNode getChild(int index)
index - the index of the child to getASTNode with the given index.java.lang.IndexOutOfBoundsException - - if the index is out of range (index < 0 || index >=
size()).public javax.swing.tree.TreeNode getChildAt(int i)
public int getChildCount()
public java.util.List<ASTNode> getChildren()
public java.lang.String getClassName()
public java.lang.String getDefinitionURL()
public int getDenominator()
java.lang.IllegalArgumentException - if the method is called on a node that is not of type
rational.public java.lang.String getEncoding()
public int getExponent()
getType() returns REAL_E or REAL, otherwise an Exception is
thrown.java.lang.IllegalArgumentException - if the method is called on a node that is not of type real.public java.lang.String getId()
public int getInteger()
java.lang.IllegalArgumentException - if the node is not of type integer.public ASTNode getLeftChild()
public java.util.List<ASTNode> getListOfNodes()
public java.util.List<ASTNode> getListOfNodes(Filter filter)
filter - public double getMantissa()
public java.lang.String getName()
isOperator() == false) or numbers (isNumber() == false).java.lang.IllegalArgumentException - if the method is called on nodes that are operators or
numbers.public int getNumerator()
java.lang.IllegalArgumentException - if this method is called on a node type other than rational.public javax.swing.tree.TreeNode getParent()
getParent in interface javax.swing.tree.TreeNodegetParent in class AbstractTreeNodepublic MathContainer getParentSBMLObject()
MathContainer; element containing it. From this
MathContainer even the overall Model can be accessed.public double getReal()
isReal() == true, otherwise and Exception is thrown.
This function performs the necessary arithmetic if the node type is
REAL_E (mantissa^exponent) or RATIONAL (numerator / denominator).java.lang.IllegalArgumentException - if this node is not of type real.public java.util.Set<SBase> getReferencedNamedSBases()
NamedSBase referenced on this node and
all his descendant.
Just for testing purposes...NamedSBase referenced on this node and
all his descendant.public ASTNode getRightChild()
getListOfNodes().getLast().public java.lang.String getStyle()
public ASTNode.Type getType()
public java.lang.String getUnits()
public UnitDefinition getUnitsInstance()
UnitDefinition corresponding to the unit
that has been set for this ASTNode and returns a pointer to it.
Note that in case that this ASTNode is associated with a
Unit.Kind, the created UnitDefinition will not be part of
the model, it is just a container for the Unit.Kind.UnitDefinition or null.public CallableSBase getVariable()
isVariable() == true}, otherwise an Exception is thrown.java.lang.RuntimeException - if isVariable() returns false.public int hashCode()
hashCode in class AbstractTreeNodepublic boolean hasUnits()
true if the current ASTNode or any of his descendant has a unit
defined.true if the current ASTNode or any of his descendant has a unit
defined.public void insertChild(int n,
ASTNode newChild)
public boolean isBoolean()
true if this node has a boolean type (a logical operator, a
relational operator, or the constants true or false).true if this ASTNode is a boolean, false otherwise.public boolean isConstant()
true if this node represents a MathML constant (e.g., true, Pi).true if this ASTNode is a MathML constant, false otherwise.public boolean isDifference()
ASTNode represents a difference.true if this ASTNode represents a difference, false
otherwise.public boolean isFunction()
true if this node represents a function. In this context, the
term function means pre-defined functions such as "ceil", "abs" or "sin"
or whether this ASTNode refers to a user-defined
FunctionDefinition object. Without having a valid reference to
the MathContainer that owns this ASTNode it is impossible
to identify the referenced FunctionDefinition.true if this ASTNode is a function, false otherwise.public boolean isInfinity()
true if this node represents the special IEEE 754 value infinity,
false otherwise.true if this ASTNode is the special IEEE 754 value infinity,
false otherwise.public boolean isInteger()
true if this node contains an integer value, false otherwise.true if this ASTNode is of type INTEGER, false otherwise.public boolean isLambda()
true if this node is a MathML <lambda>, false otherwise.true if this ASTNode is of type LAMBDA, false otherwise.public boolean isLiteral()
true if this node is constant or of type INTEGER, REAL or RATIONAL, false otherwise.true if this ASTNode is constant or of type INTEGER, REAL or RATIONAL, false otherwise.public boolean isLog10()
true if this node represents a log10() function, false otherwise.
More precisely, this predicate returns true if the node type is
FUNCTION_LOG with two children, the first of which is an INTEGER equal to
10.true if the given ASTNode represents a log10() function, false
otherwise.public boolean isLogical()
true if this node is a MathML logical operator (i.e., and, or,
not, xor).true if this ASTNode is a MathML logical operator.public boolean isMinusOne()
true if this astnode represents the number minus one (either as
integer or as real value).true if this astnode represents the number minus one (either as
integer or as real value).public boolean isName()
true if this node is a user-defined Variable name in SBML L1, L2
(MathML), or the special symbols time, Avogadro or rateOf. The predicate returns
false otherwise.true if this ASTNode is a user-defined variable name in SBML L1,
L2 (MathML) or the special symbols time, Avogadro or rateOf.public boolean isNaN()
true if this node is a type Real and represents the special IEEE
754 value 'not a number' Double.NaN, false otherwise.true if this ASTNode is the Double.NaNpublic boolean isNegInfinity()
true if this node represents the special IEEE 754 value 'negative
infinity' Double.NEGATIVE_INFINITY, false otherwise.true if this ASTNode is Double.NEGATIVE_INFINITY, false
otherwise.public boolean isNumber()
true if this node contains a number, false otherwise. This is
functionally equivalent to the following code:
isInteger() || isReal()
true if this ASTNode is a number, false otherwise.public boolean isOne()
true if this ASTNode represents the number one (either as
integer or as real value).true if this ASTNode represents the number one.public boolean isOperator()
true if this node is a mathematical operator, meaning, +, -, *, /
or ^ (power).true if this ASTNode is an operator.public boolean isPiecewise()
true if this node is the MathML <piecewise> construct,
false otherwise.true if this ASTNode is a MathML piecewise functionpublic boolean isRational()
true if this node represents a rational number, false otherwise.true if this ASTNode is of type ASTNode.Type.RATIONAL.public boolean isReal()
true if this node can represent a real number, false otherwise.
More precisely, this node must be of one of the following types: REAL,
REAL_E or RATIONAL.true if the value of this ASTNode can represented a real number,
false otherwise.public boolean isRelational()
true if this node is a MathML relational operator, meaning ==,
>=, >, <, <=, and !=.true if this ASTNode is a MathML relational operator, false
otherwise.public boolean isSemantics()
getNumSemanticsAnnotations()public boolean isSetClassName()
public boolean isSetDefinitionURL()
public boolean isSetEncoding()
public boolean isSetId()
public boolean isSetName()
public boolean isSetNumberType()
true if the number type is set.true if the number type is set.public boolean isSetParentSBMLObject()
MathContainer, is set as a
parent SBML object for this ASTNode.public boolean isSetStyle()
public boolean isSetUnits()
true if a unit is defined on this node.true if a unit is defined on this node.public boolean isSqrt()
true if this node represents a square root function, false
otherwise.
More precisely, the node type must be ASTNode.Type.FUNCTION_ROOT with two
children, the first of which is an ASTNode.Type.INTEGER node having value
equal to 2.true if the given ASTNode represents a sqrt() function, false
otherwise.public boolean isString()
true if this node is a name or refers to a
FunctionDefinition.public boolean isSum()
ASTNode represents a sum.true if this ASTNode represents a sum, false otherwise.public boolean isUMinus()
true if this node is a unary minus operator, false otherwise. A
node is defined as a unary minus node if it is of type MINUS and has
exactly one child.
For numbers, unary minus nodes can be 'collapsed' by negating the number.
In fact, SBML_parseFormula() does this during its parse. However, unary
minus nodes for symbols (NAMES) cannot be 'collapsed', so this predicate
function is necessary.true if this ASTNode is a unary minus, false otherwise.public boolean isUnary()
true if the number of child nodes is exactly one.public boolean isUnknown()
true if this node has an ASTNode.Type.UNKNOWN type.
'Unknown' nodes have the type ASTNode.Type.UNKNOWN. Nodes with unknown types will not
appear in an ASTNode tree returned by JSBML based upon valid SBML
input; the only situation in which a node with type UNKNOWN may appear is
immediately after having created a new, untyped node using the ASTNode
constructor. Callers creating nodes should endeavor to set the type to a
valid node type as soon as possible after creating new nodes.true if this ASTNode is of type ASTNode.Type.UNKNOWN, false otherwise.public boolean isVariable()
true if this node represents a Variable.true if this node represents a Variable.public boolean isVector()
ASTNode represents a vector.true if this ASTNode represents a vector, false otherwise.public boolean isZero()
true if this node represents the number zero (either as integer
or as real value).true if this node represents the number zero.public ASTNode minus(ASTNode ast)
ast - an ASTNodepublic ASTNode minus(double real)
real - a double number.public ASTNode minus(int integer)
integer - an integer number.public ASTNode minus(int integer, java.lang.String unitsID)
integer - unitsID - public ASTNode multiplyWith(ASTNode ast)
ASTNode with the given nodeast - an ASTNodepublic ASTNode multiplyWith(ASTNode... nodes)
ASTNode with the given nodes, i.e., all given nodes
will be children of this node, whose type will be set to ASTNode.Type.TIMES.nodes - some ASTNodepublic ASTNode multiplyWith(CallableSBase nsb)
ASTNode with the given SBML element.nsb - an SBML element that can be represented by a value.public ASTNode plus(ASTNode ast)
ast - an ASTNodepublic ASTNode plus(CallableSBase nsb)
nsb - an SBML element that can be represented by a value.public ASTNode plus(double real)
real - a double number.public ASTNode plus(int integer)
integer - an integer number.public void prependChild(ASTNode child)
child - an ASTNodepublic ASTNode raiseByThePowerOf(ASTNode exponent)
exponent - an ASTNodepublic ASTNode raiseByThePowerOf(CallableSBase nsb)
nsb - an SBML element that can be represented by a value.public ASTNode raiseByThePowerOf(double exponent)
ASTNode by the power of the given number.exponent - a double number.public boolean refersTo(java.lang.String id)
true if this node or one of its descendants contains some
identifier with the given id. This method can be used to scan a formula
for a specific parameter or species and detect whether this component is
used by this formula. This search is done using a DFS.id - the id of an SBML element.true if this node or one of its descendants contains the
given id.public boolean removeChild(int n)
n - the index of the child to removepublic void replaceArgument(java.lang.String bvar,
ASTNode arg)
bvar - a string representing the variable name to be substitutedarg - an ASTNode representing the name/value/formula to substitutepublic ASTNode replaceChild(int n, ASTNode newChild)
n - long the index of the child to replacenewChild - ASTNode to replace the nth childpublic void setCharacter(char value)
value - the character value to which the node's value should be set.public void setClassName(java.lang.String className)
className - the class name.public void setDefinitionURL(java.lang.String definitionURL)
definitionURL - public void setEncoding(java.lang.String encoding)
encoding - the encodingpublic void setId(java.lang.String id)
id - the id.public void setIsSetNumberType(boolean isSetNumberType)
isSetNumberType - public void setName(java.lang.String name)
ASTNode to the given name.
The node type will be set (to ASTNode.Type.NAME) only if the ASTNode was previously an
operator (isOperator(node) == true) or number (isNumber(node) == true).
This allows names to be set for ASTNode.Type.FUNCTIONs and the like.name - public void setParentSBMLObject(MathContainer parent)
parent - the parentpublic void setStyle(java.lang.String style)
ASTNode.style - the style.public void setType(java.lang.String typeStr)
typeStr - the type as a String.public void setType(ASTNode.Type type)
type - the type to which this node should be setpublic void setUnits(java.lang.String unitId)
unitId - java.lang.IllegalArgumentException - if the ASTNode is not a kind of numbers (<cn> in mathml) or
if the unitId is not a valid unit kind or the id
of a unit definition.public void setUnits(Unit.Kind unit)
unit - public void setUnits(UnitDefinition ud)
ud - public void setValue(double value)
setValue(value, 0);
value - the double format number to which this node's value should be
setpublic void setValue(double mantissa,
int exponent)
mantissa - the mantissa of this node's real-numbered valueexponent - the exponent of this node's real-numbered valuepublic void setValue(int value)
value - public void setValue(int numerator,
int denominator)
numerator - the numerator value of the rationaldenominator - the denominator value of the rationalpublic void setVariable(CallableSBase variable)
CallableSBase as the
variable of this ASTNode. Note that if the given variable
does not have a declared id field, the pointer to this variable
will get lost when cloning this node. Only references to identifiers are
permanently stored. The pointer can also not be written to an SBML file
without a valid identifier.variable - a pointer to a CallableSBase.public ASTNode sqrt()
public void swapChildren(ASTNode that)
Swaps the children of this ASTNode with the children of that
ASTNode.
Unfortunately, when swapping child nodes, we have to recursively traverse the entire subtrees in order to make sure that all pointers to the parent SBML object are correct. However, this must only be done if the parent SBML object of that differs from the one surrounding this node.
In any case, the pointer from each sub-node to its parent must be changed.
In contrast to other SBML elements, ASTNodes have sub-nodes as
direct children, i.e., there is no child called 'ListOfNodes'. The
setParent method is also not recursive.
However, this might cause many calls to listeners.
that - the other node whose children should be used to replace this
node's childrenpublic java.lang.String toFormula()
throws SBMLException
ASTNode to a text string using a specific syntax for
mathematical formulas.
The text-string form of mathematical formulas produced by
toFormula() and read by parseFormula() are simple C-inspired infix
notation taken from SBML Level 1. A formula in this text-string form
therefore can be handed to a program that understands SBML Level 1
mathematical expressions, or used as part of a formula translation
system. Be careful that the default FormulaCompilerLibSBML used produce an output
a bit different than pure SBML level 1 mathematical expressions, in particular
for logical and relational operators.
ASTNode as an SBML Level 1 text-string
mathematical formula.SBMLException - if there is a problem in the ASTNode tree.public java.lang.String toFormula(FormulaCompiler compiler) throws SBMLException
ASTNode to a text string using a specific FormulaCompiler.compiler - ASTNode. null is
returned if the given compiler is null.SBMLException - if there is a problem in the ASTNode tree.FormulaCompiler,
FormulaCompilerLibSBMLpublic java.lang.String toLaTeX()
throws SBMLException
SBMLException - if there is a problem in the ASTNode tree.public java.lang.String toMathML()
public java.lang.String toString()
toString in class AbstractTreeNodepublic java.lang.String printASTNode()
public java.lang.String toSimpleString()
public void unsetUnits()
public void updateVariables()
ASTNodes can store a direct pointer to a
variable element. This is particularly useful when performing more
complex computation on these data structures. However, if the model is
changed, it may happen that these pointer become invalid. For instance, a
previously local parameter may be added to the model in form of a global
parameter while keeping the same identifier. The local parameter may then
be removed. Whenever performing changes like this, you may want to update
pointers within ASTNode constructs as well.public static java.lang.String astNodeToTree(ASTNode n, java.lang.String tree, java.lang.String indent)
n - tree - indent - public XMLNode addSemanticsAnnotation(XMLNode semanticsAnnotation)
XMLNode as a MathML <semantics>
element to this ASTNode.
The <semantics> element is a MathML 2.0 construct
that can be used to associate additional information with a MathML
construct. The construct can be used to decorate a MathML expressions with
a sequence of one or more <annotation> or
<annotation-xml> elements. Each such element contains a
pair of items; the first is a symbol that acts as an attribute or key, and
the second is the value associated with the attribute or key. Please refer
to the MathML 2.0 documentation, particularly the Section
5.2, Semantic Annotations for more information about these constructs.
semanticsAnnotation - the annotation to add.XMLNode.public int getNumSemanticsAnnotations()
The <semantics> element is a MathML 2.0 construct
that can be used to associate additional information with a MathML
construct. The construct can be used to decorate a MathML expressions with
a sequence of one or more <annotation> or
<annotation-xml> elements. Each such element contains a
pair of items; the first is a symbol that acts as an attribute or key, and
the second is the value associated with the attribute or key. Please refer
to the MathML 2.0 documentation, particularly the Section
5.2, Semantic Annotations for more information about these constructs.
ASTNode.addSemanticsAnnotation(XMLNode semanticsAnnotation)public XMLNode getSemanticsAnnotation(int n)
<semantics> annotation of this node.
The <semantics> element is a MathML 2.0 construct
that can be used to associate additional information with a MathML
construct. The construct can be used to decorate a MathML expressions with
a sequence of one or more <annotation> or
<annotation-xml> elements. Each such element contains a
pair of items; the first is a symbol that acts as an attribute or key, and
the second is the value associated with the attribute or key. Please refer
to the MathML 2.0 documentation, particularly the Section
5.2, Semantic Annotations for more information about these constructs.
ASTNode, or null if this node has
no nth annotation (n >
getNumSemanticsAnnotations()
- 1 or n < 0).addSemanticsAnnotation(XMLNode sAnnotation)public java.util.List<XMLNode> getListOfSemanticsAnnotations()
public ASTNodePlugin createPlugin(java.lang.String nameOrUri)
ASTNodePlugin for the given package name or URI
and adds it to this ASTNode.
If an ASTNodePlugin was already present in this ASTNode
it will be replaced.
nameOrUri - the package name or URIASTNodePlugin for the given package name or URIpublic void addExtension(java.lang.String nameOrUri,
ASTNodePlugin sbasePlugin)
ASTNodePlugin object to this ASTNode.
If a previous ASTNodePlugin associated with the same package
was present before, it will be replaced.
nameOrUri - the name or URI of the package extension.sbasePlugin - the ASTNodePlugin to add.public void addPlugin(java.lang.String nameOrUri,
ASTNodePlugin sbasePlugin)
ASTNodePlugin object to this ASTNode.
If a previous ASTNodePlugin associated with the same package
was present before, it will be replaced.
nameOrUri - the name or URI of the package extension.sbasePlugin - the ASTNodePlugin to add.addExtension(String, ASTNodePlugin)public void disablePackage(java.lang.String packageURIOrName)
SBMLDocument.packageURIOrName - a package namespace URI or package namepublic void enablePackage(java.lang.String packageURIOrName)
SBMLDocument.packageURIOrName - a package namespace URI or package namepublic void enablePackage(java.lang.String packageURIOrName,
boolean enabled)
SBMLDocument.packageURIOrName - a package namespace URI or package nameenabled - a boolean to tell if the package need to be enabled or disabled. It
true the package will be enabled, otherwise it will be
disabled.public ASTNodePlugin getExtension(java.lang.String nameOrUri)
ASTNodePlugin object which matches this package
name or URI.nameOrUri - the package name or URIASTNodePlugin object which matches this package
name or URI,
null is returned if nothing matching the name or URI is found.public int getExtensionCount()
ASTNodePlugins of this ASTNode.ASTNodePlugins of this ASTNode.public int getNumPlugins()
ASTNodePlugins of this ASTNode.ASTNodePlugins of this ASTNode.public ASTNodePlugin getPlugin(java.lang.String nameOrUri)
ASTNodePlugin for an SBML Level 3 package extension
with the given package name or URI.
If no ASTNodePlugin is found for this package, a new
ASTNodePlugin is created, added to this ASTNode and returned.
nameOrUri - the name or URI of the packageASTNodePlugin for an SBML Level 3 package extension
with the given package name or URI.public boolean isExtendedByOtherPackages()
true if this object is extended by other packages.true if this object is extended by other packages.public boolean isPackageEnabled(java.lang.String packageURIOrName)
true if the given SBML Level 3 package is enabled within
the containing SBMLDocument.packageURIOrName - the name or URI of the package extension.true if the given SBML Level 3 package is enabled within
the containing SBMLDocument, false otherwise.public boolean isPackageURIEnabled(java.lang.String packageURIOrName)
true if the given SBML Level 3 package is enabled within
the containing SBMLDocument.packageURIOrName - the name or URI of the package extension.true if the given SBML Level 3 package is enabled within
the containing SBMLDocument, false otherwise.isPackageEnabled(String)public boolean isSetPlugin(java.lang.String nameOrUri)
true if an ASTNodePlugin is defined
for the given package.nameOrUri - the package name or URItrue if an ASTNodePlugin is defined
for the given package.public void unsetExtension(java.lang.String nameOrUri)
ASTNodePlugin extension object which matches this package
name or URI.nameOrUri - the package name or URIpublic void unsetPlugin(java.lang.String nameOrUri)
ASTNodePlugin plugin object which matches this package
name or URI.nameOrUri - the package name or URIunsetExtension(String)public java.util.Map<java.lang.String,ASTNodePlugin> getExtensionPackages()
ASTNodePlugin extension objects
of this ASTNode.ASTNodePlugin extension objects
of this ASTNode.