@Override public boolean check(ValidationContext ctx, Compartment c) { return c.isSetUnits() || c.isSetSpatialDimensions(); } };
/** * Returns the {@link #spatialDimensions} of this {@link Compartment}. If it * is not set and the level of this {@link Compartment} is either one or two * it returns the default SBML Level 2 value, which is 3. In all other * cases, {@link Double#NaN} will be returned. * * @return the {@link #spatialDimensions} of this {@link Compartment} or 3 * if {@link #spatialDimensions} is not set and level is 1 or 2. */ public double getSpatialDimensions() { if (isSetSpatialDimensions() && (spatialDimensions != null)) { return spatialDimensions.doubleValue(); } if (getLevel() < 3) { // Although in Level 1, no spatial dimensions are defined, but // these are implicitly 3 due to the volume attribute. return 3d; } return Double.NaN; }
@Override public int hashCode() { final int prime = 991; int hashCode = super.hashCode(); if (isSetOutside()) { hashCode += prime * getOutside().hashCode(); } if (isSetCompartmentType()) { hashCode += prime * getCompartmentType().hashCode(); } if (isSetSpatialDimensions()) { hashCode += prime * spatialDimensions.hashCode(); } return hashCode; }
@Override public boolean check(ValidationContext ctx, Compartment c) { if (c.isSetSpatialDimensions() && c.getSpatialDimensions() == 2) { return c.isSetUnits() || c.getModel().isSetAreaUnits(); } return true; } };
@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, Compartment c) { if (c.isSetSpatialDimensions() && c.getSpatialDimensions() == 3) { return c.isSetUnits() || c.getModel().isSetVolumeUnits(); } return true; } };
if (compartment.isSetSpatialDimensions()) { setSpatialDimensions(Double.valueOf(compartment.getSpatialDimensions())); } else {
@Override public boolean equals(Object object) { boolean equals = super.equals(object); if (equals) { Compartment c = (Compartment) object; equals &= c.isSetOutside() == isSetOutside(); if (equals && isSetOutside()) { equals &= c.getOutside().equals(getOutside()); } equals &= c.isSetCompartmentType() == isSetCompartmentType(); if (equals && isSetCompartmentType()) { equals &= c.getCompartmentType().equals(getCompartmentType()); } // already checked by super class: // equals &= c.getSize() == getSize(); equals &= c.isSetSpatialDimensions() == isSetSpatialDimensions(); if (equals && isSetSpatialDimensions()) { equals &= c.getSpatialDimensions() == getSpatialDimensions(); } } return equals; }
if (isSetSpatialDimensions()) { attributes.put("spatialDimensions", level < 3 ? Short.toString((short) getSpatialDimensions())
@Override public boolean check(ValidationContext ctx, Compartment c) { Model m = c.getModel(); if (m != null && !c.isSetSize()) { if (c.isSetSpatialDimensions() && c.getSpatialDimensions() == 0) { return true; } if (ctx.getLevel() >= 3 && (!c.isSetSpatialDimensions())) { // There are no default for spatialDimensions in L3, so don't report this error if spatialDimensions is not set return true; } boolean sizeByAssignment = false; if (c.isSetId()) { sizeByAssignment = m.getInitialAssignmentBySymbol(c.getId()) != null; if (!sizeByAssignment) { Rule r = m.getRuleByVariable(c.getId()); sizeByAssignment = r != null && r.isAssignment(); } } return sizeByAssignment; } return true; } };
@Override public boolean check(ValidationContext ctx, ExplicitRule r) { Model m = r.getModel(); String var = r.getVariable(); if (r.isSetVariable() && m != null) { Compartment c = m.getCompartment(var); if (c != null && c.isSetSpatialDimensions() && c.getSpatialDimensions() == 0) { ValidationConstraint.logError(ctx, CORE_20911, r, r.getElementName(), r.getVariable()); return false; } } return true; } };
if ((c != null) && c.isSetSpatialDimensions() && (c.getSpatialDimensions() == 0d)) { return null;
@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; }
} else if (isSetSpatialDimensions()) { double dim = getSpatialDimensions(); if ((dim - ((short) dim) == 0d)) {
Compartment compartment = getCompartmentInstance(); if (compartment != null && (compartment.isSetSpatialDimensions() || getLevel() < 3) && (0d == compartment.getSpatialDimensions())) { return specUnit;