public class ListOfCompartments extends ListOf
Compartment
objects.
The various ListOf___ classes in SBML
are merely containers used for organizing the main components of an SBML
model. In libSBML's implementation, ListOf___
classes are derived from the
intermediate utility class ListOf
, which
is not defined by the SBML specifications but serves as a useful
programmatic construct. ListOf
is itself is in turn derived from SBase
,
which provides all of the various ListOf___
classes with common features
defined by the SBML specification, such as 'metaid' attributes and
annotations.
The relationship between the lists and the rest of an SBML model is illustrated by the following (for SBML Level 2 Version 4):
SBML Level 3 Version 1 has essentially the same structure as Level 2 Version 4, depicted above, but SBML Level 3 Version 2 allows containers to contain zero or more of the relevant object, instead of requiring at least one. As such, libsbml will write out an otherwise-empty ListOf___ element that has any optional attribute set (such as 'id' or 'metaid'), that has an optional child (such as a 'notes' or 'annotation'), or that has attributes or children set from any SBML Level 3 package, whether or not the ListOf___ has any other children.
Readers may wonder about the motivations for using the ListOf___
containers in SBML. A simpler approach in XML might be to place the
components all directly at the top level of the model definition. The
choice made in SBML is to group them within XML elements named after
ListOfClassname, in part because it helps organize the
components. More importantly, the fact that the container classes are
derived from SBase
means that software tools can add information about
the lists themselves into each list container's 'annotation'.
Constructor and Description |
---|
ListOfCompartments(long level,
long version)
Creates a new
ListOfCompartments object. |
ListOfCompartments(SBMLNamespaces sbmlns)
Creates a new
ListOfCompartments object. |
Modifier and Type | Method and Description |
---|---|
ListOfCompartments |
cloneObject()
Creates and returns a deep copy of this
ListOfCompartments object. |
void |
delete()
Explicitly deletes the underlying native object.
|
Compartment |
get(long n)
Get a
Compartment object from the ListOfCompartments . |
Compartment |
get(java.lang.String sid)
Get a
Compartment object from the ListOfCompartments
based on its identifier. |
java.lang.String |
getElementName()
Returns the XML element name of this object.
|
int |
getItemTypeCode()
Returns the libSBML type code for the objects contained in this
ListOf
(i.e., Compartment objects, if the list is non-empty). |
Compartment |
remove(long n)
Removes the nth item from this
ListOfCompartments items and returns a pointer to
it. |
Compartment |
remove(java.lang.String sid)
Removes item in this
ListOfCompartments items with the given identifier. |
append, appendAndOwn, appendFrom, clear, clear, connectToChild, getElementByMetaId, getElementBySId, getTypeCode, insert, insertAndOwn, removeFromParentAndDelete, size
addCVTerm, addCVTerm, appendAnnotation, appendAnnotation, appendNotes, appendNotes, deleteDisabledPlugins, deleteDisabledPlugins, disablePackage, enablePackage, equals, getAncestorOfType, getAncestorOfType, getAnnotation, getAnnotationString, getColumn, getCVTerm, getCVTerms, getDisabledPlugin, getId, getIdAttribute, getLevel, getLine, getListOfAllElements, getListOfAllElements, getListOfAllElementsFromPlugins, getListOfAllElementsFromPlugins, getMetaId, getModel, getModelHistory, getName, getNamespaces, getNotes, getNotesString, getNumCVTerms, getNumDisabledPlugins, getNumPlugins, getObjectVersion, getPackageName, getPackageVersion, getParentSBMLObject, getPlugin, getPlugin, getPrefix, getResourceBiologicalQualifier, getResourceModelQualifier, getSBMLDocument, getSBOTerm, getSBOTermAsURL, getSBOTermID, getURI, getVersion, hashCode, hasValidLevelVersionNamespaceCombination, isPackageEnabled, isPackageURIEnabled, isPkgEnabled, isPkgURIEnabled, isSetAnnotation, isSetId, isSetIdAttribute, isSetMetaId, isSetModelHistory, isSetName, isSetNotes, isSetSBOTerm, isSetUserData, matchesRequiredSBMLNamespacesForAddition, matchesSBMLNamespaces, removeTopLevelAnnotationElement, removeTopLevelAnnotationElement, removeTopLevelAnnotationElement, renameMetaIdRefs, renameSIdRefs, renameUnitSIdRefs, replaceTopLevelAnnotationElement, replaceTopLevelAnnotationElement, setAnnotation, setAnnotation, setId, setIdAttribute, setMetaId, setModelHistory, setName, setNamespaces, setNotes, setNotes, setNotes, setSBOTerm, setSBOTerm, toSBML, toXMLNode, unsetAnnotation, unsetCVTerms, unsetId, unsetIdAttribute, unsetMetaId, unsetModelHistory, unsetName, unsetNotes, unsetSBOTerm, unsetUserData
public ListOfCompartments(long level, long version) throws SBMLConstructorException
ListOfCompartments
object.
The object is constructed such that it is valid for the given SBML Level and Version combination.
level
- the SBML Level.
version
- the Version within the SBML Level.
SBMLConstructorException
- Thrown if the given level
and version
combination are invalid
or if this object is incompatible with the given level and version.
SBMLDocument
having a different
combination of SBML Level, Version and XML namespaces than the object
itself will result in an error at the time a caller attempts to make the
addition. A parent object must have compatible Level, Version and XML
namespaces. (Strictly speaking, a parent may also have more XML
namespaces than a child, but the reverse is not permitted.) The
restriction is necessary to ensure that an SBML model has a consistent
overall structure. This requires callers to manage their objects
carefully, but the benefit is increased flexibility in how models can be
created by permitting callers to create objects bottom-up if desired. In
situations where objects are not yet attached to parents (e.g.,
SBMLDocument
), knowledge of the intented SBML Level and Version help
libSBML determine such things as whether it is valid to assign a
particular value to an attribute.public ListOfCompartments(SBMLNamespaces sbmlns) throws SBMLConstructorException
ListOfCompartments
object.
The object is constructed such that it is valid for the SBML Level and
Version combination determined by the SBMLNamespaces
object in
sbmlns
.
sbmlns
- an SBMLNamespaces
object that is used to determine the
characteristics of the ListOfCompartments
object to be created.
SBMLConstructorException
- Thrown if the given sbmlns
is inconsistent or incompatible
with this object.
SBMLDocument
having a different
combination of SBML Level, Version and XML namespaces than the object
itself will result in an error at the time a caller attempts to make the
addition. A parent object must have compatible Level, Version and XML
namespaces. (Strictly speaking, a parent may also have more XML
namespaces than a child, but the reverse is not permitted.) The
restriction is necessary to ensure that an SBML model has a consistent
overall structure. This requires callers to manage their objects
carefully, but the benefit is increased flexibility in how models can be
created by permitting callers to create objects bottom-up if desired. In
situations where objects are not yet attached to parents (e.g.,
SBMLDocument
), knowledge of the intented SBML Level and Version help
libSBML determine such things as whether it is valid to assign a
particular value to an attribute.public void delete()
In general, application software will not need to call this method directly. The Java language binding for libSBML is implemented as a language wrapper that provides a Java interface to libSBML's underlying C++/C code. Some of the Java methods return objects that are linked to objects created not by Java code, but by C++ code. The Java objects wrapped around them will be deleted when the garbage collector invokes the corresponding C++ finalize()
methods for the objects. The finalize()
methods in turn call the ListOfCompartments.delete()
method on the libSBML object.
This method is exposed in case calling programs want to ensure that the underlying object is freed immediately, and not at some arbitrary time determined by the Java garbage collector. In normal usage, callers do not need to invoke ListOfCompartments.delete()
themselves.
public ListOfCompartments cloneObject()
ListOfCompartments
object.
cloneObject
 in class ListOf
ListOfCompartments
object.public int getItemTypeCode()
ListOf
(i.e., Compartment
objects, if the list is non-empty).
LibSBML attaches an identifying code to every kind of SBML object. These
are integer constants known as SBML type codes. The names of all
the codes begin with the characters SBML_
.
In the Java language interface for libSBML, the
type codes are defined as static integer constants in the interface class
libsbmlConstants
. Note that different Level 3
package plug-ins may use overlapping type codes to identify the package
to which a given object belongs, call the getPackageName()
method on the object.
getItemTypeCode
 in class ListOf
ListOf
instance: SBML_COMPARTMENT
(default).
ListOfCompartments.getElementName()
,
SBase.getPackageName()
public java.lang.String getElementName()
For ListOfCompartments
, the XML element name is always
'listOfCompartments'.
getElementName
 in class ListOf
public Compartment get(long n)
Compartment
object from the ListOfCompartments
.
get
 in class ListOf
n
- the index number of the Compartment
object to get.
Compartment
object in this ListOfCompartments
.
ListOf.size()
public Compartment get(java.lang.String sid)
Compartment
object from the ListOfCompartments
based on its identifier.
sid
- a string representing the identifier
of the Compartment
object to get.
Compartment
object in this ListOfCompartments
with the given sid
or null
if no such
Compartment
object exists.
ListOfCompartments.get(long n)
,
ListOf.size()
public Compartment remove(long n)
ListOfCompartments
items and returns a pointer to
it.
The caller owns the returned item and is responsible for deleting it.
remove
 in class ListOf
n
- the index of the item to remove.
ListOf.size()
public Compartment remove(java.lang.String sid)
ListOfCompartments
items with the given identifier.
The caller owns the returned item and is responsible for deleting it.
If none of the items in this list have the identifier sid
, then
null
is returned.
sid
- the identifier of the item to remove.