public class SBaseRef extends CompBase
The SBaseRef
class was introduced by the SBML Level 3
'Hierarchical Model Composition' package
(&ldquocomp&rdquo) as the principle way by which submodel elements may
be referenced. The SBaseRef
class is usually found as the base class of a
Port
, Deletion
, ReplacedElement
, or ReplacedBy
class, but may appear as an
child of one of the above classes if the parent object references a
Submodel
.
An SBaseRef
object must reference an element using exactly one of the
optional attributes of the class. Subclasses of SBaseRef
may define
additional optional attributes that are legal ways to reference an element.
SBaseRef
objects may reference elements that do not live in the Model
parent
of the SBaseRef
object. However, the SBaseRef
class itself does not
provide a method of determining which Model
or Submodel
is being referenced.
The subclasses of SBaseRef
provide methods for this instead.
Once the Model
to which the SBaseRef
object is referencing has been established,
there are four optional attributes defined in the SBaseRef
class that
are each methods of referencing an element:
SBaseRef
is intended to refer to a port on a
submodel. The namespace of the PortSIdRef value is the set
of identifiers of type PortSId defined in the submodel, not
the parent model.
SBaseRef
is intended to refer to an object that
does not have a port identifier. The namespace of the SIdRef
value is the set of identifiers of type SId defined in the
submodel, not the parent model.
UnitDefinition
object. The namespace of the UnitSIdRef
value is the set of unit identifiers defined in the submodel, not the
parent model. (Note that even though this attribute is of type UnitSIdRef,
the reserved unit identifiers that are defined by SBML Level 3 (see
Section 3.1.10 of the core specification) are
*not* permitted as values of 'unitRef'. Reserved unit
identifiers may not be replaced or deleted.)
SBaseRef
is intended to refer to an object
that does not have a port identifier. The namespace of the 'metaIdRef'
value is the entire document in which the referenced model resides, but
must refer to a subelement of the referenced model. Since meta identifiers are
optional attributes of SBase
, all SBML objects have the potential to
have a meta identifier value.
An SBaseRef
object may have up to one subcomponent named 'sBaseRef', of
type SBaseRef
. This permits recursive structures to be constructed so
that objects inside submodels can be referenced.
The form of such recursive references must be as follows. The
highest-level SBaseRef
object of such a chain (which will necessarily
be an object of class Port
, Deletion
, ReplacedElement
or ReplacedBy
,
because they are the only classes derived from the class SBaseRef
) must
refer to a Submodel
object in the containing model. All child
SBaseRef
objects in the chain must refer to components inside the
Model
instance to which the Submodel
refers.
Constructor and Description |
---|
SBaseRef()
Creates a new
SBaseRef with the given level, version, and package version. |
SBaseRef(CompPkgNamespaces compns)
Creates a new
SBaseRef with the given CompPkgNamespaces object. |
SBaseRef(long level)
Creates a new
SBaseRef with the given level, version, and package version. |
SBaseRef(long level,
long version)
Creates a new
SBaseRef with the given level, version, and package version. |
SBaseRef(long level,
long version,
long pkgVersion)
Creates a new
SBaseRef with the given level, version, and package version. |
SBaseRef(SBaseRef source)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clearReferencedElement()
Removes the saved referenced element, if it had been saved earlier.
|
SBase |
cloneObject()
Creates and returns a deep copy of this
SBaseRef object. |
void |
connectToChild()   |
SBaseRef |
createSBaseRef()
|
void |
delete()
Explicitly deletes the underlying native object.
|
SBase |
getElementByMetaId(java.lang.String metaid)
Returns the first child element it can find with the given
metaid , or
itself if it has the given metaid , or null if no such object is found. |
SBase |
getElementBySId(java.lang.String id)
Returns the first child element found that has the given
id in the
model-wide SId namespace, or null if no such object is found. |
java.lang.String |
getElementName()
Returns the XML element name of
this SBML object.
|
java.lang.String |
getIdRef()
Returns the value of the 'idRef' attribute of this
SBaseRef . |
java.lang.String |
getMetaIdRef()
Returns the value of the 'metaIdRef' attribute of this
SBaseRef . |
int |
getNumReferents()
Returns how many elements are being referred to by this
SBaseRef . |
java.lang.String |
getPortRef()
Returns the value of the 'portRef' attribute of this
SBaseRef . |
SBase |
getReferencedElement()
Returns the object pointed to by this element.
|
SBase |
getReferencedElementFrom(Model model)
Examines the referenced
Model for the referenced object, and returns it, if found. |
SBaseRef |
getSBaseRef()
Get the child sBaseRef of this sBaseRef.
|
int |
getTypeCode()
Returns the libSBML type code of this object instance.
|
java.lang.String |
getUnitRef()
Returns the value of the 'unitRef' attribute of this
SBaseRef . |
boolean |
hasRequiredAttributes()
Returns true if getNumReferents() is exactly 1.
|
boolean |
isSetIdRef()
Predicate returning
true or false depending on whether this
SBaseRef 's 'idRef' attribute has been set. |
boolean |
isSetMetaIdRef()
Predicate returning
true or false depending on whether this
SBaseRef 's 'metaIdRef' attribute has been set. |
boolean |
isSetPortRef()
Predicate returning
true or false depending on whether this
SBaseRef 's 'portRef' attribute has been set. |
boolean |
isSetSBaseRef()
Predicate for testing whether the sBaseRef for this
SBaseRef is set. |
boolean |
isSetUnitRef()
Predicate returning
true or false depending on whether this
SBaseRef 's 'unitRef' attribute has been set. |
int |
performDeletion()
DEPRECATED FUNCTION: DO NOT USE
|
int |
removeFromParentAndDelete()
|
void |
renameSIdRefs(java.lang.String oldid,
java.lang.String newid)
Replaces all uses of a given
SIdRef type attribute value with another
value. |
int |
saveReferencedElement()
|
int |
setIdRef(java.lang.String id)
Sets the value of the 'idRef' attribute of this
SBaseRef . |
int |
setMetaIdRef(java.lang.String id)
Sets the value of the 'metaIdRef' attribute of this
SBaseRef . |
int |
setPortRef(java.lang.String id)
Sets the value of the 'portRef' attribute of this
SBaseRef . |
int |
setSBaseRef(SBaseRef sBaseRef)
|
int |
setUnitRef(java.lang.String id)
Sets the value of the 'unitRef' attribute of this
SBaseRef . |
int |
unsetIdRef()
Unsets the value of the 'idRef' attribute of this
SBaseRef . |
int |
unsetMetaIdRef()
Unsets the value of the 'metaIdRef' attribute of this
SBaseRef . |
int |
unsetPortRef()
Unsets the value of the 'portRef' attribute of this
SBaseRef . |
int |
unsetSBaseRef()
|
int |
unsetUnitRef()
Unsets the value of the 'unitRef' attribute of this
SBaseRef . |
addCVTerm, addCVTerm, appendAnnotation, appendAnnotation, appendNotes, appendNotes, deleteDisabledPlugins, deleteDisabledPlugins, disablePackage, enablePackage, equals, getAncestorOfType, getAncestorOfType, getAnnotation, getAnnotationString, getColumn, getCVTerm, getCVTerms, getDisabledPlugin, getLevel, getLine, getListOfAllElements, getListOfAllElements, getListOfAllElementsFromPlugins, getListOfAllElementsFromPlugins, getMetaId, getModel, getModelHistory, getNamespaces, getNotes, getNotesString, getNumCVTerms, getNumDisabledPlugins, getNumPlugins, getPackageName, getPackageVersion, getParentSBMLObject, getPlugin, getPlugin, getPrefix, getResourceBiologicalQualifier, getResourceModelQualifier, getSBMLDocument, getSBOTerm, getSBOTermAsURL, getSBOTermID, getURI, getVersion, hashCode, hasValidLevelVersionNamespaceCombination, isPackageEnabled, isPackageURIEnabled, isPkgEnabled, isPkgURIEnabled, isSetAnnotation, isSetMetaId, isSetModelHistory, isSetNotes, isSetSBOTerm, isSetUserData, matchesRequiredSBMLNamespacesForAddition, matchesSBMLNamespaces, removeTopLevelAnnotationElement, removeTopLevelAnnotationElement, removeTopLevelAnnotationElement, renameMetaIdRefs, renameUnitSIdRefs, replaceTopLevelAnnotationElement, replaceTopLevelAnnotationElement, setAnnotation, setAnnotation, setMetaId, setModelHistory, setNamespaces, setNotes, setNotes, setNotes, setSBOTerm, setSBOTerm, toSBML, toXMLNode, unsetAnnotation, unsetCVTerms, unsetId, unsetMetaId, unsetModelHistory, unsetName, unsetNotes, unsetSBOTerm, unsetUserData
public SBaseRef(long level, long version, long pkgVersion) throws SBMLConstructorException
SBaseRef
with the given level, version, and package version.
level
- the SBML Levelversion
- the Version within the SBML LevelpkgVersion
- the version of the packageSBMLConstructorException
public SBaseRef(long level, long version) throws SBMLConstructorException
SBaseRef
with the given level, version, and package version.
level
- the SBML Levelversion
- the Version within the SBML LevelpkgVersion
- the version of the packageSBMLConstructorException
public SBaseRef(long level) throws SBMLConstructorException
SBaseRef
with the given level, version, and package version.
level
- the SBML Levelversion
- the Version within the SBML LevelpkgVersion
- the version of the packageSBMLConstructorException
public SBaseRef() throws SBMLConstructorException
SBaseRef
with the given level, version, and package version.
level
- the SBML Levelversion
- the Version within the SBML LevelpkgVersion
- the version of the packageSBMLConstructorException
public SBaseRef(CompPkgNamespaces compns) throws SBMLConstructorException
SBaseRef
with the given CompPkgNamespaces
object.
compns
- the namespace to useSBMLConstructorException
public SBaseRef(SBaseRef source) throws SBMLConstructorException
SBMLConstructorException
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 SBaseRef.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 SBaseRef.delete()
themselves.
public SBase cloneObject()
SBaseRef
object.
cloneObject
 in class SBase
SBaseRef
objectpublic SBase getElementBySId(java.lang.String id)
id
in the
model-wide SId namespace, or null
if no such object is found.
getElementBySId
 in class SBase
id
- string representing the id of objects to find
SBase
element with the given id
.public SBase getElementByMetaId(java.lang.String metaid)
metaid
, or
itself if it has the given metaid
, or null
if no such object is found.
getElementByMetaId
 in class SBase
metaid
- string representing the metaid of objects to find
SBase
element with the given metaid
.public java.lang.String getMetaIdRef()
SBaseRef
.
SBaseRef
.public boolean isSetMetaIdRef()
true
or false
depending on whether this
SBaseRef
's 'metaIdRef' attribute has been set.
true
if this SBaseRef
's 'metaIdRef' attribute has been set,
otherwise false
is returned.public int setMetaIdRef(java.lang.String id)
SBaseRef
.
This method fails if the id is not a valid syntax for an IDREF (LIBSBML_INVALID_ATTRIBUTE_VALUE
), or if the SBaseRef
already
points to an element of the submodel using a different interface (LIBSBML_OPERATION_FAILED
). An sBaseRef must use exactly one
method to point to a submodel element.
public int unsetMetaIdRef()
SBaseRef
.
public java.lang.String getPortRef()
SBaseRef
.
SBaseRef
.public boolean isSetPortRef()
true
or false
depending on whether this
SBaseRef
's 'portRef' attribute has been set.
true
if this SBaseRef
's 'portRef' attribute has been set,
otherwise false
is returned.public int setPortRef(java.lang.String id)
SBaseRef
. Fails if
the id is not a valid syntax for a PortSIdRef (LIBSBML_INVALID_ATTRIBUTE_VALUE
), or if the SBaseRef
already
points to an element of the submodel using a different interface (LIBSBML_OPERATION_FAILED
). An SBaseRef
must use exactly one
method to point to a submodel element.
public int unsetPortRef()
SBaseRef
.
public java.lang.String getIdRef()
SBaseRef
.
SBaseRef
.public boolean isSetIdRef()
true
or false
depending on whether this
SBaseRef
's 'idRef' attribute has been set.
true
if this SBaseRef
's 'idRef' attribute has been set,
otherwise false
is returned.public int setIdRef(java.lang.String id)
SBaseRef
.
This method fails if the id is not a valid syntax for an SIdRef (LIBSBML_INVALID_ATTRIBUTE_VALUE
), or if the SBaseRef
already
points to an element of the submodel using a different interface (LIBSBML_OPERATION_FAILED
). A sBaseRef must use exactly one
method to point to a submodel element.
public int unsetIdRef()
SBaseRef
.
public java.lang.String getUnitRef()
SBaseRef
.
SBaseRef
.public boolean isSetUnitRef()
true
or false
depending on whether this
SBaseRef
's 'unitRef' attribute has been set.
true
if this SBaseRef
's 'unitRef' attribute has been set,
otherwise false
is returned.public int setUnitRef(java.lang.String id)
SBaseRef
.
This method fails if the id is not a valid syntax for a UnitSIdRef (LIBSBML_INVALID_ATTRIBUTE_VALUE
), or if the SBaseRef
already
points to an element of the submodel using a different interface (LIBSBML_OPERATION_FAILED
). A sBaseRef must use exactly one
method to point to a submodel element.
public int unsetUnitRef()
SBaseRef
.
public SBaseRef getSBaseRef()
public boolean isSetSBaseRef()
SBaseRef
is set.
true
if the sBaseRef of this SBaseRef
is set, false
otherwise.public int setSBaseRef(SBaseRef sBaseRef)
SBaseRef
to a copy of the given
SBaseRef
object instance.
This method fails if the added sBaseRef does not match the level/version/package of the parent object or if the added sBaseRef cannot be copied.
sBaseRef
- the SBaseRef
object instance to use.
public SBaseRef createSBaseRef()
SBaseRef
object instance.public int unsetSBaseRef()
public int getNumReferents()
SBaseRef
. A
valid SBaseRef
will have exactly one. Possible referents are portRef,
idRef, unitRef, and metaIdRef.
public boolean hasRequiredAttributes()
hasRequiredAttributes
 in class SBase
public void renameSIdRefs(java.lang.String oldid, java.lang.String newid)
Replaces all uses of a given SIdRef
type attribute value with another
value.
In SBML, object identifiers are of a data type called SId
.
In SBML Level 3, an explicit data type called SIdRef
was
introduced for attribute values that refer to SId
values in
previous Levels of SBML, this data type did not exist and attributes were
simply described to as 'referring to an identifier', but the effective
data type was the same as SIdRef
in Level 3. These and
other methods of libSBML refer to the type SIdRef
for all
Levels of SBML, even if the corresponding SBML specification did not
explicitly name the data type.
This method works by looking at all attributes and (if appropriate)
mathematical formulas in MathML content, comparing the referenced
identifiers to the value of oldid
. If any matches are found, the
matching values are replaced with newid
. The method does not
descend into child elements.
renameSIdRefs
 in class SBase
oldid
- the old identifiernewid
- the new identifierpublic java.lang.String getElementName()
getElementName
 in class SBase
public int getTypeCode()
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.
getTypeCode
 in class SBase
SBML_COMP_SBASEREF
SBaseRef.getElementName()
,
CompBase.getPackageName()
public void connectToChild()
connectToChild
 in class SBase
public SBase getReferencedElementFrom(Model model)
Model
for the referenced object, and returns it, if found.
public int saveReferencedElement()
Model
it needs to
point to, calling 'saveReferencedElement' on its parent (which will also
be a SBaseRef
or one of its subclasses), and the storing the result.
public SBase getReferencedElement()
public void clearReferencedElement()
public int performDeletion()
Deletes the referenced object,
plus any other elements that element points to through ReplacedElement
or ReplacedBy
children. Instead of calling this function directly, use
'CompModelPlugin.instantiateSubmodels' instead, which deals with all the
intricacies of replacements and deletions, and gives you access to the
non-flattened hierarchical form of the model.
public int removeFromParentAndDelete()
SBaseRef
's parent, which can either be a List or can be
another SBaseRef
, and tells it to remove this.
removeFromParentAndDelete
 in class SBase