public class SBMLNamespaces extends Object
This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.
There are differences in the definitions of components between different
SBML Levels, as well as Versions within Levels. For example, the
'sboTerm' attribute was not introduced until Level 2
Version 2, and then only on certain component classes the SBML
Level 2 Version 3 specification moved the 'sboTerm' attribute
to the SBase
class, thereby allowing nearly all components to have SBO
annotations. As a result of differences such as those, libSBML needs to
track the SBML Level and Version of every object created.
The purpose of the SBMLNamespaces
object class is to make it easier to
communicate SBML Level and Version data between libSBML constructors and
other methods. The SBMLNamespaces
object class tracks 3-tuples
(triples) consisting of SBML Level, Version, and the corresponding SBML
XML namespace.
The plural name (SBMLNamespaces) is not a mistake, because in SBML
Level 3, objects may have extensions added by Level 3 packages
used by a given model and therefore may have multiple namespaces
associated with them however, until the introduction of SBML
Level 3, the SBMLNamespaces
object only records one SBML
Level/Version/namespace combination at a time. Most constructors for
SBML objects in libSBML take a SBMLNamespaces
object as an argument,
thereby allowing the constructor to produce the proper combination of
attributes and other internal data structures for the given SBML Level
and Version.
Constructor and Description |
---|
SBMLNamespaces()
|
SBMLNamespaces(long level)
|
SBMLNamespaces(long level,
long version)
|
SBMLNamespaces(long level,
long version,
String pkgName,
long pkgVersion)
(For Extension)
|
SBMLNamespaces(long level,
long version,
String pkgName,
long pkgVersion,
String pkgPrefix)
(For Extension)
|
SBMLNamespaces(SBMLNamespaces orig)
Copy constructor creates a copy of a
SBMLNamespaces . |
Modifier and Type | Method and Description |
---|---|
int |
addNamespace(String uri,
String prefix)
Add an XML namespace (a pair of URI and prefix) to the set of namespaces
within this
SBMLNamespaces object. |
int |
addNamespaces(XMLNamespaces xmlns)
Add the given XML namespaces list to the set of namespaces within this
SBMLNamespaces object. |
int |
addPackageNamespace(String pkgName,
long pkgVersion)
Add an XML namespace (a pair of URI and prefix) of a package extension
to the set of namespaces within this
SBMLNamespaces object. |
int |
addPackageNamespace(String pkgName,
long pkgVersion,
String prefix)
Add an XML namespace (a pair of URI and prefix) of a package extension
to the set of namespaces within this
SBMLNamespaces object. |
int |
addPackageNamespaces(XMLNamespaces xmlns)
Add the XML namespaces of package extensions in the given
XMLNamespace object to the set of namespaces within this
SBMLNamespaces object (Non-package XML namespaces are not added
by this function). |
SBMLNamespaces |
cloneObject()
Creates and returns a deep copy of this
SBMLNamespaces . |
void |
delete()
Explicitly deletes the underlying native object.
|
boolean |
equals(Object sb)
Equality comparison method for SBMLNamespaces.
|
long |
getLevel()
Get the SBML Level of this
SBMLNamespaces object. |
XMLNamespaces |
getNamespaces()
Get the XML namespaces list for this
SBMLNamespaces object. |
String |
getPackageName()
Returns the name of the main package for this namespace.
|
static String |
getSBMLNamespaceURI(long level,
long version)
Returns a string representing the SBML XML namespace for the
given
level and version of SBML. |
static SBMLNamespacesList |
getSupportedNamespaces()
Returns a list of all supported
SBMLNamespaces in this version of
libsbml . |
String |
getURI()
Returns a string representing the SBML XML namespace of this
object.
|
long |
getVersion()
Get the SBML Version of this
SBMLNamespaces object. |
int |
hashCode()
Returns a hashcode for this SBMLNamespaces object.
|
static boolean |
isSBMLNamespace(String uri)
Predicate returning
true if the given
URL is one of SBML XML namespaces. |
boolean |
isValidCombination()
Predicate returning
true if the given
set of namespaces represent a valid set |
int |
removeNamespace(String uri)
Removes an XML namespace from the set of namespaces within this
SBMLNamespaces object. |
int |
removePackageNamespace(long level,
long version,
String pkgName,
long pkgVersion)
Removes an XML namespace of a package extension from the set of namespaces
within this
SBMLNamespaces object. |
public SBMLNamespaces() throws SBMLConstructorException
SBMLNamespaces
object corresponding to the given SBML
level
and version
.
SBMLNamespaces
objects are used in libSBML to communicate SBML Level
and Version data between constructors and other methods. The
SBMLNamespaces
object class tracks 3-tuples (triples) consisting of
SBML Level, Version, and the corresponding SBML XML namespace. Most
constructors for SBML objects in libSBML take a SBMLNamespaces
object
as an argument, thereby allowing the constructor to produce the proper
combination of attributes and other internal data structures for the
given SBML Level and Version.
The plural name (SBMLNamespaces) is not a mistake, because in SBML
Level 3, objects may have extensions added by Level 3
packages used by a given model and therefore may have multiple
namespaces associated with them however, until the introduction of
SBML Level 3, the SBMLNamespaces
object only records one SBML
Level/Version/namespace combination at a time. Most constructors for
SBML objects in libSBML take a SBMLNamespaces
object as an argument,
thereby allowing the constructor to produce the proper combination of
attributes and other internal data structures for the given SBML Level
and Version.
level
- the SBML levelversion
- the SBML version
SBMLConstructorException
public SBMLNamespaces(long level) throws SBMLConstructorException
SBMLNamespaces
object corresponding to the given SBML
level
and version
.
SBMLNamespaces
objects are used in libSBML to communicate SBML Level
and Version data between constructors and other methods. The
SBMLNamespaces
object class tracks 3-tuples (triples) consisting of
SBML Level, Version, and the corresponding SBML XML namespace. Most
constructors for SBML objects in libSBML take a SBMLNamespaces
object
as an argument, thereby allowing the constructor to produce the proper
combination of attributes and other internal data structures for the
given SBML Level and Version.
The plural name (SBMLNamespaces) is not a mistake, because in SBML
Level 3, objects may have extensions added by Level 3
packages used by a given model and therefore may have multiple
namespaces associated with them however, until the introduction of
SBML Level 3, the SBMLNamespaces
object only records one SBML
Level/Version/namespace combination at a time. Most constructors for
SBML objects in libSBML take a SBMLNamespaces
object as an argument,
thereby allowing the constructor to produce the proper combination of
attributes and other internal data structures for the given SBML Level
and Version.
level
- the SBML levelversion
- the SBML version
SBMLConstructorException
public SBMLNamespaces(long level, long version) throws SBMLConstructorException
SBMLNamespaces
object corresponding to the given SBML
level
and version
.
SBMLNamespaces
objects are used in libSBML to communicate SBML Level
and Version data between constructors and other methods. The
SBMLNamespaces
object class tracks 3-tuples (triples) consisting of
SBML Level, Version, and the corresponding SBML XML namespace. Most
constructors for SBML objects in libSBML take a SBMLNamespaces
object
as an argument, thereby allowing the constructor to produce the proper
combination of attributes and other internal data structures for the
given SBML Level and Version.
The plural name (SBMLNamespaces) is not a mistake, because in SBML
Level 3, objects may have extensions added by Level 3
packages used by a given model and therefore may have multiple
namespaces associated with them however, until the introduction of
SBML Level 3, the SBMLNamespaces
object only records one SBML
Level/Version/namespace combination at a time. Most constructors for
SBML objects in libSBML take a SBMLNamespaces
object as an argument,
thereby allowing the constructor to produce the proper combination of
attributes and other internal data structures for the given SBML Level
and Version.
level
- the SBML levelversion
- the SBML version
SBMLConstructorException
public SBMLNamespaces(long level, long version, String pkgName, long pkgVersion) throws SBMLConstructorException
Creates a new SBMLNamespaces
object corresponding to the combination of
(1) the given SBML level
and version
, and (2) the given package
with the package
version
.
level
- the SBML levelversion
- the SBML versionpkgName
- the string of package name (e.g. 'layout', 'multi')pkgVersion
- the package versionpkgPrefix
- the prefix of the package namespace (e.g. 'layout', 'multi') to be added.
The package's name will be used if the given string is empty (default).
SBMLConstructorException
SBMLExtensionException
will be thrown if the extension module
that supports the combination of the given sbml level, sbml version,
package name, and package version has not been registered.
public SBMLNamespaces(long level, long version, String pkgName, long pkgVersion, String pkgPrefix) throws SBMLConstructorException
Creates a new SBMLNamespaces
object corresponding to the combination of
(1) the given SBML level
and version
, and (2) the given package
with the package
version
.
level
- the SBML levelversion
- the SBML versionpkgName
- the string of package name (e.g. 'layout', 'multi')pkgVersion
- the package versionpkgPrefix
- the prefix of the package namespace (e.g. 'layout', 'multi') to be added.
The package's name will be used if the given string is empty (default).
SBMLConstructorException
SBMLExtensionException
will be thrown if the extension module
that supports the combination of the given sbml level, sbml version,
package name, and package version has not been registered.
public SBMLNamespaces(SBMLNamespaces orig) throws SBMLConstructorException
SBMLNamespaces
.
orig
- the SBMLNamespaces
instance to copy.
SBMLConstructorException
- Thrown if the argument orig
is null.
public int addNamespace(String uri, String prefix)
SBMLNamespaces
object.
uri
- the XML namespace to be added.prefix
- the prefix of the namespace to be added.
public int addNamespaces(XMLNamespaces xmlns)
SBMLNamespaces
object.
The following code gives an example of how one could add the XHTML
namespace to the list of namespaces recorded by the top-level
<sbml>
element of a model. It gives the new
namespace a prefix of html
.
SBMLDocument
sd try { sd = newSBMLDocument
(3, 1) } catch (SBMLConstructorException e) { // Here, have code to handle a truly exceptional situation. Candidate // causes include invalid combinations of SBML Level and Version // (impossible if hardwired as given here), running out of memory, and // unknown system exceptions. }SBMLNamespaces
sn = sd.getNamespaces() if (sn != null) { sn.add('http://www.w3.org/1999/xhtml', 'html') } else { // Handle another truly exceptional situation. }
xmlns
- the XML namespaces to be added.
public int addPackageNamespace(String pkgName, long pkgVersion)
SBMLNamespaces
object.
The SBML Level and SBML Version of this object is used.
pkgName
- the string of package name (e.g. 'layout', 'multi')pkgVersion
- the package versionprefix
- the prefix of the package namespace to be added.
The package's name will be used if the given string is empty (default).
SBMLNamespaces.addNamespace(String uri, String prefix)
LIBSBML_INVALID_ATTRIBUTE_VALUE
will be returned).
public int addPackageNamespace(String pkgName, long pkgVersion, String prefix)
SBMLNamespaces
object.
The SBML Level and SBML Version of this object is used.
pkgName
- the string of package name (e.g. 'layout', 'multi')pkgVersion
- the package versionprefix
- the prefix of the package namespace to be added.
The package's name will be used if the given string is empty (default).
SBMLNamespaces.addNamespace(String uri, String prefix)
LIBSBML_INVALID_ATTRIBUTE_VALUE
will be returned).
public int addPackageNamespaces(XMLNamespaces xmlns)
SBMLNamespaces
object (Non-package XML namespaces are not added
by this function).
xmlns
- the XML namespaces to be added.
LIBSBML_INVALID_ATTRIBUTE_VALUE
will be returned if the given xmlns is null.
public SBMLNamespaces cloneObject()
SBMLNamespaces
.
SBMLNamespaces
.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 SBMLNamespaces.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 SBMLNamespaces.delete()
themselves.
public boolean equals(Object sb)
Because the Java methods for libSBML are actually wrappers around code
implemented in C++ and C, certain operations will not behave as
expected. Equality comparison is one such case. An instance of a
libSBML object class is actually a proxy object
wrapping the real underlying C/C++ object. The normal ==
equality operator in Java will only compare the Java proxy objects,
not the underlying native object. The result is almost never what you
want in practical situations. Unfortunately, Java does not provide a
way to override ==
.
The alternative that must be followed is to use the
equals()
method. The equals
method on this
class overrides the default java.lang.Object one, and performs an
intelligent comparison of instances of objects of this class. The
result is an assessment of whether two libSBML Java objects are truly
the same underlying native-code objects.
The use of this method in practice is the same as the use of any other
Java equals
method. For example,
a.equals(
b)
returns
true
if a and b are references to the
same underlying object.
public long getLevel()
SBMLNamespaces
object.
SBMLNamespaces
object.public XMLNamespaces getNamespaces()
SBMLNamespaces
object.
The plural is not a mistake, because in SBML Level 3, objects may
have extensions added by Level 3 packages used by a given model,
and therefore there may be multiple XML namespaces involved too.
However, until the introduction of SBML Level 3, the
SBMLNamespaces
object only records one SBML Level/Version/namespace
combination at a time, and so this method will also only return
a list of one item.
SBMLNamespaces
object.public String getPackageName()
public static String getSBMLNamespaceURI(long level, long version)
level
and version
of SBML.
level
- the SBML levelversion
- the SBML version
SBMLNamespaces
), and the
other will be a standalone top-level function with the name
SBMLNamespaces_getSBMLNamespaceURI(). They are functionally
identical.public static SBMLNamespacesList getSupportedNamespaces()
SBMLNamespaces
in this version of
libsbml
.
SBMLNamespaces
), and the
other will be a standalone top-level function with the name
SBMLNamespaces_getSupportedNamespaces(). They are functionally
identical.public String getURI()
public long getVersion()
SBMLNamespaces
object.
SBMLNamespaces
object.public int hashCode()
public static boolean isSBMLNamespace(String uri)
true
if the given
URL is one of SBML XML namespaces.
uri
- the URI of namespace
true
if the 'uri' is one of SBML namespaces, false
otherwise.
SBMLNamespaces
), and the
other will be a standalone top-level function with the name
SBMLNamespaces_isSBMLNamespace(). They are functionally
identical.public boolean isValidCombination()
true
if the given
set of namespaces represent a valid set
true
if the set of namespaces is valid, false
otherwise.public int removeNamespace(String uri)
SBMLNamespaces
object.
uri
- the XML namespace to be added.
public int removePackageNamespace(long level, long version, String pkgName, long pkgVersion)
SBMLNamespaces
object.
level
- the SBML levelversion
- the SBML versionpkgName
- the string of package name (e.g. 'layout', 'multi')pkgVersion
- the package version