public final class ValidationTools
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
static ValidationFunction<SBaseWithDerivedUnit> |
checkDerivedUnit |
|
static byte |
DT_BOOLEAN |
|
static byte |
DT_NUMBER |
|
static byte |
DT_STRING |
|
static byte |
DT_UNKNOWN |
|
static byte |
DT_VECTOR |
|
static Filter |
FILTER_IS_FUNCTION |
|
static Filter |
FILTER_IS_NAME |
|
static java.lang.String |
KEY_META_ID_SET |
Constructor | Description |
---|---|
ValidationTools() |
Modifier and Type | Method | Description |
---|---|---|
static boolean |
areEquivalent(UnitDefinition ud1,
UnitDefinition ud2) |
Returns true or false depending on whether two
UnitDefinition objects are equivalent. |
static boolean |
areIdentical(UnitDefinition ud1,
UnitDefinition ud2) |
|
static java.lang.String |
checkInvalidAttribute(ValidationContext ctx,
AbstractTreeNode treeNode,
java.lang.String attributeName) |
Checks if the given
SBase contains an attribute in the invalid XML user object. |
static boolean |
checkUnit(ValidationContext ctx,
Model m,
java.lang.String units) |
Checks that the given units is a valid units in the
Model (validation rule 10313). |
static java.lang.String |
checkUnknowndAttribute(ValidationContext ctx,
AbstractTreeNode treeNode,
java.lang.String attributeName) |
Checks if the given
SBase contains an attribute in the unknown XML user object. |
static java.lang.String |
checkUnknownUnitSyntax(ValidationContext ctx,
SBase sbase,
java.lang.String attributeName) |
Checks if the given
SBase contains an attribute in the unknown XML user object. |
static boolean |
containsMathOnlyPredefinedFunctions(ASTNode math) |
|
static byte |
getDataType(ASTNode node) |
Returns the data type of an
ASTNode . |
static java.util.Set<java.lang.String> |
getDefinedSpecies(Reaction r) |
|
static UnitDefinition |
getDerivedExtendUnitDefinition(Model m) |
Returns the extend
UnitDefinition for the given Model . |
static UnitDefinition |
getDerivedSubstanceUnitDefinition(Model m) |
Returns the substance
UnitDefinition for the given Model . |
static UnitDefinition |
getDerivedSubstanceUnitDefinition(Species sbase) |
Returns the substance only derived
UnitDefinition for the given Species . |
static UnitDefinition |
getDerivedTimeUnitDefinition(Model m) |
Returns the time
UnitDefinition for the given Model . |
static UnitDefinition |
getDerivedUnitDefinition(ValidationContext ctx,
SBaseWithDerivedUnit sbase) |
Returns the derived
UnitDefinition for the given SBaseWithDerivedUnit . |
static UnitDefinition |
getMathDerivedUnitDefinition(ValidationContext ctx,
MathContainer container) |
Returns the derived
UnitDefinition for the given MathContainer . |
static boolean |
hasCorrectUnits(ValidationContext ctx,
KineticLaw kl) |
Returns true if the given
KineticLaw has correct derived units. |
static boolean |
haveEquivalentUnits(ValidationContext ctx,
Assignment assignment,
Variable var) |
Returns true if the given
Assignment and Variable have equivalent derived units. |
static boolean |
isBigLetter(char c) |
A big letter is a ASCII symbol between 'A' and 'Z'.
|
static boolean |
isDigit(char c) |
A digit is a ASCII symbol between '0' and '9'.
|
static boolean |
isId(java.lang.String s,
int level,
int version) |
A SId starts with a letter or '-' and can be followed by a various amout
of idChars.
|
static boolean |
isIdChar(char c) |
A idChar is a letter, digit or '-'.
|
static boolean |
isLetter(char c) |
A letter is either a small letter or big letter.
|
static boolean |
isLocalParameter(ASTNode node,
java.lang.String name) |
|
static boolean |
isNameChar(char c) |
A NameChar (defined in the XML Schema 1.0) can be a letter, a digit, '
|
static boolean |
isSboTerm(java.lang.String s) |
A SBOTerm begins with 'SBO:' followed by exactly 7 digits
|
static boolean |
isSmallLetter(char c) |
A small letter is a ASCII symbol between 'a' and 'z'.
|
static boolean |
isSpeciesReference(Model m,
java.lang.String name) |
|
static boolean |
isValidVariable(Variable var,
int level) |
|
static boolean |
isXmlId(java.lang.String s) |
A XML ID (defined in the XML Schema 1.0) starts with a letter, '-' or ':'
which can be followed by a unlimited amout of NameChars.
|
static java.lang.String |
printASTNodeAsFormula(ASTNode node) |
Returns the infix formula representing this ASTNode or an empty String if there was
a problem to construct the formula.
|
public static final byte DT_UNKNOWN
public static final byte DT_NUMBER
public static final byte DT_BOOLEAN
public static final byte DT_STRING
public static final byte DT_VECTOR
public static final java.lang.String KEY_META_ID_SET
public static Filter FILTER_IS_FUNCTION
public static Filter FILTER_IS_NAME
public static ValidationFunction<SBaseWithDerivedUnit> checkDerivedUnit
public static boolean containsMathOnlyPredefinedFunctions(ASTNode math)
public static java.util.Set<java.lang.String> getDefinedSpecies(Reaction r)
public static byte getDataType(ASTNode node)
ASTNode
.
It can be DT_NUMBER
, DT_BOOLEAN
, DT_STRING
,
DT_VECTOR
or DT_UNKNOWN
.
node
- an ASTNode
public static boolean isLocalParameter(ASTNode node, java.lang.String name)
public static boolean isSpeciesReference(Model m, java.lang.String name)
public static boolean isValidVariable(Variable var, int level)
public static boolean isLetter(char c)
c
- public static boolean isSmallLetter(char c)
c
- public static boolean isBigLetter(char c)
c
- public static boolean isIdChar(char c)
c
- public static boolean isDigit(char c)
c
- public static boolean isNameChar(char c)
c
- public static boolean isId(java.lang.String s, int level, int version)
s
- public static boolean isSboTerm(java.lang.String s)
s
- public static boolean isXmlId(java.lang.String s)
s
- public static boolean haveEquivalentUnits(ValidationContext ctx, Assignment assignment, Variable var)
Assignment
and Variable
have equivalent derived units.assignment
- the assignment to checkvar
- the variable to checkAssignment
and Variable
have equivalent derived units.public static boolean hasCorrectUnits(ValidationContext ctx, KineticLaw kl)
KineticLaw
has correct derived units.kl
- the kineticLaw to checkKineticLaw
has correct derived units.public static boolean areEquivalent(UnitDefinition ud1, UnitDefinition ud2)
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.
For this test, the UnitDefinitions are not cloned or simplified so be sure to call this method if you don't mind the arguments to be modified and if your UnitDefinitions are already simplified and converted to SI.
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.UnitDefinition.areIdentical(UnitDefinition, UnitDefinition)
,
Unit.areEquivalent(Unit, String)
public static boolean areIdentical(UnitDefinition ud1, UnitDefinition ud2)
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.
For this test, the UnitDefinitions are not cloned or simplified so be sure to call this method if you don't mind the arguments to be modified and if your UnitDefinitions are already simplified and converted to SI.
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 boolean checkUnit(ValidationContext ctx, Model m, java.lang.String units)
Model
(validation rule 10313).ctx
- the validation contextm
- the modelunits
- the units value to checkfalse
if the given units is not a valid units in the Model
, true
otherwise.public static java.lang.String checkInvalidAttribute(ValidationContext ctx, AbstractTreeNode treeNode, java.lang.String attributeName)
SBase
contains an attribute in the invalid XML user object.ctx
- the validation contexttreeNode
- the object to checkattributeName
- the attribute name to search in the invalid XML attributespublic static java.lang.String checkUnknowndAttribute(ValidationContext ctx, AbstractTreeNode treeNode, java.lang.String attributeName)
SBase
contains an attribute in the unknown XML user object.ctx
- the validation contexttreeNode
- the object to checkattributeName
- the attribute name to search in the unknown XML attributespublic static java.lang.String checkUnknownUnitSyntax(ValidationContext ctx, SBase sbase, java.lang.String attributeName)
SBase
contains an attribute in the unknown XML user object.
If the attribute is found, checks that it respect the UnitSId syntax (validation rule 10311).ctx
- the validation contextsbase
- the sbase to checkattributeName
- the attribute name to search in the unknown XML attributesnull
otherwise.public static java.lang.String printASTNodeAsFormula(ASTNode node)
public static UnitDefinition getDerivedUnitDefinition(ValidationContext ctx, SBaseWithDerivedUnit sbase)
UnitDefinition
for the given SBaseWithDerivedUnit
.
Try to get the derived unit from the user objects first and store it there for future usage if it is not there.
ctx
- the validation contextsbase
- the sbaseUnitDefinition
for the given SBaseWithDerivedUnit
.public static UnitDefinition getDerivedSubstanceUnitDefinition(Species sbase)
UnitDefinition
for the given Species
.
Try to get the derived unit from the user objects first and store it there for future usage if it is not there.
sbase
- the sbaseUnitDefinition
for the given Species
.public static UnitDefinition getDerivedExtendUnitDefinition(Model m)
UnitDefinition
for the given Model
.
Try to get the derived unit from the user objects first and store it there for future usage if it is not there.
m
- the modelUnitDefinition
for the given Model
.public static UnitDefinition getDerivedSubstanceUnitDefinition(Model m)
UnitDefinition
for the given Model
.
Try to get the derived unit from the user objects first and store it there for future usage if it is not there.
m
- the modelUnitDefinition
for the given Model
.public static UnitDefinition getDerivedTimeUnitDefinition(Model m)
UnitDefinition
for the given Model
.
Try to get the derived unit from the user objects first and store it there for future usage if it is not there.
m
- the modelUnitDefinition
for the given Model
.public static UnitDefinition getMathDerivedUnitDefinition(ValidationContext ctx, MathContainer container) throws SBMLException
UnitDefinition
for the given MathContainer
.ctx
- the validation contextcontainer
- the math containerSBMLException