org.sbml.jsbml.math.compiler
T
- public class ASTNode2Value<T> extends java.lang.Object
ASTNode2
s, the ASTNode2Compiler
takes
elements of this class as arguments and performs its operations on it. Hence,
this class represents the union of all possible types to which an abstract
syntax tree can be evaluated, i.e., Boolean
,
CallableSBase
, Number
, or String
. This
class does not define what to do with these values or how to perform any
operations on it. It is just the container of a value. The type of this value
tells the ASTNode2Compiler
which operation was performed to obtain the
value stored in this object.Modifier and Type | Field and Description |
---|---|
private ASTNode2Compiler |
compiler
An
ASTNode2Compiler that is needed in the case that this
ASTNode2Value contains a derivative of
CallableSBase as value to translate this value into a
double. |
private int |
level
The level of the underlying
SBMLDocument . |
private ASTNode.Type |
type
The type of the underlying
ASTNode2 . |
private boolean |
uFlag
Flag to indicate whether the underlying
ASTNode2 was an unary
node. |
private UnitDefinition |
unitDef
The unit associated to the value of this object.
|
private T |
value
The actual value of this element.
|
private int |
version
The version of the underlying
SBMLDocument . |
Constructor and Description |
---|
ASTNode2Value(ASTNode.Type type,
ASTNode2Compiler compiler) |
ASTNode2Value(ASTNode2Compiler compiler) |
ASTNode2Value(T value,
ASTNode2Compiler compiler) |
ASTNode2Value(UnitDefinition unit,
ASTNode2Compiler compiler) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsUndeclaredUnits()
Flag to indicate whether or not units have been fully declared for this
value.
|
int |
getLevel()
Returns the level of the SBML document that was the basis to create this
ASTNode2Value . |
ASTNode.Type |
getType() |
UnitDefinition |
getUnits() |
T |
getValue() |
int |
getVersion() |
boolean |
isBoolean() |
boolean |
isCallableSBase() |
boolean |
isDifference() |
boolean |
isNode()
Checks whether the value encapsulated in this
ASTNodeValue is an
instance of Node . |
boolean |
isNumber() |
boolean |
isSetUnit()
Test if this value can be evaluated to a
UnitDefinition |
boolean |
isString() |
boolean |
isSum() |
boolean |
isUMinus() |
boolean |
isUnary() |
java.lang.String |
printValueAndUnit() |
void |
setLevel(int level) |
void |
setType(ASTNode.Type type) |
void |
setUIFlag(boolean uiFlag) |
void |
setUnits(UnitDefinition unit) |
void |
setValue(boolean value) |
void |
setValue(T value) |
void |
setVersion(int version) |
boolean |
toBoolean()
Analog to the toDouble() method but this method tries to evaluate the
value contained in this object to a boolean value.
|
CallableSBase |
toCallableSBase() |
double |
toDouble() |
float |
toFloat() |
int |
toInteger()
This method is analog to the toDouble method but tries to convert this
value into an integer.
|
long |
toLong() |
org.w3c.dom.Node |
toNode() |
java.lang.Number |
toNumber()
Tries to convert the value contained in this object into a double number.
|
java.lang.String |
toString() |
void |
unsetUnit()
Removes the unit of this element, i.e., the unit will become invalid.
|
private ASTNode2Compiler compiler
ASTNode2Compiler
that is needed in the case that this
ASTNode2Value
contains a derivative of
CallableSBase
as value to translate this value into a
double. If the compiler does not convert instances of
CallableSBase
to double numbers, a
ClassCastException
will be thrown..private int level
SBMLDocument
.private ASTNode.Type type
ASTNode2
.private boolean uFlag
ASTNode2
was an unary
node.private UnitDefinition unitDef
private T value
Object
, but indeed
we restrict the possibilities to store only certain types here.private int version
SBMLDocument
.public ASTNode2Value(ASTNode2Compiler compiler)
compiler
- public ASTNode2Value(T value, ASTNode2Compiler compiler)
value
- compiler
- ASTNode2Value(ASTNode.Type type, ASTNode2Compiler compiler)
type
- compiler
- public ASTNode2Value(UnitDefinition unit, ASTNode2Compiler compiler)
unit
- compiler
- public boolean containsUndeclaredUnits()
public int getLevel()
ASTNode2Value
.public ASTNode.Type getType()
public UnitDefinition getUnits()
public T getValue()
public int getVersion()
public boolean isBoolean()
public boolean isDifference()
public boolean isCallableSBase()
public boolean isNode()
ASTNodeValue
is an
instance of Node
.public boolean isNumber()
public boolean isSetUnit()
UnitDefinition
public boolean isString()
public boolean isSum()
public boolean isUMinus()
public boolean isUnary()
public java.lang.String printValueAndUnit()
public void setLevel(int level)
level
- the level to setpublic void setType(ASTNode.Type type)
type
- public void setUIFlag(boolean uiFlag)
uiFlag
- public void setUnits(UnitDefinition unit)
unit
- public void setValue(boolean value)
value
- public void setValue(T value)
value
- public void setVersion(int version)
version
- the version to setpublic boolean toBoolean() throws SBMLException
CallableSBase
, it
can only be converted into a boolean value if the
ASTNode2Compiler
associated with this object compiles this
value to an ASTNode2Value
that contains a boolean or at
least a Number
value.SBMLException
public double toDouble() throws SBMLException
SBMLException
public float toFloat() throws SBMLException
SBMLException
public int toInteger() throws SBMLException
SBMLException
public long toLong() throws SBMLException
SBMLException
public CallableSBase toCallableSBase()
public org.w3c.dom.Node toNode()
public java.lang.Number toNumber() throws SBMLException
ASTNodeValue
.
In case this ASTNodeValue
contains an instance of
Boolean
, zero is returned for false and one for true. If
the value is null or cannot be converted to any number,
Double.NaN
will be returned. Note that if the value of
this container is an instance of
CallableSBase
, the value can only be
converted to a number if the compiler associated with this
ASTNodeValue
compiles this
CallableSBase
to an ASTNodeValue
that
contains a Number
.SBMLException
public java.lang.String toString()
toString
in class java.lang.Object
public void unsetUnit()