@Override public boolean check(ValidationContext ctx, Compartment c) { if (c.isSetOutside() && (c.getOutsideInstance() == null)) { ValidationConstraint.logError(ctx, CORE_20504, c, c.getId(), c.getOutside()); return false; } return true; } };
@Override public Map<String, String> writeXMLAttributes() { Map<String, String> attributes = super.writeXMLAttributes(); int level = getLevel(); Locale en = Locale.ENGLISH; if (isSetUnits()) { attributes.put("units", getUnits()); if (isSetVolume()) { attributes.put("volume", StringTools.toString(en, getVolume())); if (isSetSpatialDimensions()) { attributes.put("spatialDimensions", level < 3 ? Short.toString((short) getSpatialDimensions()) : StringTools.toString(en, getSpatialDimensions())); if ((level < 3) && (((short) getSpatialDimensions()) - getSpatialDimensions() != 0d)) { logger.warn(MessageFormat.format( resourceBundle.getString("Compartment.writeXMLAttributes"), getSpatialDimensions())); if (isSetSize()) { attributes.put("size", StringTools.toString(en, getSize())); if (isSetConstant()) { attributes.put("constant", Boolean.toString(getConstant())); if (isSetCompartmentType()) { attributes.put("compartmentType", getCompartmentType());
/** * Returns the size of this compartment. * * @return the size of this compartment. */ public double getSize() { return getValue(); }
@Override public boolean check(ValidationContext ctx, Compartment c) { if (c.getSpatialDimensions() == 0 && (!c.isConstant())) { return false; } return true; } };
@Override public boolean check(ValidationContext ctx, Compartment c) { /* * Invalid use of the 'size' attribute for a * zero-dimensional compartment */ if (c.getSpatialDimensions() == 0 && c.isSetSize()) { return false; } return true; } };
@Override public boolean check(ValidationContext ctx, Compartment c) { /* * Invalid use of the 'units' attribute for a * zero-dimensional compartment */ if (c.getSpatialDimensions() == 0 && c.isSetUnits()) { return false; } return true; } };
ONDEXConcept concept = graph.getFactory().createConcept(compartment.getId(), dataSourceSBML, cc, etSBML); compartmentsById.put(compartment.getId(), concept); if (compartment.isSetName()) { concept.createConceptName(compartment.getName(), true); if (compartment.isSetNotes()) { concept.setDescription(compartment.getNotesString()); if (compartment.isSetCompartmentType()) { concept.createAttribute(compartmentTypeA, compartment.getCompartmentType(), true); concept.createAttribute(spatialDimensionsA, compartment.getSpatialDimensions(), false); if (compartment.isSetSize()) { concept.createAttribute(sizeA, compartment.getSize(), false); concept.createAttribute(constantA, compartment.getConstant(), false); if (compartment.isSetOutside()) { allOutsideOfs.put(concept, compartment.getOutside());
super(compartment); if (compartment.isSetCompartmentType()) { compartmentTypeID = new String(compartment.getCompartmentType()); } else { compartmentTypeID = compartment.compartmentTypeID == null ? null if (compartment.isSetSpatialDimensions()) { setSpatialDimensions(Double.valueOf(compartment.getSpatialDimensions())); } else { spatialDimensions = compartment.spatialDimensions == null ? null if (compartment.isSetOutside()) { setOutside(new String(compartment.getOutside())); } else { outsideID = compartment.outsideID == null ? null removeUserObject(JSBML.CLONING_IN_PROGRESS);
@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; }
for (int i = 0; i < model.getCompartmentCount(); i++) { Compartment compartment = model.getCompartment(i); if (compartment.isSetCompartmentType() && !compartment.isSetCompartmentTypeInstance()) { logger.warn(MessageFormat.format( bundle.getString("SBMLCoreParser.unknownReferenceError1"), "CompartmentType", "compartmentTypeID", compartment.getCompartmentType(), compartment.getElementName(), SBMLtools.getIdOrName(compartment))); if (compartment.isSetOutside() && !compartment.isSetOutsideInstance()) { logger.warn(MessageFormat.format( bundle.getString("SBMLCoreParser.unknownReferenceError1"), "Compartment", "outsideID", compartment.getOutside(), compartment.getElementName(), SBMLtools.getIdOrName(compartment))); if (compartment.isSetUnits() && !compartment.isSetUnitsInstance()) { logger.warn(MessageFormat.format( bundle.getString("SBMLCoreParser.unknownReferenceError1"), "UnitDefinition", "unitsID", compartment.getUnits(), compartment.getElementName(), SBMLtools.getIdOrName(compartment)));
@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; } };
/** * * @param id * @param name * @param compartment * @param fast * @param reversible * @return */ public Reaction buildReaction(String id, String name, Compartment compartment, boolean fast, boolean reversible) { return buildReaction(id, name, compartment != null ? compartment.getId() : null, fast, reversible); }
@Override public boolean check(ValidationContext ctx, Compartment c) { if (c.isSetOutside() && c.getSpatialDimensions() == 0) { Compartment outside = c.getOutsideInstance(); if (outside != null && outside.getSpatialDimensions() != 0) { ValidationConstraint.logError(ctx, CORE_20506, c, c.getId(), outside.getId()); return false; } } return true; } };
@Override public void setValue(double value) { double dim = getSpatialDimensions(); if (isReadingInProgress() || (dim > 0d) || Double.isNaN(dim)) { super.setValue(value); } else { throw new IllegalArgumentException(MessageFormat.format( resourceBundle.getString("Compartment.ERROR_MESSAGE_ZERO_DIM"), "size", getId())); } }
@Override public boolean check(ValidationContext ctx, Compartment c) { if (c.isSetCompartmentType() && c.getCompartmentTypeInstance() == null) { ValidationConstraint.logError(ctx, CORE_20510, c, c.getId(), c.getCompartmentType()); return false; } return true; } };
public void setUnits(String units) { if ((units != null) && (units.trim().length() == 0)) { unsetUnits(); return; if (0d == getSpatialDimensions() && !isReadingInProgress()) { throw new IllegalArgumentException(MessageFormat.format( resourceBundle.getString("Compartment.ERROR_MESSAGE_ZERO_DIM"), "units", getId())); unitsID = units; if (checkAttribute(TreeNodeChangeEvent.units)) firePropertyChange(TreeNodeChangeEvent.units, oldUnits, unitsID); if (!isReadingInProgress()) { throw new IllegalArgumentException(MessageFormat.format( JSBML.ILLEGAL_UNIT_EXCEPTION_MSG, units));
@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 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; }
/** * @return * @deprecated use {@link #getSpatialDimensions()} */ @Deprecated public double getSpatialDimensionsAsDouble() { return getSpatialDimensions(); }
@Override public boolean check(ValidationContext ctx, Compartment c) { if (c.getSpatialDimensions() == 2 && c.isSetUnits()) { UnitDefinition def = c.getUnitsInstance(); if (def == null) { return false; } boolean isArea = def.isVariantOfArea(); // boolean isDimensionless = def.isVariantOfDimensionless(); if (ctx.getLevel() == 2 && ctx.getVersion() == 1) { return isArea; } else { boolean isDimensionless = def.isVariantOfDimensionless(); return isDimensionless || isArea; } } return true; } };