org.sbml.jsbml
public class UnitDefinition extends AbstractNamedSBase
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
AREA
Identifier of the (for SBML Level 2) predefined
UnitDefinition
area. |
static java.lang.String |
LENGTH
Identifier of the (for SBML Level 2) predefined
UnitDefinition
length. |
private ListOf<Unit> |
listOfUnits
Represents the 'listOfUnit' XML sub-element of a UnitDefinition.
|
private static org.apache.log4j.Logger |
logger
The logger for this class.
|
static long |
serialVersionUID
Generated serial version identifier.
|
static java.lang.String |
SUBSTANCE
Identifier of the (for the SBML Levels 1 and 2) predefined
UnitDefinition substance. |
static java.lang.String |
TIME
Identifier of the (for the SBML Levels 1 and 2) predefined
UnitDefinition time. |
static java.lang.String |
VOLUME
Identifier of the (for some SBML Levels 1 and 2) predefined
UnitDefinition volume. |
ignoredExtensions, ignoredXMLElements, lvlistOfListeners, parent, UNKNOWN_ATTRIBUTES, UNKNOWN_ELEMENTS| Constructor and Description |
|---|
UnitDefinition()
Creates an UnitDefinition instance.
|
UnitDefinition(int level,
int version) |
UnitDefinition(java.lang.String id) |
UnitDefinition(java.lang.String id,
int level,
int version)
Creates an UnitDefinition instance from an id, level and version.
|
UnitDefinition(java.lang.String id,
java.lang.String name,
int level,
int version)
Creates an UnitDefinition instance from an id, level and version.
|
UnitDefinition(UnitDefinition unitDefinition)
Creates an UnitDefinition instance from a given UnitDefinition.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addUnit(java.lang.String unit) |
void |
addUnit(Unit.Kind kind)
Convenient method to add a new unit object with the given kind that will
have the same level/version combination than this
UnitDefinition
object. |
void |
addUnit(Unit u)
Adds an
Unit to this UnitDefinition. |
static UnitDefinition |
area(int level,
int version)
Predefined unit for area.
|
static boolean |
areCompatible(UnitDefinition ud1,
UnitDefinition ud2)
Predicate returning
true or false depending on
whether two UnitDefinition objects are compatible. |
static boolean |
areEquivalent(UnitDefinition ud,
java.lang.String units)
Checks whether the given
UnitDefinition and the
UnitDefinition or Unit represented by the given
String are equivalent. |
static boolean |
areEquivalent(UnitDefinition ud1,
UnitDefinition ud2)
Predicate returning true or false depending on whether two
UnitDefinition objects are equivalent. |
static boolean |
areIdentical(UnitDefinition ud1,
UnitDefinition ud2)
|
void |
clear()
Removes all
Unit elements from the list of Units in this object. |
UnitDefinition |
clone()
Creates a deep copy of this object, i.e., a new
SBase with the same properties
like this one. |
void |
convertToSIUnits()
This method converts this unit definition to a
|
Unit |
createUnit() |
Unit |
createUnit(Unit.Kind kind) |
UnitDefinition |
divideBy(UnitDefinition definition)
Divides this unit definition by the second unit definition.
|
boolean |
getAllowsChildren() |
javax.swing.tree.TreeNode |
getChildAt(int index) |
int |
getChildCount() |
ListOf<Unit> |
getListOfUnits() |
int |
getNumUnits() |
ListOf<UnitDefinition> |
getParent()
This is equivalent to calling
AbstractSBase.getParentSBMLObject(), but this
method is needed for TreeNode. |
static UnitDefinition |
getPredefinedUnit(java.lang.String id,
int level,
int version)
This method returns the predefined unit with the given identifier for the
specified level and version combination or null if either for the given
combination of level and version there is no such predefined unit or the
identifier is not one of those belonging to the group of predefined unit
definitions.
|
Unit |
getUnit(int i)
Returns a specific Unit instance belonging to this UnitDefinition.
|
int |
getUnitCount() |
boolean |
isBuiltIn()
Deprecated.
use
isPredefined() |
static boolean |
isBuiltIn(UnitDefinition ud)
Deprecated.
use
isPredefined() |
boolean |
isIdMandatory()
This method can be used to query if the identifier of this
NamedSBase is required to be defined (i.e., not null)
in the definition of SBML. |
boolean |
isInvalid()
This method checks, if this UnitDefinition only contains Invalid as
Unit.Kind. |
boolean |
isPredefined()
This method tests if this unit definition is a predefined unit.
|
static boolean |
isPredefined(java.lang.String name,
int level) |
static boolean |
isPredefined(UnitDefinition ud)
Test if the given unit is a predefined unit.
|
boolean |
isSetListOfUnits() |
boolean |
isUnitKind()
Convenient method to test whether this
UnitDefinition contains
exactly one Unit that itself represents a Unit.Kind, i.e.,
multiplier = 1, exponent = 1, scale = 1. |
boolean |
isVariantOfArea() |
boolean |
isVariantOfLength()
Convenience function for testing if a given unit definition is a variant
of the predefined unit identifier 'length'.
|
boolean |
isVariantOfSubstance()
Convenience function for testing if a given unit definition is a variant
of the predefined unit identifier 'substance'.
|
boolean |
isVariantOfSubstancePerArea() |
boolean |
isVariantOfSubstancePerLength() |
boolean |
isVariantOfSubstancePerTime() |
boolean |
isVariantOfSubstancePerVolume() |
boolean |
isVariantOfTime()
Convenience function for testing if a given unit definition is a variant
of the predefined unit identifier 'time'.
|
boolean |
isVariantOfVolume()
Convenience function for testing if a given unit definition is a variant
of the predefined unit identifier 'volume'.
|
static UnitDefinition |
length(int level,
int version)
Predefined unit for length.
|
UnitDefinition |
multiplyWith(UnitDefinition definition)
Multiplies this unit with the given unit definition, i.e., adds a clone
of each unit object in the list of units of the given definition to the
list of this unit.
|
static java.lang.String |
printUnits(UnitDefinition ud)
Returns a string that expresses the unit definition represented by this
UnitDefinition object.
|
static java.lang.String |
printUnits(UnitDefinition ud,
boolean compact)
Returns a string that expresses the unit definition represented by this
UnitDefinition object.
|
UnitDefinition |
raiseByThePowerOf(double exponent)
Raises this unit definition by the power of the given exponent, i.e., the
exponents of every unit contained by this unit definition are multiplied
with the given exponent.
|
Unit |
removeUnit(int i)
Removes the nth
Unit object from this UnitDefinition object and returns a
pointer to it. |
static void |
reorder(UnitDefinition ud)
|
void |
setId(java.lang.String id)
sets the id value with 'id'
|
void |
setListOfUnits(ListOf<Unit> listOfUnits)
Sets the
listOfUnits of this UnitDefinition. |
UnitDefinition |
simplify()
Simplifies the
UnitDefinition so that any Unit objects
occurring within the listOfUnits occurs only once. |
static UnitDefinition |
simplify(UnitDefinition ud) |
static UnitDefinition |
substance(int level,
int version)
Predefined unit for substance.
|
static UnitDefinition |
time(int level,
int version)
Predefined unit for time.
|
java.lang.String |
toString()
Returns the name of the component, if it is available.
|
boolean |
unsetListOfUnits()
Removes the
listOfUnits from this UnitDefinition and
notifies all registered instances of TreeNodeChangeListener. |
static UnitDefinition |
volume(int level,
int version)
Predefined unit for volume.
|
checkIdentifier, equals, getId, getName, hashCode, isSetId, isSetName, isValidId, readAttribute, setName, unsetId, unsetName, writeXMLAttributesaddCVTerm, addDeclaredNamespace, addExtension, appendNotes, appendNotes, checkLevelAndVersionCompatibility, createHistory, createPlugin, disablePackage, enablePackage, enablePackage, filterCVTerms, filterCVTerms, filterCVTerms, fireNodeRemovedEvent, getAnnotation, getAnnotationString, getCVTerm, getCVTermCount, getCVTerms, getDeclaredNamespaces, getElementName, getExtension, getExtensionPackages, getHistory, getLevel, getLevelAndVersion, getMetaId, getModel, getNamespace, getNotes, getNotesString, getNumCVTerms, getNumPlugins, getParentSBMLObject, getPlugin, getSBMLDocument, getSBOTerm, getSBOTermID, getVersion, hasValidAnnotation, hasValidLevelVersionNamespaceCombination, isExtendedByOtherPackages, isPackageEnabled, isPackageURIEnabled, isPkgEnabled, isPkgURIEnabled, isSetAnnotation, isSetHistory, isSetLevel, isSetLevelAndVersion, isSetMetaId, isSetNotes, isSetParentSBMLObject, isSetPlugin, isSetSBOTerm, isSetVersion, isValidLevelAndVersionCombination, isValidMetaId, notifyChildChange, registerChild, setAnnotation, setHistory, setLevel, setLevelAndVersion, setMetaId, setNamespace, setNotes, setNotes, setParentSBML, setParentSBMLObject, setSBOTerm, setSBOTerm, setThisAsParentSBMLObject, setVersion, unregister, unsetAnnotation, unsetCVTerms, unsetExtension, unsetHistory, unsetMetaId, unsetNamespace, unsetNotes, unsetPlugin, unsetSBOTermaddAllChangeListeners, addTreeNodeChangeListener, addTreeNodeChangeListener, children, clearUserObjects, containsUserObjectKey, filter, filter, filter, fireNodeAddedEvent, firePropertyChange, getIndex, getListOfTreeNodeChangeListeners, getNumChildren, getRoot, getTreeNodeChangeListenerCount, getUserObject, indexOf, isLeaf, isRoot, isSetParent, isSetUserObjects, putUserObject, removeAllTreeNodeChangeListeners, removeFromParent, removeTreeNodeChangeListener, removeTreeNodeChangeListener, removeUserObject, setParent, userObjectKeySetfinalize, getClass, notify, notifyAll, wait, wait, waitaddCVTerm, addDeclaredNamespace, addExtension, appendNotes, appendNotes, createPlugin, disablePackage, enablePackage, enablePackage, filterCVTerms, filterCVTerms, filterCVTerms, getAnnotation, getAnnotationString, getCVTerm, getCVTermCount, getCVTerms, getDeclaredNamespaces, getElementName, getExtension, getExtensionPackages, getHistory, getLevel, getLevelAndVersion, getMetaId, getModel, getNamespace, getNotes, getNotesString, getNumCVTerms, getNumPlugins, getParentSBMLObject, getPlugin, getSBMLDocument, getSBOTerm, getSBOTermID, getVersion, hasValidAnnotation, hasValidLevelVersionNamespaceCombination, isExtendedByOtherPackages, isPackageEnabled, isPackageURIEnabled, isPkgEnabled, isPkgURIEnabled, isSetAnnotation, isSetHistory, isSetLevel, isSetLevelAndVersion, isSetMetaId, isSetNotes, isSetParentSBMLObject, isSetPlugin, isSetSBOTerm, isSetVersion, registerChild, removeTreeNodeChangeListener, setAnnotation, setHistory, setLevel, setMetaId, setNotes, setNotes, setSBOTerm, setSBOTerm, setThisAsParentSBMLObject, setVersion, unregister, unsetAnnotation, unsetCVTerms, unsetExtension, unsetHistory, unsetMetaId, unsetNotes, unsetPlugin, unsetSBOTermaddAllChangeListeners, addTreeNodeChangeListener, addTreeNodeChangeListener, clearUserObjects, containsUserObjectKey, filter, filter, filter, fireNodeAddedEvent, fireNodeRemovedEvent, firePropertyChange, getListOfTreeNodeChangeListeners, getRoot, getTreeNodeChangeListenerCount, getUserObject, isRoot, isSetParent, isSetUserObjects, putUserObject, removeAllTreeNodeChangeListeners, removeFromParent, removeTreeNodeChangeListener, removeUserObject, userObjectKeySetpublic static final java.lang.String AREA
UnitDefinition
area.public static final java.lang.String LENGTH
UnitDefinition
length.private static final org.apache.log4j.Logger logger
public static final long serialVersionUID
public static final java.lang.String SUBSTANCE
UnitDefinition substance.public static final java.lang.String TIME
UnitDefinition time.public static final java.lang.String VOLUME
UnitDefinition volume.public UnitDefinition()
public UnitDefinition(int level,
int version)
level - version - public UnitDefinition(java.lang.String id)
id - public UnitDefinition(java.lang.String id,
int level,
int version)
id - level - version - public UnitDefinition(java.lang.String id,
java.lang.String name,
int level,
int version)
id - name - level - version - public UnitDefinition(UnitDefinition unitDefinition)
unitDefinition - public static final UnitDefinition area(int level, int version)
public static boolean areCompatible(UnitDefinition ud1, UnitDefinition ud2)
Predicate returning true or false depending on
whether two UnitDefinition objects are compatible.
For the purposes of performing this comparison, two
UnitDefinition objects are considered compatible when they
contain compatible list of Unit objects. This means two
UnitDefinition objects are compatible if both satisfy the method
areEquivalent(UnitDefinition, UnitDefinition) or one of both has
Unit.Kind.INVALID as Unit.Kind
ud1 - the first UnitDefinition object to compareud2 - the second UnitDefinition object to comparetrue if all the Unit objects in ud1 are
compatible to the Unit objects in ud2, false
otherwise.areIdentical(UnitDefinition, UnitDefinition),
Unit.areEquivalent(Unit, Unit)public static boolean areEquivalent(UnitDefinition ud, java.lang.String units)
UnitDefinition and the
UnitDefinition or Unit represented by the given
String are equivalent.ud - units - areEquivalent(UnitDefinition, UnitDefinition),
Unit.areEquivalent(Unit, Unit)public static boolean areEquivalent(UnitDefinition ud1, UnitDefinition ud2)
Predicate returning true or false depending on whether two
UnitDefinition objects are equivalent.
For the purposes of performing this comparison, two UnitDefinition
objects are considered equivalent when they contain equivalent list of
Unit objects. Unit objects are in turn considered
equivalent if they satisfy the predicate
Unit.areEquivalent(Unit, Unit). The predicate tests a subset of the
objects's attributes.
ud1 - the first UnitDefinition object to compareud2 - the second UnitDefinition object to comparetrue if all the Unit objects in ud1 are equivalent to
the Unit objects in ud2, false otherwise.areIdentical(UnitDefinition, UnitDefinition),
Unit.areEquivalent(Unit, String)public static boolean areIdentical(UnitDefinition ud1, UnitDefinition ud2)
Predicate returning true or false depending on
whether two UnitDefinition objects are identical.
For the purposes of performing this comparison, two UnitDefinition
objects are considered identical when they contain identical lists of
Unit objects. Pairs of Unit objects in the lists are in
turn considered identical if they satisfy the predicate
Unit.areIdentical(Unit, Unit). The predicate compares every
attribute of the Unit objects.
ud1 - the first UnitDefinition object to compareud2 - the second UnitDefinition object to comparetrue if all the Unit objects in ud1 are
identical to the Unit objects of ud2, false
otherwise.public static final UnitDefinition getPredefinedUnit(java.lang.String id, int level, int version)
id - one of the values
level - a number greater than zero.version - a number greater than zero.@Deprecated public static boolean isBuiltIn(UnitDefinition ud)
isPredefined()ud - public static boolean isPredefined(java.lang.String name,
int level)
name - level - public static boolean isPredefined(UnitDefinition ud)
ud - public static final UnitDefinition length(int level, int version)
public static java.lang.String printUnits(UnitDefinition ud)
ud - the UnitDefinition objectpublic static java.lang.String printUnits(UnitDefinition ud, boolean compact)
ud - the UnitDefinition objectcompact - boolean indicating whether the compact form should be used
(defaults to false)public static void reorder(UnitDefinition ud)
ud - the UnitDefinition object whose Units are to be
reordered.public static UnitDefinition simplify(UnitDefinition ud)
ud - UnitDefinition. In order
to make sure that the original UnitDefinition is not
changed, it is cloned before the simplification.public static final UnitDefinition substance(int level, int version)
public static final UnitDefinition time(int level, int version)
public static final UnitDefinition volume(int level, int version)
public void addUnit(java.lang.String unit)
unit - public void addUnit(Unit u)
Unit to this UnitDefinition.u - public void addUnit(Unit.Kind kind)
UnitDefinition
object.kind - public void clear()
Unit elements from the list of Units in this object.public UnitDefinition clone()
SBaseSBase with the same properties
like this one.clone in interface SBaseclone in class AbstractSBasepublic void convertToSIUnits()
public Unit createUnit()
public UnitDefinition divideBy(UnitDefinition definition)
definition - public boolean getAllowsChildren()
getAllowsChildren in interface javax.swing.tree.TreeNodegetAllowsChildren in class AbstractSBasepublic javax.swing.tree.TreeNode getChildAt(int index)
getChildAt in interface javax.swing.tree.TreeNodegetChildAt in class AbstractSBasepublic int getChildCount()
getChildCount in interface javax.swing.tree.TreeNodegetChildCount in class AbstractSBasepublic ListOf<Unit> getListOfUnits()
public int getNumUnits()
public int getUnitCount()
public ListOf<UnitDefinition> getParent()
AbstractSBaseAbstractSBase.getParentSBMLObject(), but this
method is needed for TreeNode.getParent in interface javax.swing.tree.TreeNodegetParent in class AbstractSBaseAbstractSBase.getParentSBMLObject()public Unit getUnit(int i)
i - an integer, the index of the Unit to be returned.@Deprecated public boolean isBuiltIn()
isPredefined()public boolean isIdMandatory()
NamedSBaseNamedSBase is required to be defined (i.e., not null)
in the definition of SBML.true if the identifier of this element must be set in
order to create a valid SBML representation. false
otherwise, i.e., if the identifier can be understood as an optional
attribute.public boolean isInvalid()
Unit.Kind.public boolean isPredefined()
public boolean isSetListOfUnits()
true if the listOfUnits is not null and not empty.public boolean isUnitKind()
UnitDefinition contains
exactly one Unit that itself represents a Unit.Kind, i.e.,
multiplier = 1, exponent = 1, scale = 1. Note that this method requires
the level and version attributes of this UnitDefinition to be
set.public boolean isVariantOfArea()
true if this UnitDefinition is a variant of Areapublic boolean isVariantOfLength()
two - true if this UnitDefinition is a variant of the predefined unit
length, meaning metres with only arbitrary variations in scale or
multiplier values; false otherwise.public boolean isVariantOfSubstance()
true if this UnitDefinition is a variant of the predefined unit
substance, meaning moles or items (and grams or kilograms from
SBML Level 2 Version 2 onwards) with only arbitrary variations in
scale or multiplier values; false otherwise.public boolean isVariantOfSubstancePerArea()
public boolean isVariantOfSubstancePerLength()
true if this UnitDefinition is a variant of substance per length.public boolean isVariantOfSubstancePerTime()
public boolean isVariantOfSubstancePerVolume()
true if this UnitDefinition is a variant of substance per volume.public boolean isVariantOfTime()
true if this UnitDefinition is a variant of
the predefined unit time, meaning second with only arbitrary
variations in scale or multiplier values; false
otherwise.public boolean isVariantOfVolume()
true if this UnitDefinition is a variant of
the predefined unit volume, meaning litre or cubic metre with
only arbitrary variations in scale or multiplier values;
false otherwise.public UnitDefinition multiplyWith(UnitDefinition definition)
definition - public UnitDefinition raiseByThePowerOf(double exponent)
exponent - UnitDefinition.public Unit removeUnit(int i)
Unit object from this UnitDefinition object and returns a
pointer to it.
The caller owns the returned object and is responsible for deleting it.i - the index of the Unit object to removeUnit object removed. As mentioned above, the caller owns the
returned item. null is returned if the given index is out of
range.public void setId(java.lang.String id)
NamedSBasesetId in interface NamedSBasesetId in class AbstractNamedSBasepublic void setListOfUnits(ListOf<Unit> listOfUnits)
listOfUnits of this UnitDefinition.
Automatically sets the parent SBML object of the list to this
UnitDefinition instance.listOfUnits - public UnitDefinition simplify()
UnitDefinition so that any Unit objects
occurring within the listOfUnits occurs only once. Units
of Unit.Kind Kind.INVALID are treated like
Kind.DIMENSIONLESS units and will therefore tend to disappear by
merging with other units.UnitDefinition.public java.lang.String toString()
AbstractNamedSBasetoString in class AbstractNamedSBasepublic boolean unsetListOfUnits()
listOfUnits from this UnitDefinition and
notifies all registered instances of TreeNodeChangeListener.true if calling this method lead to a change in this
data structure.