@Override public int getLevel() { if (isSetExtendedASTNode()) { SBase parentSBase = extendedASTNode.getParentSBMLObject(); if (parentSBase != null) { return parentSBase.getLevel(); } } return -1; }
@Override public SBMLDocument getSBMLDocument() { if (isSetExtendedASTNode()) { SBase parentSBase = extendedASTNode.getParentSBMLObject(); if (parentSBase != null) { return parentSBase.getSBMLDocument(); } } return null; }
/** * Subtracts the given number from this node. * * @param real * a double number. * @return the current node for convenience. */ public ASTNode minus(double real) { minus(new ASTNode(real, getParentSBMLObject())); return this; }
/** * Adds an SBML element to this node. * * @param nsb * an SBML element that can be represented by a value. * @return the current node for convenience. */ public ASTNode plus(CallableSBase nsb) { plus(new ASTNode(nsb, getParentSBMLObject())); return this; }
/** * Applies the square root function on this syntax tree and returns the * resulting tree. * * @return the current node for convenience. */ public ASTNode sqrt() { arithmeticOperation(Type.FUNCTION_ROOT, new ASTNode(2, getParentSBMLObject())); return this; }
/** * Returns a new {@link ASTNode} that represents Euler's constant raised by the * power of the given exponent. * * @param exponent the exponent * @return a new {@link ASTNode} that represents Euler's constant raised by the * power of the given exponent. */ public static ASTNode exp(ASTNode exponent) { ASTNode e = new ASTNode(Type.CONSTANT_E, exponent.getParentSBMLObject()); return e.raiseByThePowerOf(exponent); }
/** * Adds a number to this node. * * @param real * a double number. * @return the current node for convenience. */ public ASTNode plus(double real) { plus(new ASTNode(real, getParentSBMLObject())); return this; }
@Override public int getVersion() { if (isSetExtendedASTNode()) { SBase parentSBase = extendedASTNode.getParentSBMLObject(); if (parentSBase != null) { return parentSBase.getVersion(); } } return -1; }
/** * Creates a root {@link ASTNode}. * * @param radicand * @return a root {@link ASTNode}. */ public static ASTNode sqrt(ASTNode radicand) { return root(new ASTNode(2, radicand.getParentSBMLObject()), radicand); }
/** * Multiplies this {@link ASTNode} with the given SBML element. * * @param nsb * an SBML element that can be represented by a value. * @return the current node for convenience. */ public ASTNode multiplyWith(CallableSBase nsb) { return multiplyWith(new ASTNode(nsb, getParentSBMLObject())); }
/** * Raises this ASTNode by the power of the value of this named SBase object. * * @param nsb * an SBML element that can be represented by a value. * @return the current node for convenience. */ public ASTNode raiseByThePowerOf(CallableSBase nsb) { return raiseByThePowerOf(new ASTNode(nsb, getParentSBMLObject())); }
public static boolean isLocalParameter(ASTNode node, String name) { MathContainer parent = node.getParentSBMLObject(); if (parent instanceof KineticLaw) { KineticLaw kl = (KineticLaw) parent; if (kl.isSetListOfLocalParameters()) { return kl.getLocalParameter(name) != null; } } return false; }
/** * Divides this node by the given SBML element. * * @param namedSBase * an SBML element that can be represented by a value. * @return the current node for convenience. */ public ASTNode divideBy(CallableSBase namedSBase) { return divideBy(new ASTNode(namedSBase, getParentSBMLObject())); }
/** * * @param integer * @param unitsID * @return */ public ASTNode minus(int integer, String unitsID) { minus(new ASTNode(integer, unitsID, getParentSBMLObject())); return this; }
/** * Adds an integer number to this node. * * @param integer * an integer number. * @return the current node for convenience. */ public ASTNode plus(int integer) { plus(new ASTNode(integer, getParentSBMLObject())); return this; }
/** * Creates a new {@link ASTNode} that of type DIVIDE with the given numerator and * denominator. * * @param numerator the numerator * @param denominator the denominator * @return a new {@link ASTNode} that of type DIVIDE with the given numerator and * denominator. */ public static ASTNode frac(int numerator, ASTNode denominator) { return frac(new ASTNode(numerator, denominator.getParentSBMLObject()), denominator); }
/** * Creates an {@link ASTNode} that performs a less than comparison between a * variable and another {@link ASTNode}. The parent SBML object will be * taken from the given {@link ASTNode}. * * @param variable the left child. * @param node the right child. * @return an {@link ASTNode} that performs a less than comparison between a * variable and another {@link ASTNode}. */ public static ASTNode lt(String variable, ASTNode node) { return lt(new ASTNode(variable, node.getParentSBMLObject()), node); }
@Override public ASTNodeValue uMinus(ASTNode value) throws DOMException, SBMLException { ASTNodeValue v = value.compile(this); v.setLevel(value.getParentSBMLObject().getLevel()); return uMinus(v); }
@Override public boolean check(ValidationContext ctx, ASTNode node) { if (node.isSetUnits()) { boolean isValid = SyntaxChecker.isValidId(node.getUnits(), ctx.getLevel(), ctx.getVersion()); if (!isValid) { ValidationConstraint.logErrorWithPostmessageCode(ctx, CORE_10311, CORE_10311 + "_MATH", node.getParentSBMLObject(), node.getUnits(), node.getParentSBMLObject().getElementName()); return false; } } return true; } };
@Override public ASTNodeValue delay(String delayName, ASTNode x, ASTNode delay, String timeUnit) throws DOMException, SBMLException { setLevel(x.getParentSBMLObject().getLevel()); return createApplyNode(createCSymbol(delayName, MathMLParser .getDefinitionURIdelay()), compile(x.toString()), compile(delay.toString())); }