@Override public String getPredefinedUnitID() { int level = getLevel(); if (level < 3) { return "substance"; } return null; }
/** * Creates a SimpleSpeciesReference instance from a given Species. * * @param species */ public SimpleSpeciesReference(Species species) { this(species.getLevel(), species.getVersion()); speciesID = species.isSetId() ? new String(species.getId()) : null; }
@Override public String getElementName() { if ((getLevel() == 1) && (getVersion() == 1)) { return "specie"; } return super.getElementName(); }
/** * Initializes the default values using the current Level/Version configuration. */ public void initDefaults() { initDefaults(getLevel(), getVersion()); }
/** * Sets the charge of this {@link Species}. * * @param charge the charge * @deprecated Only defined in SBML Level 1, Version 1 and 2, and Level 2 * Version 1. Since Level 2 Version 2 it has been marked as a * deprecated property, but has been completely removed in SBML * Level 3. * @throws PropertyNotAvailableException if Level >= 3. */ @Deprecated public void setCharge(int charge) { if (3 <= getLevel()) { throw new PropertyNotAvailableException(TreeNodeChangeEvent.charge, this); } Integer oldCharge = this.charge; this.charge = Integer.valueOf(charge); isSetCharge = true; firePropertyChange(TreeNodeChangeEvent.charge, oldCharge, this.charge); }
/** * Sets the speciesTypeID of this {@link Species} to 'speciesType'. * * @param speciesType the species type to set * @deprecated Only valid in SBML Level 2 from Version 2. * @throws PropertyNotAvailableException * for inappropriate Level/Version combinations. */ @Deprecated public void setSpeciesType(String speciesType) { if ((getLevel() != 2) || ((getLevel() == 2) && (getVersion() == 1))) { throw new PropertyNotAvailableException(TreeNodeChangeEvent.speciesType, this); } if ((speciesType == null) || (speciesType.trim().length() == 0) || checkIdentifier(speciesType)) { String oldSpeciesType = speciesTypeID; speciesTypeID = ((speciesType != null) && (speciesType.trim() .length() == 0)) ? null : speciesType; firePropertyChange(TreeNodeChangeEvent.speciesType, oldSpeciesType, speciesTypeID); } }
/** * Sets the conversionFactor of this {@link Species} to * 'conversionFactorID'. This is only possible if Level >= 3. * * @param conversionFactorID the conversion factor * @throws PropertyNotAvailableException if Level < 3. */ public void setConversionFactor(String conversionFactorID) { if (getLevel() < 3) { throw new PropertyNotAvailableException( TreeNodeChangeEvent.conversionFactor, this); } String oldConversionFactor = this.conversionFactorID; if ((conversionFactorID != null) && (conversionFactorID.trim().length() == 0)) { this.conversionFactorID = null; } else { this.conversionFactorID = conversionFactorID; } firePropertyChange(TreeNodeChangeEvent.conversionFactor, oldConversionFactor, conversionFactorID); }
@Override public boolean containsUndeclaredUnits() { boolean undeclared = super.containsUndeclaredUnits(); if (undeclared && (getLevel() > 2)) { Model model = getModel(); if ((model != null) && model.isSetSubstanceUnits()) { // In Level 3 a species inherits substance units from its model. // If the model declares the default substance units, the units of each // species are also declared. return false; } } return undeclared; }
/** * Returns the substanceUnits of this Species. * * @return the substanceUnits of this Species. */ public String getSubstanceUnits() { String units = getUnits(); if ((units == null) && (getLevel() > 2)) { Model model = getModel(); if ((model != null) && model.isSetSubstanceUnits()) { units = model.getSubstanceUnits(); } } return units; }
/** * Returns the substanceUnits of this Species as a {@link UnitDefinition} instance. * * @return The UnitsDefinition instance which has the substanceUnist of * this Species as id. */ public UnitDefinition getSubstanceUnitsInstance() { UnitDefinition ud = getUnitsInstance(); if ((ud == null) && (getLevel() > 2)) { Model model = getModel(); if ((model != null) && model.isSetSubstanceUnits()) { ud = model.getSubstanceUnitsInstance(); } } return ud; }
if (1 < getLevel()) { if (isSetInitialConcentration() && !isSetInitialAmount()) { attributes.put("initialConcentration", if (getLevel() < 3) { if (isSetCharge) { attributes.put(TreeNodeChangeEvent.charge, Integer.toString(getCharge())); if (getLevel() == 2) { if ((getVersion() == 1) || (getVersion() == 2)) { if (isSetSpatialSizeUnits()) { } else if (getLevel() == 3) { if (isSetConversionFactor()) { attributes.put("conversionFactor", getConversionFactor());
/** * Returns the derived species substance units, never dividing by the compartment units. * * @return the derived species substance units, never dividing by the compartment units. * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getDerivedUnitDefinition() */ public UnitDefinition getDerivedSubstanceUnitDefinition() { // We cannot use 'super.getDerivedUnitDefinition()' because the method Species.getDerivedUnits() cannot be used in this case // as it return null if hasOnlySubstanceUnits is 'false' and we just want to have the species units for this method UnitDefinition specUnit = null; Model model = getModel(); if (isSetUnitsInstance()) { specUnit = getUnitsInstance(); } else { String derivedUnits = super.getDerivedUnits(); // System.out.println("Species - getDerivedUnits " + getElementName() + " = " + derivedUnits + " (unitsID = " + unitsID + ", isSetUnits = " + isSetUnits() + ")"); if ((model != null) && (derivedUnits != null) && !derivedUnits.isEmpty()) { specUnit = model.getUnitDefinition(derivedUnits); } } if ((specUnit == null) && (getLevel() > 2) && (model != null) && (model.isSetSubstanceUnits())) { // According to SBML specification of Level 3 Version 1, page 44, lines 20-22: specUnit = model.getSubstanceUnitsInstance(); } return specUnit; }
/** * Sets hasOnlySubstanceUnits Boolean * * @param hasOnlySubstanceUnits the has only substance units value to be set * @throws PropertyNotAvailableException if Level < 2. */ public void setHasOnlySubstanceUnits(boolean hasOnlySubstanceUnits) { if (!isReadingInProgress() && getLevel() < 2) { throw new PropertyNotAvailableException( TreeNodeChangeEvent.hasOnlySubstanceUnits, this); } if (!isReadingInProgress() && hasOnlySubstanceUnits && isSetSpatialSizeUnits()) { String ud = isSetUnitsInstance() ? UnitDefinition.printUnits( getSpatialSizeUnitsInstance(), true) : getSpatialSizeUnits(); throw new SBMLException(MessageFormat.format( "Cannot define that species {0} with spatial size units {1} has only substance units.", toString(), ud)); } Boolean oldHasOnlySubstanceUnits = this.hasOnlySubstanceUnits; this.hasOnlySubstanceUnits = Boolean.valueOf(hasOnlySubstanceUnits); isSetHasOnlySubstanceUnits = true; firePropertyChange(TreeNodeChangeEvent.hasOnlySubstanceUnits, oldHasOnlySubstanceUnits, this.hasOnlySubstanceUnits); }
if (!isReadingInProgress() && (getLevel() != 2) && ((1 != getVersion()) || (2 != getVersion()))) { throw new PropertyNotAvailableException( TreeNodeChangeEvent.spatialSizeUnits, this);
if (getLevel() > 2 && !isSetHasOnlySubstanceUnits()) {