/** * Returns the compartment instance which matches the outside id in Model. * Return null if no compartment instance matches the outside id. * * @return the compartment instance which matches the outside id in Model. * Return null if no compartment instance matches the outside id. */ public Compartment getOutsideInstance() { Model m = getModel(); return m != null ? m.getCompartment(outsideID) : null; }
/** * Returns {@code true} if the compartmentType instance which matches the * compartmentTypeID of this compartment is not {@code null}. * * @return {@code true} if the compartmentType instance which matches the * compartmentTypeID of this compartment is not {@code null}. */ @Deprecated public boolean isSetCompartmentTypeInstance() { Model m = getModel(); return m != null ? m.getCompartmentType(compartmentTypeID) != null : false; }
/** * Returns {@code true} if the compartment instance which matches the * outsideID of * this compartment is not {@code null}. * * @return {@code true} if the compartment instance which matches the * outsideID of * this compartment is not {@code null}. */ public boolean isSetOutsideInstance() { Model m = getModel(); return m != null ? m.getCompartment(outsideID) != null : false; }
/** * Returns the compartmentType instance in Model for this compartment * compartmentTypeID. Return null if there is no compartmentType * instance which matches this compartmentTypeID. * * @return the compartmentType instance in Model for this compartment * compartmentTypeID. Return null if there is no compartmentType * instance which matches this compartmentTypeID. */ @Deprecated public CompartmentType getCompartmentTypeInstance() { Model m = getModel(); return m != null ? m.getCompartmentType(compartmentTypeID) : null; }
@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; } };
@Override public UnitDefinition getUnitsInstance() { UnitDefinition ud = super.getUnitsInstance(); if ((ud == null) && (getLevel() > 2)) { int dim = (int) getSpatialDimensions(); if (dim - getSpatialDimensions() == 0d) { Model model = getModel(); if (model != null) { switch (dim) { case 1: return model.getLengthUnitsInstance(); case 2: return model.getAreaUnitsInstance(); case 3: return model.getVolumeUnitsInstance(); default: break; } } } } return ud; }
@Override public String getUnits() { String units = super.getUnits(); if ((units == null) && (getLevel() > 2)) { int dim = (int) getSpatialDimensions(); if (dim - getSpatialDimensions() == 0d) { Model model = getModel(); if (model != null) { switch (dim) { case 1: return model.getLengthUnits(); case 2: return model.getAreaUnits(); case 3: return model.getVolumeUnits(); default: break; } } } } return units; }
@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; }
@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; } };
double dim = getSpatialDimensions(); if ((dim - ((short) dim) == 0d)) { Model model = getModel(); if (model != null) {