/** * Returns the length units ID of this {@link Model}. * * @return the length units ID of this {@link Model}. Returns an empty * {@link String} if it is not set. */ public String getLengthUnits() { if (isSetLengthUnits()) { return lengthUnitsID; } else if (getLevel() == 2) { return UnitDefinition.LENGTH; } return ""; }
model.getElementName(), SBMLtools.getIdOrName(model))); if (model.isSetLengthUnits() && !model.isSetLengthUnitsInstance()) { logger.warn(MessageFormat.format( bundle.getString("SBMLCoreParser.unknownReferenceError1"),
@Override public boolean check(ValidationContext ctx, Compartment c) { if (c.isSetSpatialDimensions() && c.getSpatialDimensions() == 1) { return c.isSetUnits() || c.getModel().isSetLengthUnits(); } return true; } };
@Override public boolean check(ValidationContext ctx, Model m) { if (m.isSetLengthUnits()) { UnitDefinition ud = m.getLengthUnitsInstance(); if (ud != null && ud.getUnitCount() == 0) { return false; } if (ud != null) { return ud.isVariantOfLength() || ud.isVariantOfDimensionless(); } } return true; } };
/** * Returns the value of unit * * @return the value of unit */ @Override public String getUnits() { if (isSetUnits()) { return unit; } Model model = getModel(); if (model.isSetLengthUnits()) { unit = model.getLengthUnits(); } // This is necessary if we cannot return null here. throw new PropertyUndefinedError(SpatialConstants.unit, this); }
@Override public int hashCode() { final int prime = 887; int hashCode = super.hashCode(); if (isSetTimeUnits()) { hashCode += prime * getTimeUnits().hashCode(); } if (isSetAreaUnits()) { hashCode += prime * getAreaUnits().hashCode(); } if (isSetConversionFactor()) { hashCode += prime * getConversionFactor().hashCode(); } if (isSetExtentUnits()) { hashCode += prime * getExtentUnits().hashCode(); } if (isSetLengthUnits()) { hashCode += prime * getLengthUnits().hashCode(); } if (isSetSubstanceUnits()) { hashCode += prime * getSubstanceUnits().hashCode(); } if (isSetVolumeUnits()) { hashCode += prime * getVolumeUnits().hashCode(); } return hashCode; }
@Override public Map<String, String> writeXMLAttributes() { Map<String, String> attributes = super.writeXMLAttributes(); if (getLevel() > 2) { if (isSetSubstanceUnits()) { attributes.put("substanceUnits", getSubstanceUnits()); } if (isSetTimeUnits()) { attributes.put("timeUnits", getTimeUnits()); } if (isSetVolumeUnits()) { attributes.put("volumeUnits", getVolumeUnits()); } if (isSetAreaUnits()) { attributes.put("areaUnits", getAreaUnits()); } if (isSetLengthUnits()) { attributes.put("lengthUnits", getLengthUnits()); } if (isSetExtentUnits()) { attributes.put("extentUnits", getExtentUnits()); } if (isSetConversionFactor()) { attributes.put("conversionFactor", getConversionFactor()); } } return attributes; }
equals &= getExtentUnits().equals(m.getExtentUnits()); equals &= m.isSetLengthUnits() == isSetLengthUnits(); if (equals && isSetLengthUnits()) { equals &= getLengthUnits().equals(m.getLengthUnits());
@Override public boolean containsUndeclaredUnits() { boolean undeclared = super.containsUndeclaredUnits(); if (undeclared && (getLevel() > 2)) { Model model = getModel(); if (model != null) { if (isSetSpatialDimensions()) { int spatialDim = (int) getSpatialDimensions(); if (getSpatialDimensions() - spatialDim == 0) { // In Level 3 a compartment inherits substance units from its model. // If the model declares the default size units, the units of each // compartment are also declared. switch (spatialDim) { case 0: return false; case 1: return !model.isSetLengthUnits(); case 2: return !model.isSetAreaUnits(); case 3: return !model.isSetVolumeUnits(); default: break; } } } } } return undeclared; }
setExtentUnits(model.getExtentUnits()); if (model.isSetLengthUnits()) { setLengthUnits(model.getLengthUnits());