public class Unit extends SBase
The SBML unit definition facility uses two classes of objects,
UnitDefinition
and Unit
. The approach to defining units in SBML is
compositional for example, meter second &ndash2 is
constructed by combining a Unit
object representing meter with
another Unit
object representing second &ndash2.
The combination is wrapped inside a UnitDefinition
, which provides for
assigning an identifier and optional name to the combination. The
identifier can then be referenced from elsewhere in a model. Thus, the
UnitDefinition
class is the container, and Unit
instances are placed
inside UnitDefinition
instances.
A Unit
has four attributes named 'kind', 'exponent', 'scale'
and 'multiplier'. It represents a (possibly transformed) reference to a
base unit. The attribute 'kind' on Unit
indicates the chosen base unit.
Its value must be one of the text strings listed below this list
corresponds to SBML Level 3:
ampere | farad | joule | lux | radian | volt |
avogadro | gram | katal | metre | second | watt |
becquerel | gray | kelvin | mole | siemens | weber |
candela | henry | kilogram | newton | sievert | |
coulomb | hertz | litre | ohm | steradian | |
dimensionless | item | lumen | pascal | tesla |
A few small differences exist between the Level 3 list of base
units and the list defined in other Level/Version combinations of SBML.
Specifically, Levels of SBML before Level 3 do not define
avogadro
conversely, Level 2 Version 1 defines Celsius
,
and Level 1 defines celsius
, meter
, and liter
, none of
which are available in Level 3. In libSBML, each of the predefined
base unit names is represented by an enumeration value whose name begins with the characters
UNIT_KIND_
, discussed in a separate section below.
The attribute named 'exponent' on Unit
represents an exponent on the
unit. In SBML Level 2, the attribute is optional and has a default
value of 1
(one) in SBML Level 3, the attribute is mandatory
and there is no default value. A Unit
also has an attribute
called 'scale' its value must be an integer exponent for a power-of-ten
multiplier used to set the scale of the unit. For example, a unit
having a 'kind' value of gram
and a 'scale' value of -3
signifies
10 &ndash3 × gram, or milligrams. In SBML
Level 2, the attribute is optional and has a default value of 0
(zero), because 10 0 = 1 in SBML Level 3, the attribute
is mandatory and has no default value. Lastly, the attribute named
'multiplier' can be used to multiply the unit by a real-numbered factor
this enables the definition of units that are not power-of-ten multiples
of SI units. For instance, a multiplier of 0.3048 could be used to
define foot
as a measure of length in terms of a metre.
The
'multiplier' attribute is optional in SBML Level 2, where it has a
default value of 1
(one) in SBML Level 3, the attribute is
mandatory and has not default value.
*
As discussed above, SBML defines a set of base units which serves as the starting point for new unit definitions. This set of base units consists of the SI units and a small number of additional convenience units.
In SBML Level 2 Versions before
Version 3, there existed an enumeration of units called
UnitKind.
In Version 3, this enumeration was removed and the
identifier class UnitSId
redefined to include the previous
UnitKind
values as reserved symbols. This change has no net effect on
permissible models, their representation or their syntax. The purpose
of the change in the SBML specification was simply to clean up an
inconsistency about the contexts in which these values were usable.
However, libSBML maintains UnitKind in the form of of a set of static
integer constants whose names begin with the characters
UNIT_KIND_
. These constants are defined in the class
libsbmlConstants
.
As a consequence of the fact that libSBML supports models in all Levels
and Versions of SBML, libSBML's set of UNIT_KIND_
values is a union
of all the possible base unit names defined in the different SBML
specifications. However, not every base unit is allowed in every
Level+Version combination of SBML. Note in particular the following
exceptions:
'meter'
is included in
addition to the official SI spelling 'metre'.
This spelling is only
permitted in SBML Level 1 models.
'liter'
is included in addition to the
official SI spelling 'litre'.
This spelling is only permitted in
SBML Level 1 models.
'Celsius'
is included because of its presence in
specifications of SBML prior to SBML Level 2 Version 3.
avogadro
was introduced in SBML Level 3, and
is only permitted for use in SBML Level 3 models.
The table below lists the unit constants defined in libSBML, and their meanings.
Enumerator | Meaning |
---|---|
UNIT_KIND_AMPERE | The ampere unit. |
UNIT_KIND_AVOGADRO | The unit
dimensionless multiplied by the numerical value of Avogadro's
constant. (Only usable in SBML Level 3 models.) |
UNIT_KIND_BECQUEREL | The becquerel unit. |
UNIT_KIND_CANDELA | The candela unit. |
UNIT_KIND_CELSIUS | The Celsius unit. (Only usable in SBML Level 1 and SBML Level 2 Version 1 models.) |
UNIT_KIND_COULOMB | The coulomb unit. |
UNIT_KIND_DIMENSIONLESS | A pseudo-unit indicating a dimensionless quantity. |
UNIT_KIND_FARAD | The farad unit. |
UNIT_KIND_GRAM | The gram unit. |
UNIT_KIND_GRAY | The gray unit. |
UNIT_KIND_HENRY | The henry unit. |
UNIT_KIND_HERTZ | The hertz unit. |
UNIT_KIND_ITEM | A pseudo-unit representing a single "thing". |
UNIT_KIND_JOULE | The joule unit. |
UNIT_KIND_KATAL | The katal unit. |
UNIT_KIND_KELVIN | The kelvin unit. |
UNIT_KIND_KILOGRAM | The kilogram unit. |
UNIT_KIND_LITER | Alternate spelling of litre. |
UNIT_KIND_LITRE | The litre unit. |
UNIT_KIND_LUMEN | The lumen unit. |
UNIT_KIND_LUX | The lux unit. |
UNIT_KIND_METER | Alternate spelling of metre. |
UNIT_KIND_METRE | The metre unit. |
UNIT_KIND_MOLE | The mole unit. |
UNIT_KIND_NEWTON | The newton unit. |
UNIT_KIND_OHM | The ohm unit. |
UNIT_KIND_PASCAL | The pascal unit. |
UNIT_KIND_RADIAN | The radian unit. |
UNIT_KIND_SECOND | The second unit. |
UNIT_KIND_SIEMENS | The siemens unit. |
UNIT_KIND_SIEVERT | The sievert unit. |
UNIT_KIND_STERADIAN | The steradian unit. |
UNIT_KIND_TESLA | The tesla unit. |
UNIT_KIND_VOLT | The volt unit. |
UNIT_KIND_WATT | The watt unit. |
UNIT_KIND_WEBER | The weber unit. |
UNIT_KIND_INVALID | Marker used by libSBML to indicate an invalid or unset unit. |
Constructor and Description |
---|
Unit(long level,
long version)
|
Unit(SBMLNamespaces sbmlns)
|
Unit(Unit orig)
Copy constructor creates a copy of this
Unit . |
Modifier and Type | Method and Description |
---|---|
static boolean |
areEquivalent(Unit unit1,
Unit unit2)
Predicate returning
true if
Unit objects are equivalent. |
static boolean |
areIdentical(Unit unit1,
Unit unit2)
Predicate returning
true if two
Unit objects are identical. |
Unit |
cloneObject()
Creates and returns a deep copy of this
Unit object. |
static UnitDefinition |
convertToSI(Unit unit)
Returns a
UnitDefinition object containing the given unit converted
to the appropriate SI unit. |
void |
delete()
Explicitly deletes the underlying native object.
|
java.lang.String |
getElementName()
Returns the XML element name of this object, which for
Unit , is
always 'unit'. |
int |
getExponent()
Returns the value of the 'exponent' attribute of this unit.
|
double |
getExponentAsDouble()
Returns the value of the 'exponent' attribute of this unit.
|
int |
getKind()
Returns the 'kind' of
Unit this is. |
double |
getMultiplier()
Returns the value of the 'multiplier' attribute of this
Unit . |
double |
getOffset()
Returns the value of the 'offset' attribute of this
Unit . |
int |
getScale()
Returns the value of the 'scale' attribute of this unit.
|
int |
getTypeCode()
Returns the libSBML type code of this object instance.
|
boolean |
hasRequiredAttributes()
Predicate returning
true if
all the required attributes for this Unit object
have been set. |
void |
initDefaults()
Initializes the fields of this
Unit object to 'typical' default
values. |
boolean |
isAmpere()
Predicate for testing whether this
Unit is of the kind ampere. |
boolean |
isAvogadro()
Predicate for testing whether this
Unit is of the kind avogadro. |
boolean |
isBecquerel()
Predicate for testing whether this
Unit is of the kind becquerel |
static boolean |
isBuiltIn(java.lang.String name,
long level)
Predicate to test whether a given string is the name of a
predefined SBML unit.
|
boolean |
isCandela()
Predicate for testing whether this
Unit is of the kind candela |
boolean |
isCelsius()
Predicate for testing whether this
Unit is of the kind Celsius |
boolean |
isCoulomb()
Predicate for testing whether this
Unit is of the kind coulomb |
boolean |
isDimensionless()
Predicate for testing whether this
Unit is of the kind
dimensionless. |
boolean |
isFarad()
Predicate for testing whether this
Unit is of the kind farad |
boolean |
isGram()
Predicate for testing whether this
Unit is of the kind gram |
boolean |
isGray()
Predicate for testing whether this
Unit is of the kind gray |
boolean |
isHenry()
Predicate for testing whether this
Unit is of the kind henry |
boolean |
isHertz()
Predicate for testing whether this
Unit is of the kind hertz |
boolean |
isItem()
Predicate for testing whether this
Unit is of the kind item |
boolean |
isJoule()
Predicate for testing whether this
Unit is of the kind joule |
boolean |
isKatal()
Predicate for testing whether this
Unit is of the kind katal |
boolean |
isKelvin()
Predicate for testing whether this
Unit is of the kind kelvin |
boolean |
isKilogram()
Predicate for testing whether this
Unit is of the kind kilogram |
boolean |
isLitre()
Predicate for testing whether this
Unit is of the kind litre |
boolean |
isLumen()
Predicate for testing whether this
Unit is of the kind lumen |
boolean |
isLux()
Predicate for testing whether this
Unit is of the kind lux |
boolean |
isMetre()
Predicate for testing whether this
Unit is of the kind metre |
boolean |
isMole()
Predicate for testing whether this
Unit is of the kind mole |
boolean |
isNewton()
Predicate for testing whether this
Unit is of the kind newton |
boolean |
isOhm()
Predicate for testing whether this
Unit is of the kind ohm |
boolean |
isPascal()
Predicate for testing whether this
Unit is of the kind pascal |
boolean |
isRadian()
Predicate for testing whether this
Unit is of the kind radian |
boolean |
isSecond()
Predicate for testing whether this
Unit is of the kind second |
boolean |
isSetExponent()
Predicate to test whether the 'exponent' attribute of this
Unit
is set. |
boolean |
isSetKind()
Predicate to test whether the 'kind' attribute of this
Unit is set. |
boolean |
isSetMultiplier()
Predicate to test whether the 'multiplier' attribute of this
Unit
is set. |
boolean |
isSetOffset()
Predicate to test whether the 'offset' attribute of this
Unit
is set. |
boolean |
isSetScale()
Predicate to test whether the 'scale' attribute of this
Unit
is set. |
boolean |
isSiemens()
Predicate for testing whether this
Unit is of the kind siemens |
boolean |
isSievert()
Predicate for testing whether this
Unit is of the kind sievert |
boolean |
isSteradian()
Predicate for testing whether this
Unit is of the kind steradian |
boolean |
isTesla()
Predicate for testing whether this
Unit is of the kind tesla |
static boolean |
isUnitKind(java.lang.String name,
long level,
long version)
Predicate to test whether a given string is the name of a valid
base unit in SBML (such as
'gram' or 'mole' ). |
boolean |
isVolt()
Predicate for testing whether this
Unit is of the kind volt |
boolean |
isWatt()
Predicate for testing whether this
Unit is of the kind watt |
boolean |
isWeber()
Predicate for testing whether this
Unit is of the kind weber |
static void |
merge(Unit unit1,
Unit unit2)
|
static int |
removeScale(Unit unit)
Manipulates the attributes of the
Unit to express the unit with the
value of the scale attribute reduced to zero. |
int |
setExponent(double value)
Sets the 'exponent' attribute value of this
Unit . |
int |
setExponent(int value)
Sets the 'exponent' attribute value of this
Unit . |
int |
setKind(int kind)
Sets the 'kind' attribute value of this
Unit . |
int |
setMultiplier(double value)
Sets the 'multipler' attribute value of this
Unit . |
int |
setOffset(double value)
Sets the 'offset' attribute value of this
Unit . |
int |
setScale(int value)
Sets the 'scale' attribute value of this
Unit . |
int |
unsetExponent()
Unsets the 'exponent' attribute value of this
Unit . |
int |
unsetKind()
Unsets the 'kind' attribute value of this
Unit . |
int |
unsetMultiplier()
Unsets the 'multipler' attribute value of this
Unit . |
int |
unsetOffset()
Unsets the 'offset' attribute value of this
Unit . |
int |
unsetScale()
Unsets the 'scale' attribute value of this
Unit . |
addCVTerm, addCVTerm, appendAnnotation, appendAnnotation, appendNotes, appendNotes, connectToChild, deleteDisabledPlugins, deleteDisabledPlugins, disablePackage, enablePackage, equals, getAncestorOfType, getAncestorOfType, getAnnotation, getAnnotationString, getColumn, getCVTerm, getCVTerms, getDisabledPlugin, getElementByMetaId, getElementBySId, 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, removeFromParentAndDelete, 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 Unit(long level, long version) throws SBMLConstructorException
level
- a long integer, the SBML Level to assign to this Unit
.
version
- a long integer, the SBML Version to assign to this
Unit
.
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 Unit(SBMLNamespaces sbmlns) throws SBMLConstructorException
Unit
using the given SBMLNamespaces
object
sbmlns
.
The SBMLNamespaces
object encapsulates SBML Level/Version/namespaces
information. It is used to communicate the SBML Level, Version, and (in
Level 3) packages used in addition to SBML Level 3 Core. A
common approach to using libSBML's SBMLNamespaces
facilities is to create an
SBMLNamespaces
object somewhere in a program once, then hand that object
as needed to object constructors that accept SBMLNamespaces
as arguments.
sbmlns
- an SBMLNamespaces
object.
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 Unit(Unit orig) throws SBMLConstructorException
Unit
.
orig
- the object to copy.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 Unit.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 Unit.delete()
themselves.
public Unit cloneObject()
Unit
object.
cloneObject
 in class SBase
Unit
object.public void initDefaults()
Unit
object to 'typical' default
values.
The SBML Unit
component has slightly different aspects and default
attribute values in different SBML Levels and Versions. This method
sets the values to certain common defaults, based mostly on what they
are in SBML Level 2. Specifically:
1
0
1.0
The 'kind' attribute is left unchanged.
public int getKind()
Unit
this is.
Unit
as a
value from the set of constants whose names begin
with UNIT_KIND_
defined in the class
libsbmlConstants
.public int getExponent()
Unit
, as an integer.public double getExponentAsDouble()
Unit
, as a double.public int getScale()
Unit
, as an integer.public double getMultiplier()
Unit
.
Unit
, as a double.public double getOffset()
Unit
.
Unit
, as a double.
public boolean isAmpere()
Unit
is of the kind ampere.
true
if the kind of this Unit
is ampere
, false
otherwise.public boolean isAvogadro()
Unit
is of the kind avogadro.
true
if the kind of this Unit
is avogadro
, false
otherwise.
avogadro
was introduced in SBML Level 3, and
is only permitted for use in SBML Level 3 models.public boolean isBecquerel()
Unit
is of the kind becquerel
true
if the kind of this Unit
is becquerel
, false
otherwise.public boolean isCandela()
Unit
is of the kind candela
true
if the kind of this Unit
is candela
, false
otherwise.public boolean isCelsius()
Unit
is of the kind Celsius
true
if the kind of this Unit
is Celsius
, false
otherwise.
Celsius
was
removed from the list of predefined units in SBML Level 2
Version 2 at the same time that the 'offset' attribute was removed
from Unit
definitions. LibSBML methods such as this one related to
Celsius
are retained in order to support SBML Level 2
Version 1, but their use is strongly discouraged.public boolean isCoulomb()
Unit
is of the kind coulomb
true
if the kind of this Unit
is coulomb
, false
otherwise.public boolean isDimensionless()
Unit
is of the kind
dimensionless.
true
if the kind of this Unit
is dimensionless
, false
otherwise.public boolean isFarad()
Unit
is of the kind farad
true
if the kind of this Unit
is farad
, false
otherwise.public boolean isGram()
Unit
is of the kind gram
true
if the kind of this Unit
is gram
, false
otherwise.public boolean isGray()
Unit
is of the kind gray
true
if the kind of this Unit
is gray
, false
otherwise.public boolean isHenry()
Unit
is of the kind henry
true
if the kind of this Unit
is henry
, false
otherwise.public boolean isHertz()
Unit
is of the kind hertz
true
if the kind of this Unit
is hertz
, false
otherwise.public boolean isItem()
Unit
is of the kind item
true
if the kind of this Unit
is item
, false
otherwise.public boolean isJoule()
Unit
is of the kind joule
true
if the kind of this Unit
is joule
, false
otherwise.public boolean isKatal()
Unit
is of the kind katal
true
if the kind of this Unit
is katal
, false
otherwise.public boolean isKelvin()
Unit
is of the kind kelvin
true
if the kind of this Unit
is kelvin
, false
otherwise.public boolean isKilogram()
Unit
is of the kind kilogram
true
if the kind of this Unit
is kilogram
, false
otherwise.public boolean isLitre()
Unit
is of the kind litre
true
if the kind of this Unit
is litre
or 'liter',
false
otherwise.public boolean isLumen()
Unit
is of the kind lumen
true
if the kind of this Unit
is lumen
, false
otherwise.public boolean isLux()
Unit
is of the kind lux
true
if the kind of this Unit
is lux
, false
otherwise.public boolean isMetre()
Unit
is of the kind metre
true
if the kind of this Unit
is metre
or 'meter',
false
otherwise.public boolean isMole()
Unit
is of the kind mole
true
if the kind of this Unit
is mole
, false
otherwise.public boolean isNewton()
Unit
is of the kind newton
true
if the kind of this Unit
is newton
, false
otherwise.public boolean isOhm()
Unit
is of the kind ohm
true
if the kind of this Unit
is ohm
, false
otherwise.public boolean isPascal()
Unit
is of the kind pascal
true
if the kind of this Unit
is pascal
, false
otherwise.public boolean isRadian()
Unit
is of the kind radian
true
if the kind of this Unit
is radian
, false
otherwise.public boolean isSecond()
Unit
is of the kind second
true
if the kind of this Unit
is second
, false
otherwise.public boolean isSiemens()
Unit
is of the kind siemens
true
if the kind of this Unit
is siemens
, false
otherwise.public boolean isSievert()
Unit
is of the kind sievert
true
if the kind of this Unit
is sievert
, false
otherwise.public boolean isSteradian()
Unit
is of the kind steradian
true
if the kind of this Unit
is steradian
, false
otherwise.public boolean isTesla()
Unit
is of the kind tesla
true
if the kind of this Unit
is tesla
, false
otherwise.public boolean isVolt()
Unit
is of the kind volt
true
if the kind of this Unit
is volt
, false
otherwise.public boolean isWatt()
Unit
is of the kind watt
true
if the kind of this Unit
is watt
, false
otherwise.public boolean isWeber()
Unit
is of the kind weber
true
if the kind of this Unit
is weber
, false
otherwise.public boolean isSetKind()
Unit
is set.
true
if the 'kind' attribute of this Unit
is set,
false
otherwise.public boolean isSetExponent()
Unit
is set.
true
if the 'exponent' attribute of this Unit
is set,
false
otherwise.public boolean isSetScale()
Unit
is set.
true
if the 'scale' attribute of this Unit
is set,
false
otherwise.public boolean isSetMultiplier()
Unit
is set.
true
if the 'multiplier' attribute of this Unit
is set,
false
otherwise.public boolean isSetOffset()
Unit
is set.
true
if the 'offset' attribute of this Unit
is set,
false
otherwise.
public int setKind(int kind)
Unit
.
kind
- a unit identifier chosen from the set of constants whose
names begin with UNIT_KIND_
in libsbmlConstants
.
public int setExponent(int value)
Unit
.
value
- the integer to which the attribute 'exponent' should be set.
public int setExponent(double value)
Unit
.
value
- the double to which the attribute 'exponent' should be set.
public int setScale(int value)
Unit
.
value
- the integer to which the attribute 'scale' should be set.
public int setMultiplier(double value)
Unit
.
value
- the floating-point value to which the attribute
'multiplier' should be set.
public int setOffset(double value)
Unit
.
value
- the float-point value to which the attribute 'offset'
should set.
public int unsetKind()
Unit
.
public int unsetExponent()
Unit
.
public int unsetScale()
Unit
.
public int unsetMultiplier()
Unit
.
public int unsetOffset()
Unit
.
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_UNIT
(default).
SBase.getPackageName()
,
Unit.getElementName()
public java.lang.String getElementName()
Unit
, is
always 'unit'.
getElementName
 in class SBase
'unit'.
public static boolean isBuiltIn(java.lang.String name, long level)
name
- a string to be tested against the predefined unit names.
level
- the Level of SBML for which the determination should be
made. This is necessary because there are a few small differences
in allowed units between SBML Level 1 and Level 2.
true
if name
is one of the five SBML predefined unit
identifiers ('substance'
, 'volume'
, 'area'
, 'length'
or
'time'
), false
otherwise.
'length'
and 'area'
were
added in Level 2 Version 1.
public static boolean isUnitKind(java.lang.String name, long level, long version)
'gram'
or 'mole'
).
This method exists because prior to SBML Level 2 Version 3,
an enumeration called UnitKind
was defined by SBML. This enumeration
was removed in SBML Level 2 Version 3 and its values were
folded into the space of values of a type called UnitSId.
This method
therefore has less significance in SBML Level 2 Version 3
and Level 2 Version 4, but remains for backward
compatibility and support for reading models in older Versions of
Level 2.
name
- a string to be tested.
level
- a long integer representing the SBML specification
Level.
version
- a long integer representing the SBML specification
Version.
true
if name is a valid SBML UnitKind, false
otherwise.
public static boolean areIdentical(Unit unit1, Unit unit2)
true
if two
Unit
objects are identical.
Two Unit
objects are considered to be identical if they match in
all attributes. (Contrast this to the method areEquivalent(Unit u1, Unit u2), which compares Unit
objects only with respect
to certain attributes.)
unit1
- the first Unit
object to compare.unit2
- the second Unit
object to compare.
true
if all the attributes of unit1 are identical
to the attributes of unit2, false
otherwise.
Unit.areEquivalent(Unit u1, Unit u2)
public static boolean areEquivalent(Unit unit1, Unit unit2)
true
if
Unit
objects are equivalent.
Two Unit
objects are considered to be equivalent either if (1) both
have a 'kind' attribute value of dimensionless
, or (2) their 'kind',
'exponent' and (for SBML Level 2 Version 1) 'offset'
attribute values are equal. (Contrast this to the method
areIdentical(Unit, Unit), which compares Unit
objects with respect to all
attributes, not just the 'kind' and 'exponent'.)
unit1
- the first Unit
object to compare.unit2
- the second Unit
object to compare.
true
if the 'kind' and 'exponent' attributes of unit1 are
identical to the kind and exponent attributes of unit2, false
otherwise.
Unit.areIdentical(Unit u1, Unit u2)
public static int removeScale(Unit unit)
Unit
to express the unit with the
value of the scale attribute reduced to zero.
For example, 1 millimetre can be expressed as a Unit
with kind=
'metre'
multiplier='1'
scale='-3'
exponent='1'.
It can also be
expressed as a Unit
with kind='metre'
multiplier='0.001'
scale='0'
exponent='1'.
unit
- the Unit
object to manipulate.
Unit.convertToSI(Unit u)
,
Unit.merge(Unit u1, Unit u2)
public static void merge(Unit unit1, Unit unit2)
Unit
objects with the same 'kind' attribute value into a
single Unit
.
For example, the following,
<unit kind='metre' exponent='2'/> <unit kind='metre' exponent='1'/>would be merged to become
<unit kind='metre' exponent='3'/>
unit1
- the first Unit
object the result of the operation is
left as a new version of this unit, modified in-place. Not modified if
the two units have different kinds.
unit2
- the second Unit
object to merge with the first.
Unit.convertToSI(Unit u)
,
Unit.removeScale(Unit u)
public static UnitDefinition convertToSI(Unit unit)
UnitDefinition
object containing the given unit
converted
to the appropriate SI unit.
This method exists because some units can be expressed in terms of others when the same physical dimension is involved. For example, one hertz is identical to 1 sec-1, one litre is equivalent to 1 cubic decametre, and so on.
unit
- the Unit
object to convert to SI.
UnitDefinition
object containing the SI unit.
Unit.merge(Unit u1, Unit u2)
public boolean hasRequiredAttributes()
true
if
all the required attributes for this Unit
object
have been set.
The required attributes for a Unit
object are:
hasRequiredAttributes
 in class SBase
true
if the required attributes have been set, false
otherwise.