/** * * @return the stoichiometry value of this {@link SpeciesReference} if it is * set, otherwise, depending on the Level attribute, 1 for Level < 3 * or {@link Double#NaN}. */ public double getStoichiometry() { if (isSetStoichiometry()) { return stoichiometry.doubleValue(); } return (getLevel() < 3) ? 1d : Double.NaN; }
@Override public void setConstant(boolean constant) { if (getLevel() < 3) { throw new PropertyNotAvailableException(TreeNodeChangeEvent.constant, this); } Boolean oldConstant = this.constant; this.constant = Boolean.valueOf(constant); isSetConstant = true; firePropertyChange(TreeNodeChangeEvent.constant, oldConstant, this.constant); }
@Override public String getElementName() { if ((getLevel() == 1) && (getVersion() == 1)) { return "specieReference"; } return super.getElementName(); }
/** * Initializes the default values using the current Level/Version configuration. */ public void initDefaults() { initDefaults(getLevel(), getVersion()); }
/** * Sets the denominator of this {@link SpeciesReference}. * * @param denominator * @deprecated */ @Deprecated public void setDenominator(int denominator) { if ((getLevel() == 1) && (getVersion() == 2)) { if (denominator < 0) { throw new IllegalArgumentException(MessageFormat.format( ILLEGAL_STOCHIOMETRY_VALUE, "denominator", stoichiometry)); } } Integer oldDenominator = this.denominator; this.denominator = denominator; isSetDenominator = true; firePropertyChange(TreeNodeChangeEvent.denominator, oldDenominator, this.denominator); }
/** * Sets the stoichiometry of this {@link SpeciesReference}. * * @param stoichiometry */ public void setStoichiometry(double stoichiometry) { if ((getLevel() == 1) && (getVersion() == 2)) { int stoch = (int) stoichiometry; if ((stoch < 0) || (stoch - stoichiometry != 0d)) { throw new IllegalArgumentException(MessageFormat.format( ILLEGAL_STOCHIOMETRY_VALUE, "stoichiometry", stoichiometry)); } } Double oldStoichiometry = this.stoichiometry; this.stoichiometry = Double.valueOf(stoichiometry); if (isSetStoichiometryMath()) { stoichiometryMath = null; } if (Double.isNaN(stoichiometry)) { isSetStoichiometry = false; } else { isSetStoichiometry = true; } firePropertyChange(TreeNodeChangeEvent.stoichiometry, oldStoichiometry, this.stoichiometry); }
/** * * @param math * @return * @deprecated since SBML Level 3 this should not be used anymore. */ @Deprecated public StoichiometryMath createStoichiometryMath(ASTNode math) { StoichiometryMath sm = new StoichiometryMath(getLevel(), getVersion()); sm.setMath(math); setStoichiometryMath(sm); return sm; }
@Override public Map<String, String> writeXMLAttributes() { Map<String, String> attributes = super.writeXMLAttributes(); if (isSetStoichiometry()) { attributes.put("stoichiometry", StringTools.toString( Locale.ENGLISH, getStoichiometry())); } if (isSetConstant()) { attributes.put("constant", Boolean.toString(isConstant())); } if (isSetDenominator() && (getLevel() == 1)) { int denominator = getDenominator(); if (denominator != 1) { attributes.put("denominator", Integer.toString(denominator)); } } return attributes; }
@Override public UnitDefinition getDerivedUnitDefinition() { if (isSetStoichiometryMath()) { return stoichiometryMath.getDerivedUnitDefinition(); } UnitDefinition ud = new UnitDefinition(getLevel(), getVersion()); ud.addUnit(Unit.Kind.DIMENSIONLESS); return ud; }
if (elementName.equals("stoichiometryMath") && speciesReference.getLevel() == 2) { StoichiometryMath stoichiometryMath = (StoichiometryMath) newContextObject; speciesReference.setStoichiometryMath(stoichiometryMath);