org.sbml.jsbml.util.compilers
public class FormulaCompiler extends StringTools implements ASTNodeCompiler
Strings that represent the
content of ASTNodes. These can be used to save equations in SBML with
older than Level 2.DECIMAL_FORMAT, REAL_FORMAT, SCIENTIFIC_FORMAT, underscore| Constructor and Description |
|---|
FormulaCompiler() |
| Modifier and Type | Method and Description |
|---|---|
ASTNodeValue |
abs(ASTNode node)
The absolute value represented by the given
ASTNode. |
ASTNodeValue |
and(java.util.List<ASTNode> nodes) |
ASTNodeValue |
arccos(ASTNode node) |
ASTNodeValue |
arccosh(ASTNode node) |
ASTNodeValue |
arccot(ASTNode node) |
ASTNodeValue |
arccoth(ASTNode node) |
ASTNodeValue |
arccsc(ASTNode node) |
ASTNodeValue |
arccsch(ASTNode node) |
ASTNodeValue |
arcsec(ASTNode node) |
ASTNodeValue |
arcsech(ASTNode node) |
ASTNodeValue |
arcsin(ASTNode node) |
ASTNodeValue |
arcsinh(ASTNode node) |
ASTNodeValue |
arctan(ASTNode node) |
ASTNodeValue |
arctanh(ASTNode node) |
private static java.lang.StringBuffer |
arith(char operator,
java.lang.Object... elements)
Basic method which links several elements with a mathematical operator.
|
static java.lang.StringBuffer |
brackets(java.lang.Object sb) |
ASTNodeValue |
ceiling(ASTNode node) |
private java.lang.String |
checkBrackets(ASTNode node)
Creates brackets if needed.
|
private java.lang.String |
checkDenominatorBrackets(ASTNode nodes)
Creates brackets if needed.
|
ASTNodeValue |
compile(CallableSBase variable) |
ASTNodeValue |
compile(Compartment c) |
ASTNodeValue |
compile(double mantissa,
int exponent,
java.lang.String units)
Creates an
ASTNodeValue that represents a real number in
scientific notation, i.e., mantissa * 10^exponent, and the given units. |
ASTNodeValue |
compile(double real,
java.lang.String units) |
ASTNodeValue |
compile(int integer,
java.lang.String units) |
ASTNodeValue |
compile(java.lang.String name)
A compiler will also have to deal with a name.
|
private static boolean |
containsArith(java.lang.Object something)
Tests whether the String representation of the given object contains any
arithmetic symbols and if the given object is already sorrounded by
brackets.
|
ASTNodeValue |
cos(ASTNode node) |
ASTNodeValue |
cosh(ASTNode node) |
ASTNodeValue |
cot(ASTNode node) |
ASTNodeValue |
coth(ASTNode node) |
ASTNodeValue |
csc(ASTNode node) |
ASTNodeValue |
csch(ASTNode node) |
ASTNodeValue |
delay(java.lang.String delayName,
ASTNode x,
ASTNode y,
java.lang.String timeUnits)
Evaluates delay functions.
|
static java.lang.StringBuffer |
diff(java.lang.Object... subtrahents)
Returns the difference of the given elements as StringBuffer.
|
ASTNodeValue |
eq(ASTNode left,
ASTNode right)
Equal.
|
ASTNodeValue |
exp(ASTNode node) |
ASTNodeValue |
factorial(ASTNode node) |
ASTNodeValue |
floor(ASTNode node) |
ASTNodeValue |
frac(ASTNode numerator,
ASTNode denominator)
Fraction of two
ASTNodes |
ASTNodeValue |
frac(int numerator,
int denominator)
A fraction of two int values.
|
static java.lang.StringBuffer |
frac(java.lang.Object numerator,
java.lang.Object denominator)
Returns a fraction with the given elements as numerator and denominator.
|
ASTNodeValue |
function(FunctionDefinition func,
java.util.List<ASTNode> nodes) |
protected ASTNodeValue |
function(java.lang.String name,
ASTNode... nodes) |
ASTNodeValue |
function(java.lang.String name,
java.util.List<ASTNode> nodes) |
ASTNodeValue |
geq(ASTNode left,
ASTNode right)
Greater equal.
|
ASTNodeValue |
getConstantAvogadro(java.lang.String name)
Creates an
ASTNodeValue that represent's Avogadro's number. |
ASTNodeValue |
getConstantE() |
ASTNodeValue |
getConstantFalse() |
ASTNodeValue |
getConstantPi() |
ASTNodeValue |
getConstantTrue() |
ASTNodeValue |
getNegativeInfinity() |
ASTNodeValue |
getPositiveInfinity() |
protected static java.lang.StringBuffer |
getSpecies(SpeciesReference ref)
Returns the id of a PluginSpeciesReference object's belonging species as
an object of type StringBuffer.
|
protected static double |
getStoichiometry(SpeciesReference ref)
Returns the value of a PluginSpeciesReference object's stoichiometry
either as a double or, if the stoichiometry has an integer value, as an
int object.
|
ASTNodeValue |
gt(ASTNode left,
ASTNode right)
Greater than.
|
ASTNodeValue |
lambda(java.util.List<ASTNode> nodes)
The body of a
FunctionDefinition. |
private java.lang.String |
lambdaBody(java.util.List<ASTNode> nodes)
Creates the body of a lambda function, i.e., the argument list and the
actual mathematical operation, all comma separated and surrounded in
brackets.
|
ASTNodeValue |
leq(ASTNode left,
ASTNode right)
Less equal.
|
ASTNodeValue |
ln(ASTNode node)
Natural logarithm.
|
ASTNodeValue |
log(ASTNode node)
Logarithm of the given value to base 10.
|
ASTNodeValue |
log(ASTNode left,
ASTNode right)
Logarithm of the given value to the given base.
|
private ASTNodeValue |
logicalOperation(java.lang.String operator,
java.util.List<ASTNode> nodes) |
ASTNodeValue |
lt(ASTNode left,
ASTNode right)
Less than.
|
ASTNodeValue |
minus(java.util.List<ASTNode> nodes)
Subtraction.
|
ASTNodeValue |
neq(ASTNode left,
ASTNode right)
Not equal.
|
ASTNodeValue |
not(ASTNode node) |
ASTNodeValue |
or(java.util.List<ASTNode> nodes) |
ASTNodeValue |
piecewise(java.util.List<ASTNode> nodes) |
ASTNodeValue |
plus(java.util.List<ASTNode> nodes) |
ASTNodeValue |
pow(ASTNode left,
ASTNode right) |
static java.lang.StringBuffer |
pow(java.lang.Object basis,
java.lang.Object exponent)
Returns the basis to the power of the exponent as StringBuffer.
|
private java.lang.String |
relation(ASTNode left,
java.lang.String symbol,
ASTNode right) |
ASTNodeValue |
root(ASTNode rootExponent,
ASTNode radiant) |
ASTNodeValue |
root(double rootExponent,
ASTNode radiant) |
static java.lang.StringBuffer |
root(java.lang.Object exponent,
java.lang.Object basis)
Returns the exponent-th root of the basis as StringBuffer.
|
ASTNodeValue |
sec(ASTNode node) |
ASTNodeValue |
sech(ASTNode node) |
ASTNodeValue |
selector(java.util.List<ASTNode> nodes) |
ASTNodeValue |
sin(ASTNode node) |
ASTNodeValue |
sinh(ASTNode node) |
ASTNodeValue |
sqrt(ASTNode node)
Square root.
|
static java.lang.StringBuffer |
sqrt(java.lang.Object basis) |
static java.lang.StringBuffer |
sum(java.lang.Object... summands)
Returns the sum of the given elements as StringBuffer.
|
ASTNodeValue |
symbolTime(java.lang.String time)
The simulation time.
|
ASTNodeValue |
tan(ASTNode node) |
ASTNodeValue |
tanh(ASTNode node) |
ASTNodeValue |
times(java.util.List<ASTNode> nodes)
Product of all given
ASTNodes. |
static java.lang.StringBuffer |
times(java.lang.Object... factors)
Returns the product of the given elements as StringBuffer.
|
ASTNodeValue |
uMinus(ASTNode node)
Unary minus, i.e., negation of the given
ASTNode. |
ASTNodeValue |
unknownValue()
Dealing with a malformed
ASTNode. |
ASTNodeValue |
xor(java.util.List<ASTNode> nodes)
Exclusive or.
|
append, append, concat, concatStringBuilder, encodeForHTML, fill, fill, firstLetterLowerCase, firstLetterUpperCase, getWordForNumber, leadingZeros, newLine, parseSBMLBoolean, parseSBMLDouble, parseSBMLInt, parseSBMLShort, toHTML, toHTML, toString, toString, toXMLAnnotationString, toXMLMessageString, toXMLNotesStringprivate static final java.lang.StringBuffer arith(char operator,
java.lang.Object... elements)
operator - elements - public static final java.lang.StringBuffer brackets(java.lang.Object sb)
sb - private static boolean containsArith(java.lang.Object something)
something - public static final java.lang.StringBuffer diff(java.lang.Object... subtrahents)
subtrahents - public static final java.lang.StringBuffer frac(java.lang.Object numerator,
java.lang.Object denominator)
numerator - denominator - protected static final java.lang.StringBuffer getSpecies(SpeciesReference ref)
ref - protected static final double getStoichiometry(SpeciesReference ref)
ref - public static final java.lang.StringBuffer pow(java.lang.Object basis,
java.lang.Object exponent)
basis - exponent - public static final java.lang.StringBuffer root(java.lang.Object exponent,
java.lang.Object basis)
throws java.lang.NumberFormatException
exponent - basis - java.util.IllegalFormatException - If the given exponent represents a zero.java.lang.NumberFormatExceptionpublic static final java.lang.StringBuffer sqrt(java.lang.Object basis)
basis - public static final java.lang.StringBuffer sum(java.lang.Object... summands)
summands - public static final java.lang.StringBuffer times(java.lang.Object... factors)
factors - public ASTNodeValue abs(ASTNode node) throws SBMLException
ASTNodeCompilerASTNode.abs in interface ASTNodeCompilernode - Must be interpretable as a Number.SBMLExceptionpublic ASTNodeValue and(java.util.List<ASTNode> nodes) throws SBMLException
and in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arccos(ASTNode node) throws SBMLException
arccos in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arccosh(ASTNode node) throws SBMLException
arccosh in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arccot(ASTNode node) throws SBMLException
arccot in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arccoth(ASTNode node) throws SBMLException
arccoth in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arccsc(ASTNode node) throws SBMLException
arccsc in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arccsch(ASTNode node) throws SBMLException
arccsch in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arcsec(ASTNode node) throws SBMLException
arcsec in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arcsech(ASTNode node) throws SBMLException
arcsech in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arcsin(ASTNode node) throws SBMLException
arcsin in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arcsinh(ASTNode node) throws SBMLException
arcsinh in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arctan(ASTNode node) throws SBMLException
arctan in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue arctanh(ASTNode node) throws SBMLException
arctanh in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue ceiling(ASTNode node) throws SBMLException
ceiling in interface ASTNodeCompilerSBMLExceptionprivate java.lang.String checkBrackets(ASTNode node) throws SBMLException
node - SBMLExceptionprivate java.lang.String checkDenominatorBrackets(ASTNode nodes) throws SBMLException
nodes - SBMLExceptionpublic ASTNodeValue compile(Compartment c)
compile in interface ASTNodeCompilerpublic ASTNodeValue compile(double mantissa, int exponent, java.lang.String units)
ASTNodeCompilerASTNodeValue that represents a real number in
scientific notation, i.e., mantissa * 10^exponent, and the given units.compile in interface ASTNodeCompilermantissa - The number to be multiplied with ten to the power of the given
exponent.exponent - The exponent for the multiplier ten.units - The identifier of the units object associated with the number
represented by this element. Can be null if no units have been
defined.public ASTNodeValue compile(double real, java.lang.String units)
compile in interface ASTNodeCompilerunits - A String representing the Unit of the given number.
This can be the identifier of a UnitDefinition in the
model or a literal in Unit.Kind. Can be null if no units
have been defined.public ASTNodeValue compile(int integer, java.lang.String units)
compile in interface ASTNodeCompilerunits - A String representing the Unit of the given number.
This can be the identifier of a UnitDefinition in the
model or a literal in Unit.Kind. Can be null if no units
have been defined.public ASTNodeValue compile(CallableSBase variable)
compile in interface ASTNodeCompilerpublic ASTNodeValue compile(java.lang.String name)
ASTNodeCompilerSpecies in the
system. In case of numerical computation, the ASTNodeCompiler
must create an ASTNodeValue representing the current value of
this Species.compile in interface ASTNodeCompilerpublic ASTNodeValue cos(ASTNode node) throws SBMLException
cos in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue cosh(ASTNode node) throws SBMLException
cosh in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue cot(ASTNode node) throws SBMLException
cot in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue coth(ASTNode node) throws SBMLException
coth in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue csc(ASTNode node) throws SBMLException
csc in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue csch(ASTNode node) throws SBMLException
csch in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue delay(java.lang.String delayName, ASTNode x, ASTNode y, java.lang.String timeUnits) throws SBMLException
ASTNodeCompilerdelay in interface ASTNodeCompilerdelayName - the name of this delay function.y - an expression of a positive duration time (the amoutn of
delay)timeUnits - the units for the delay.SBMLExceptionpublic ASTNodeValue eq(ASTNode left, ASTNode right) throws SBMLException
ASTNodeCompilereq in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue exp(ASTNode node) throws SBMLException
exp in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue factorial(ASTNode node)
factorial in interface ASTNodeCompilerpublic ASTNodeValue floor(ASTNode node) throws SBMLException
floor in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue frac(ASTNode numerator, ASTNode denominator) throws SBMLException
ASTNodeCompilerASTNodesfrac in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue frac(int numerator, int denominator)
ASTNodeCompilerfrac in interface ASTNodeCompilerpublic ASTNodeValue function(FunctionDefinition func, java.util.List<ASTNode> nodes) throws SBMLException
function in interface ASTNodeCompilernodes - Values to be inserted into the parameter list of the
function.SBMLExceptionprotected ASTNodeValue function(java.lang.String name, ASTNode... nodes) throws SBMLException
name - nodes - SBMLExceptionpublic ASTNodeValue function(java.lang.String name, java.util.List<ASTNode> nodes) throws SBMLException
function in interface ASTNodeCompilername - nodes - SBMLExceptionpublic ASTNodeValue geq(ASTNode left, ASTNode right) throws SBMLException
ASTNodeCompilergeq in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue getConstantAvogadro(java.lang.String name)
ASTNodeCompilerASTNodeValue that represent's Avogadro's number.
Optionally, the compiler may associate the given name with this number.getConstantAvogadro in interface ASTNodeCompilername - An optional name for Avogadro's number.public ASTNodeValue getConstantE()
getConstantE in interface ASTNodeCompilerpublic ASTNodeValue getConstantFalse()
getConstantFalse in interface ASTNodeCompilerpublic ASTNodeValue getConstantPi()
getConstantPi in interface ASTNodeCompilerpublic ASTNodeValue getConstantTrue()
getConstantTrue in interface ASTNodeCompilerpublic ASTNodeValue getNegativeInfinity()
getNegativeInfinity in interface ASTNodeCompilerpublic ASTNodeValue getPositiveInfinity()
getPositiveInfinity in interface ASTNodeCompilerpublic ASTNodeValue gt(ASTNode left, ASTNode right) throws SBMLException
ASTNodeCompilergt in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue lambda(java.util.List<ASTNode> nodes) throws SBMLException
ASTNodeCompilerFunctionDefinition.lambda in interface ASTNodeCompilernodes - Place holders for arguments.SBMLExceptionprivate java.lang.String lambdaBody(java.util.List<ASTNode> nodes) throws SBMLException
nodes - SBMLExceptionpublic ASTNodeValue leq(ASTNode left, ASTNode right) throws SBMLException
ASTNodeCompilerleq in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue ln(ASTNode node) throws SBMLException
ASTNodeCompilerln in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue log(ASTNode node) throws SBMLException
ASTNodeCompilerlog in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue log(ASTNode left, ASTNode right) throws SBMLException
ASTNodeCompilerlog in interface ASTNodeCompilerSBMLExceptionprivate ASTNodeValue logicalOperation(java.lang.String operator, java.util.List<ASTNode> nodes) throws SBMLException
operator - nodes - SBMLExceptionpublic ASTNodeValue lt(ASTNode left, ASTNode right) throws SBMLException
ASTNodeCompilerlt in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue minus(java.util.List<ASTNode> nodes) throws SBMLException
ASTNodeCompilerminus in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue neq(ASTNode left, ASTNode right) throws SBMLException
ASTNodeCompilerneq in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue not(ASTNode node) throws SBMLException
not in interface ASTNodeCompilernode - This value must be interpretable as a Boolean.SBMLExceptionpublic ASTNodeValue or(java.util.List<ASTNode> nodes) throws SBMLException
or in interface ASTNodeCompilernodes - These values must be interpretable as a Boolean.SBMLExceptionpublic ASTNodeValue piecewise(java.util.List<ASTNode> nodes) throws SBMLException
piecewise in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue plus(java.util.List<ASTNode> nodes) throws SBMLException
plus in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue pow(ASTNode left, ASTNode right) throws SBMLException
pow in interface ASTNodeCompilerSBMLExceptionprivate java.lang.String relation(ASTNode left, java.lang.String symbol, ASTNode right) throws SBMLException
left - symbol - right - SBMLExceptionpublic ASTNodeValue root(ASTNode rootExponent, ASTNode radiant) throws SBMLException
root in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue root(double rootExponent, ASTNode radiant) throws SBMLException
root in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue sec(ASTNode node) throws SBMLException
sec in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue sech(ASTNode node) throws SBMLException
sech in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue sin(ASTNode node) throws SBMLException
sin in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue sinh(ASTNode node) throws SBMLException
sinh in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue sqrt(ASTNode node) throws SBMLException
ASTNodeCompilersqrt in interface ASTNodeCompilernode - This value must be interpretable as a Number.SBMLExceptionpublic ASTNodeValue symbolTime(java.lang.String time)
ASTNodeCompilersymbolTime in interface ASTNodeCompilertime - The name of the time symbol.ASTNodeValue that represents the current time.public ASTNodeValue tan(ASTNode node) throws SBMLException
tan in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue tanh(ASTNode node) throws SBMLException
tanh in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue times(java.util.List<ASTNode> nodes) throws SBMLException
ASTNodeCompilerASTNodes.times in interface ASTNodeCompilernodes - These values must be interpretable to Number.SBMLExceptionpublic ASTNodeValue uMinus(ASTNode node) throws SBMLException
ASTNodeCompilerASTNode.uMinus in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue unknownValue() throws SBMLException
ASTNodeCompilerASTNode.unknownValue in interface ASTNodeCompilerSBMLExceptionpublic ASTNodeValue xor(java.util.List<ASTNode> nodes) throws SBMLException
ASTNodeCompilerxor in interface ASTNodeCompilernodes - It must be possible to evaluate the given values to
Boolean.SBMLExceptionpublic ASTNodeValue selector(java.util.List<ASTNode> nodes) throws SBMLException
selector in interface ASTNodeCompilerSBMLException