/** * Returns {@code true} if this model has a reference to the {@link UnitDefinition} with the * given identifier. * * @param id the id of the {@link UnitDefinition} to search for * @return {@code true} if this model has a reference to the {@link UnitDefinition} with the * given identifier, {@code false} otherwise. */ public boolean hasUnit(String id) { return getUnitDefinition(id) != null; }
/** * Returns {@code true} if this {@link Model} contains a reference to the * given * {@link UnitDefinition}. * * @param units * @return {@code true} if this {@link Model} contains a reference to the * given * {@link UnitDefinition}. */ public boolean containsUnitDefinition(String units) { return getUnitDefinition(units) != null; }
/** * * @return {@code true} if the UnistDefinition instance which has the timeUnitsID of * this KineticLaw as id is not {@code null}. * @deprecated */ @Deprecated public boolean isSetTimeUnitsInstance() { Model m = getModel(); return m != null ? m.getUnitDefinition(timeUnitsID) != null : false; }
/** * * @return {@code true} if the UnistDefinition instance which has the * substanceUnitsID of this KineticLaw as id is not {@code null}. * @deprecated */ @Deprecated public boolean isSetSubstanceUnitsInstance() { Model m = getModel(); return m != null ? m.getUnitDefinition(substanceUnitsID) != null : false; }
/** * Returns the {@link UnitDefinition} instance which has the * {@link #areaUnitsID} of * this {@link Model} as id. * * @return the {@link UnitDefinition} instance which has the * {@link #areaUnitsID} of * this {@link Model} as id. {@code null} if it doesn't exist. */ public UnitDefinition getAreaUnitsInstance() { return getUnitDefinition(getAreaUnits()); }
/** * Returns the {@link UnitDefinition} instance which has the * {@link #volumeUnitsID} * of this {@link Model} as id. * * @return the {@link UnitDefinition} instance which has the * {@link #volumeUnitsID} * of this {@link Model} as id. {@code null} if it doesn't exist. */ public UnitDefinition getVolumeUnitsInstance() { return getUnitDefinition(getVolumeUnits()); }
/** * Gets the {@link UnitDefinition} representing the time units of this * {@link Model}. * * @return the {@link UnitDefinition} representing the time units of this * {@link Model}, {@code null} if it is not defined in this * {@link Model} */ public UnitDefinition getTimeUnitsInstance() { return getUnitDefinition(getTimeUnits()); }
/** * Returns the {@link UnitDefinition} instance which has the extent units ID * of this Model as id. * * @return the {@link UnitDefinition} instance which has the extent units ID * of this Model as id. {@code null} if it doesn't exist */ public UnitDefinition getExtentUnitsInstance() { return getUnitDefinition(getExtentUnits()); }
/** * Returns the length units of this {@link Model} as a {@link UnitDefinition}. * * @return the {@link UnitDefinition} instance which has the * {@link #lengthUnitsID} of this * {@link Model} as id. {@code null} if it doesn't exist. */ public UnitDefinition getLengthUnitsInstance() { return getUnitDefinition(getLengthUnits()); }
/** * Returns the {@link UnitDefinition} which has the {@link #substanceUnitsID} * of this * {@link Model} as id. * * @return the {@link UnitDefinition} which has the {@link #substanceUnitsID} * of this * {@link Model} as id. {@code null} if it doesn't exist. */ public UnitDefinition getSubstanceUnitsInstance() { return getUnitDefinition(getSubstanceUnits()); }
/** * * @return the UnitDefinition instance which matches the unitsID of this * object. * @deprecated This is a requirement for Level 1 Version 1 and Version 2, * but can only be used in conjunction with {@link Parameter}s. * In this case this {@link AssignmentRule} represents the SBML * element ParameterRule. */ @Override @Deprecated public UnitDefinition getUnitsInstance() { Model model = getModel(); return model != null ? model.getUnitDefinition(unitsID) : null; }
/** * * @return {@code true} if the UnitsID of this object matches a no null * UniDefinition of the model instance. * @deprecated This is a requirement for Level 1 Version 1 and Version 2, * but can only be used in conjunction with {@link Parameter}s. * In this case this {@link AssignmentRule} represents the SBML * element ParameterRule. */ @Override @Deprecated public boolean isSetUnitsInstance() { Model model = getModel(); return model != null ? model.getUnitDefinition(unitsID) != null : false; }
/** * * @param unitsMap * @param model the original model from which a sub-model is to be created. * @param elementUnits */ private static void processUnitsMap(Map<String, UnitDefinition> unitsMap, Model model, String elementUnits) { Logger debugLogger = Logger.getLogger(SubModel.class); debugLogger.debug("processUnitsMap called with " + elementUnits); UnitDefinition unit = model.getUnitDefinition(elementUnits); debugLogger.debug("processUnitsMap: unit = " + elementUnits); if (unit != null && !unitsMap.containsKey(unit.getId())) { unitsMap.put(unit.getId(), unit); } }
/** * @return {@code true} if the {@link UnitDefinition} which has the * spatialSizeUnitsID of * this {@link Species} as id is not {@code null}. * @deprecated Only valid for SBML Level 2 Versions 1 and 2. */ @Deprecated public boolean isSetSpatialSizeUnitsInstance() { if (getModel() == null) { return false; } return getModel().getUnitDefinition(spatialSizeUnitsID) != null; }
@Override public UnitDefinition getUnitsInstance() { Model model = getModel(); return model != null ? model.getUnitDefinition(getUnits()) : null; }
@Override public UnitDefinition getDerivedUnitDefinition() { if (isSetUnitsInstance()) { return getUnitsInstance(); } String derivedUnits = getDerivedUnits(); // System.out.println("AbstractNamedSBaseWithUnit - getDerivedUnits " + getElementName() + " = " + derivedUnits + " (unitsID = " + unitsID + ", isSetUnits = " + isSetUnits() + ")"); Model model = getModel(); if ((model != null) && (derivedUnits != null) && !derivedUnits.isEmpty()) { return model.getUnitDefinition(derivedUnits); } return null; }
@Override @Deprecated public boolean isSetUnitsInstance() { if (isSetSubstanceUnitsInstance() && isSetTimeUnitsInstance()) { return true; } if (unitsID != null) { if (Unit.isUnitKind(unitsID, getLevel(), getVersion())) { return true; } Model model = getModel(); return model == null ? false : model.getUnitDefinition(unitsID) != null; } return false; }
@Override public boolean isSetUnitsInstance() { if (isSetUnits()) { if (Unit.isUnitKind(unitsID, getLevel(), getVersion())) { return true; } Model model = getModel(); return model == null ? false : model .getUnitDefinition(unitsID) != null; } return false; }
@Override public ASTNodeValue compile(double real, String units) { ASTNodeValue v = new ASTNodeValue(real, this); UnitDefinition ud; if (Unit.Kind.isValidUnitKindString(units, level, version)) { ud = new UnitDefinition(level, version); ud.addUnit(Unit.Kind.valueOf(units.toUpperCase())); v.setUnits(ud); } else if (model != null) { ud = model.getUnitDefinition(units); if (ud != null) { v.setUnits(ud); } } return v; }
@Override public boolean check(ValidationContext ctx, Parameter p) { if (p.isSetUnits()) { String units = p.getUnits(); Model m = p.getModel(); if (! (Unit.isUnitKind(units, ctx.getLevel(), ctx.getVersion()) || Unit.isPredefined(units, ctx.getLevel()) || (m != null && m.getUnitDefinition(units) != null))) { ValidationConstraint.logError(ctx, CORE_20701, p, p.getId(), p.getUnits()); return false; } } return true; } };