/** * Creates a new {@link ASTNode} of the given {@link Type} but without a * pointer to its {@link MathContainer}. * * @param type */ public ASTNode(Type type) { this(); setType(type); }
/** * Creates and returns a new {@link ASTNode}. * * @param type * the type of the ASTNode to create. * @param parent * the parent SBML object. */ public ASTNode(Type type, MathContainer parent) { this(parent); setType(type); }
@Override public ASTNodeValue getConstantE() { ASTNode eNode = new ASTNode(Math.E); eNode.setType(ASTNode.Type.CONSTANT_E); setNode(eNode); return dummy; }
@Override public ASTNodeValue getConstantPi() { ASTNode piNode = new ASTNode(Math.PI); piNode.setType(ASTNode.Type.CONSTANT_PI); setNode(piNode); return dummy; }
@Override public ASTNodeValue getConstantTrue() { ASTNode trueNode = new ASTNode(1); trueNode.setType(ASTNode.Type.CONSTANT_TRUE); setNode(trueNode); return dummy; }
@Override public ASTNodeValue getConstantFalse() { ASTNode falseNode = new ASTNode(0); falseNode.setType(ASTNode.Type.CONSTANT_FALSE); setNode(falseNode); return dummy; }
/** * Sets the type from a String. The method accept all the supported mathML * elements, the possible types of cn elements or the possible definitionURL * of csymbol elements. * * @param typeStr * the type as a String. */ public void setType(String typeStr) { if (isDebugEnabled) { logger.debug("ASTNode: setType(String) called: " + typeStr); } Type type = Type.getTypeFor(typeStr); setType(type); if (type != Type.UNKNOWN) { if (type == Type.REAL) { if (typeStr.equals("notanumber")) { setValue(Double.NaN); } else if (typeStr.equals("infinity")) { setValue(Double.POSITIVE_INFINITY); } } } }
@Override public ASTNodeValue vector(List<ASTNode> nodes) throws SBMLException { ASTNode vector = new ASTNode(); vector.setType(ASTNode.Type.VECTOR); for (int i = 0; i < nodes.size(); ++i) { nodes.get(i).compile(this); ASTNode node = getNode(); if (node.equals(new ASTNode("unknown"))) { unknownValue(); return dummy; } vector.addChild(getNode()); } setNode(vector); return dummy; }
double result = 1; node.getChildren().clear(); node.setType(ASTNode.Type.PLUS); if (values.size() > 0) { for (int i = 0; i < values.size(); ++i) {
boolean result = false; boolean isResultSet = false; node.setType(ASTNode.Type.LOGICAL_XOR); node.getChildren().clear(); if (values.size() > 0) {
boolean result = false; boolean isResultSet = false; node.setType(ASTNode.Type.LOGICAL_OR); node.getChildren().clear(); if (values.size() > 0) {
/** * @param values * @param vector * @throws SBMLException */ private void piecewiseRecursive(List<ASTNode> values, ASTNode vector) throws SBMLException{ if (!vector.isVector()) { vector.setType(ASTNode.Type.FUNCTION_PIECEWISE); vector.getChildren().clear(); for (ASTNode value : values) { vector.addChild(value); } return; } for (int i = 0; i < vector.getChildCount(); ++i) { List<ASTNode> children = new ArrayList<ASTNode>(); for (ASTNode value : values) { if (value.getChildCount() == 0) { children.add(value.clone()); } else if (value.isVector()) { if (value.getChildCount() != vector.getChildCount()) { throw new SBMLException(); } children.add(value.getChild(i).clone()); } } piecewiseRecursive(children, vector.getChild(i)); } } /* (non-Javadoc)
if (node.getChildCount() == 0) { if (useId) { node.setType(ASTNode.Type.FUNCTION_POWER); node.getChildren().clear(); node.addChild(left);
if (node.getChildCount() == 0) { if (useId) { node.setType(ASTNode.Type.RELATIONAL_LT); node.getChildren().clear(); node.addChild(left);
if (node.getChildCount() == 0) { if (useId) { node.setType(ASTNode.Type.RELATIONAL_EQ); node.getChildren().clear(); node.addChild(left);
if (node.getChildCount() == 0) { if (useId) { node.setType(ASTNode.Type.RELATIONAL_GEQ); node.getChildren().clear(); node.addChild(left);
if (node.getChildCount() == 0) { if (useId) { node.setType(ASTNode.Type.RELATIONAL_NEQ); node.getChildren().clear(); node.addChild(left);
if (node.getChildCount() == 0) { if (useId) { node.setType(ASTNode.Type.RELATIONAL_GT); node.getChildren().clear(); node.addChild(left);
if (node.getChildCount() == 0) { if (useId) { node.setType(ASTNode.Type.RELATIONAL_LEQ); node.getChildren().clear(); node.addChild(left);
node.setType(ASTNode.Type.RATIONAL); node.getChildren().clear(); node.addChild(left);