public class ConversionProperties extends java.lang.Object
This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. It is a class used in the implementation of extra functionality provided by libSBML.
LibSBML provides a number of converters that can perform transformations
on SBML documents. The properties of SBML converters are communicated
using objects of class ConversionProperties
, and within such objects,
individual options are encapsulated using ConversionOption
objects. The
ConversionProperties
class provides numerous methods for setting and
getting options.
ConversionProperties
objects are also used to determine the target SBML
namespace when an SBML converter's behavior depends on the intended
Level+Version combination of SBML. In addition, it is conceivable that
conversions may be affected by SBML Level 3 packages being used by an
SBML document consequently, the packages in use are also communicated by
the values of the SBML namespaces set on a ConversionProperties
object.
The use of all the converters follows a similar approach. First, one
creates a ConversionProperties
object and calls
ConversionProperties.addOption(ConversionOption)
on this object with one arguments: a text string that identifies the desired
converter. (The text string is specific to each converter consult the
documentation for a given converter to find out how it should be enabled.)
Next, for some converters, the caller can optionally set some
converter-specific properties using additional calls to
ConversionProperties.addOption(ConversionOption)
.
Many converters provide the ability to
configure their behavior to some extent this is realized through the use
of properties that offer different options. The default property values
for each converter can be interrogated using the method
SBMLConverter.getDefaultProperties()
on the converter class in question .
Finally, the caller should invoke the method
SBMLDocument.convert(ConversionProperties)
with the ConversionProperties
object as an argument.
The following code fragment illustrates an example using
SBMLReactionConverter
, which is invoked using the option string
'replaceReactions':
ConversionProperties
props = newConversionProperties
() if (props != null) { props.addOption('replaceReactions') } else { // Deal with error. }
In the case of SBMLReactionConverter
, there are no options to affect
its behavior, so the next step is simply to invoke the converter on
an SBMLDocument
object. Continuing the example code:
// Assume that the variable 'document' has been set to an SBMLDocument
object.
status = document.convert(config)
if (status != libsbml.LIBSBML_OPERATION_SUCCESS)
{
// Handle error somehow.
System.out.println('Error: conversion failed due to the following:')
document.printErrors()
}
Here is an example of using a converter that offers an option. The
following code invokes SBMLStripPackageConverter
to remove the
SBML Level 3 Layout package from a model. It sets the name
of the package to be removed by adding a value for the option named
'package'
defined by that converter:
ConversionProperties
config = newConversionProperties
() if (config != None) { config.addOption('stripPackage') config.addOption('package', 'layout') status = document.convert(config) if (status != LIBSBML_OPERATION_SUCCESS) { // Handle error somehow. System.out.println('Error: unable to strip theLayout
package') document.printErrors() } } else { // Handle error somehow. System.out.println('Error: unable to createConversionProperties
object') }
LibSBML provides a number of built-in converters by convention, their names end in Converter. The following are the built-in converters provided by libSBML 5.13.0 :
CobraToFbcConverter
CompFlatteningConverter
FbcToCobraConverter
FbcV1ToV2Converter
FbcV2ToV1Converter
SBMLFunctionDefinitionConverter
SBMLIdConverter
SBMLInferUnitsConverter
SBMLInitialAssignmentConverter
SBMLLevel1Version1Converter
SBMLLevelVersionConverter
SBMLLocalParameterConverter
SBMLReactionConverter
SBMLRuleConverter
SBMLStripPackageConverter
SBMLUnitsConverter
ConversionOption
,
SBMLNamespaces
Constructor and Description |
---|
ConversionProperties()
Constructor that initializes the conversion properties
with a specific SBML target namespace.
|
ConversionProperties(ConversionProperties orig)
Copy constructor.
|
ConversionProperties(SBMLNamespaces targetNS)
Constructor that initializes the conversion properties
with a specific SBML target namespace.
|
Modifier and Type | Method and Description |
---|---|
void |
addOption(ConversionOption option)
Adds a copy of the given option to this properties object.
|
void |
addOption(java.lang.String key)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
boolean value)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
boolean value,
java.lang.String description)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
double value)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
double value,
java.lang.String description)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
float value)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
float value,
java.lang.String description)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
int value)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
int value,
java.lang.String description)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
java.lang.String value)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
java.lang.String value,
int type)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
java.lang.String value,
int type,
java.lang.String description)
Adds a new
ConversionOption object with the given parameters. |
void |
addOption(java.lang.String key,
java.lang.String value,
java.lang.String description)
Adds a new
ConversionOption object with the given parameters. |
ConversionProperties |
cloneObject()
Creates and returns a deep copy of this
ConversionProperties object. |
void |
delete()
Explicitly deletes the underlying native object.
|
boolean |
getBoolValue(java.lang.String key)
Returns the value of the given option as a Boolean.
|
java.lang.String |
getDescription(java.lang.String key)
Returns the description string for a given option in this properties
object.
|
double |
getDoubleValue(java.lang.String key)
Returns the value of the given option as a
double. |
float |
getFloatValue(java.lang.String key)
Returns the value of the given option as a
float. |
int |
getIntValue(java.lang.String key)
Returns the value of the given option as an integer.
|
int |
getNumOptions()
Returns the number of options in this Conversion Properties object
|
ConversionOption |
getOption(int index)
Returns the
ConversionOption object for the given index. |
ConversionOption |
getOption(java.lang.String key)
Returns the
ConversionOption object for a given key. |
SBMLNamespaces |
getTargetNamespaces()
Returns the current target SBML namespace.
|
int |
getType(java.lang.String key)
Returns the type of a given option in this properties object.
|
java.lang.String |
getValue(java.lang.String key)
Returns the value of the given option as a string.
|
boolean |
hasOption(java.lang.String key)
Returns
true if this properties object contains an option with
the given key. |
boolean |
hasTargetNamespaces()
Returns
true if the target SBML namespace has been set. |
ConversionOption |
removeOption(java.lang.String key)
Removes the option with the given key from this properties object.
|
void |
setBoolValue(java.lang.String key,
boolean value)
Sets the value of the given option to a Boolean.
|
void |
setDoubleValue(java.lang.String key,
double value)
Sets the value of the given option to a
double. |
void |
setFloatValue(java.lang.String key,
float value)
Sets the value of the given option to a
float. |
void |
setIntValue(java.lang.String key,
int value)
Sets the value of the given option to an integer.
|
void |
setTargetNamespaces(SBMLNamespaces targetNS)
Sets the target namespace.
|
void |
setValue(java.lang.String key,
java.lang.String value)
Sets the value of the given option to a string.
|
public ConversionProperties(SBMLNamespaces targetNS)
targetNS
- the target namespace to convert to
public ConversionProperties()
targetNS
- the target namespace to convert to
public ConversionProperties(ConversionProperties orig)
orig
- the object to copy.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 ConversionProperties.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 ConversionProperties.delete()
themselves.
public ConversionProperties cloneObject()
ConversionProperties
object.
ConversionProperties
object.public SBMLNamespaces getTargetNamespaces()
public boolean hasTargetNamespaces()
true
if the target SBML namespace has been set.
true
if the target namespace has been set, false
otherwise.public void setTargetNamespaces(SBMLNamespaces targetNS)
targetNS
- the target namespace to use.public java.lang.String getDescription(java.lang.String key)
key
- the key for the option.
public int getType(java.lang.String key)
key
- the key for the option.
public ConversionOption getOption(java.lang.String key)
ConversionOption
object for a given key.
key
- the key for the option.
public ConversionOption getOption(int index)
ConversionOption
object for the given index.
index
- the index for the option.
public void addOption(ConversionOption option)
option
- the option to addpublic void addOption(java.lang.String key, java.lang.String value, int type, java.lang.String description)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- (optional) the value of that optiontype
- (optional) the type of the option (see the documentation
for ConversionOption
for more information about the types)description
- (optional) the description for the option
public void addOption(java.lang.String key, java.lang.String value, int type)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- (optional) the value of that optiontype
- (optional) the type of the option (see the documentation
for ConversionOption
for more information about the types)description
- (optional) the description for the option
public void addOption(java.lang.String key, java.lang.String value)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- (optional) the value of that optiontype
- (optional) the type of the option (see the documentation
for ConversionOption
for more information about the types)description
- (optional) the description for the option
public void addOption(java.lang.String key)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- (optional) the value of that optiontype
- (optional) the type of the option (see the documentation
for ConversionOption
for more information about the types)description
- (optional) the description for the option
public void addOption(java.lang.String key, java.lang.String value, java.lang.String description)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- the string value of that optiondescription
- (optional) the description for the option
public void addOption(java.lang.String key, boolean value, java.lang.String description)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- the boolean value of that optiondescription
- (optional) the description for the option
public void addOption(java.lang.String key, boolean value)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- the boolean value of that optiondescription
- (optional) the description for the option
public void addOption(java.lang.String key, double value, java.lang.String description)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- the double value of that optiondescription
- (optional) the description for the option
public void addOption(java.lang.String key, double value)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- the double value of that optiondescription
- (optional) the description for the option
public void addOption(java.lang.String key, float value, java.lang.String description)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- the float value of that optiondescription
- (optional) the description for the option
public void addOption(java.lang.String key, float value)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- the float value of that optiondescription
- (optional) the description for the option
public void addOption(java.lang.String key, int value, java.lang.String description)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- the integer value of that optiondescription
- (optional) the description for the option
public void addOption(java.lang.String key, int value)
ConversionOption
object with the given parameters.
key
- the key for the new optionvalue
- the integer value of that optiondescription
- (optional) the description for the option
public ConversionOption removeOption(java.lang.String key)
key
- the key for the new option to removepublic boolean hasOption(java.lang.String key)
true
if this properties object contains an option with
the given key.
key
- the key of the option to find.
true
if an option with the given key
exists in
this properties object, false
otherwise.public java.lang.String getValue(java.lang.String key)
key
- the key for the option.
public void setValue(java.lang.String key, java.lang.String value)
key
- the key for the optionvalue
- the new valuepublic boolean getBoolValue(java.lang.String key)
key
- the key for the option.
public void setBoolValue(java.lang.String key, boolean value)
key
- the key for the option.
value
- the new Boolean value.public double getDoubleValue(java.lang.String key)
double.
key
- the key for the option.
public void setDoubleValue(java.lang.String key, double value)
double.
key
- the key for the option.
value
- the new double value.public float getFloatValue(java.lang.String key)
float.
key
- the key for the option.
public void setFloatValue(java.lang.String key, float value)
float.
key
- the key for the option.
value
- the new float value.public int getIntValue(java.lang.String key)
key
- the key for the option.
public void setIntValue(java.lang.String key, int value)
key
- the key for the option.
value
- the new integer value.public int getNumOptions()