@Override public TreeNode getChildAt(int index) { if (index < 0) { throw new IndexOutOfBoundsException(MessageFormat.format( resourceBundle.getString("IndexSurpassesBoundsException"), index, 0)); } int count = super.getChildCount(), pos = 0; if (index < count) { return super.getChildAt(index); } else { index -= count; } if (isSetStoichiometryMath()) { if (pos == index) { return getStoichiometryMath(); } pos++; } throw new IndexOutOfBoundsException(MessageFormat.format( resourceBundle.getString("IndexExceedsBoundsException"), index, Math.min(pos, 0))); }
@Override public String printSpeciesReference() { StringBuilder sb = new StringBuilder(); if (isSetStoichiometry() && (getStoichiometry() != 1d)) { sb.append(StringTools.toString(getStoichiometry())); sb.append(' '); } else if (isSetStoichiometryMath()) { sb.append(getStoichiometryMath().getMath().toFormula()); sb.append(' '); } sb.append(super.printSpeciesReference()); return sb.toString(); }
@Override public boolean containsUndeclaredUnits() { if (isSetStoichiometryMath()) { return getStoichiometryMath().containsUndeclaredUnits(); } return isSetStoichiometry() ? false : true; }
private boolean checkStoichiometryMath(Model m, SpeciesReference ref, Set<String> definedSpecies) { if (ref.isSetStoichiometryMath() && ref.getStoichiometryMath().isSetMath()) { Queue<ASTNode> queue = new LinkedList<ASTNode>(); queue.offer(ref.getStoichiometryMath().getMath()); while (!queue.isEmpty()) { ASTNode node = queue.poll(); if (node.isName()) { String name = (node.getName() != null) ? node.getName() : ""; if (m.getSpecies(name) != null && !definedSpecies.contains(name)) { return false; } } queue.addAll(node.getListOfNodes()); } } return true; } };
reactionEqn.append(reactant.getStoichiometryMath().getMath() .compile(this)); } else if (reactant.getStoichiometry() != 1d) { reactionEqn.append(product.getStoichiometryMath().getMath() .compile(this)); } else if (product.getStoichiometry() != 1d) {
/** * Creates a SpeciesReference instance from a given SpeciesReference. * * @param speciesReference */ @SuppressWarnings("deprecation") public SpeciesReference(SpeciesReference speciesReference) { super(speciesReference); if (speciesReference.isSetStoichiometryMath()) { setStoichiometryMath(speciesReference.getStoichiometryMath() .clone()); } if (speciesReference.isSetStoichiometry()) { setStoichiometry(new Double(speciesReference.getStoichiometry())); } else { stoichiometry = speciesReference.stoichiometry == null ? null : new Double(speciesReference.stoichiometry); } if (speciesReference.isSetConstant()) { setConstant(new Boolean(speciesReference.isConstant())); } else { constant = speciesReference.constant == null ? null : new Boolean(speciesReference.constant); } if (speciesReference.isSetDenominator) { setDenominator(new Integer(speciesReference.getDenominator())); } else { denominator = speciesReference.denominator == null ? null : new Integer(speciesReference.denominator); } }
reactionEqn.append(reactant.getStoichiometryMath().getMath().toASTNode2() .compile((ASTNode2Compiler) this)); } else if (reactant.getStoichiometry() != 1d) { reactionEqn.append(product.getStoichiometryMath().getMath().toASTNode2() .compile((ASTNode2Compiler) this)); } else if (product.getStoichiometry() != 1d) {