001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.10 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package org.sbml.libsbml; 010 011/** 012 * <span class="pkg-marker pkg-color-fbc"><a href="group__fbc.html">fbc</a></span> 013 Convert “fbc” Version 2 models to Version 1 014 <p> 015 * <p style='color: #777; font-style: italic'> 016This class of objects is defined by libSBML only and has no direct 017equivalent in terms of SBML components. It is a class used in 018the implementation of extra functionality provided by libSBML. 019</p> 020 021 <p> 022 * This converter takes a model in “fbc” Version 2 format 023 * and converts it to “fbc” Version 1 format. 024 <p> 025 * {@link FbcV2ToV1Converter} is enabled by creating a {@link ConversionProperties} object 026 * with the option <code>'convert fbc v2 to fbc v1'</code> (literally that 027 * full string, including the spaces), and passing this properties object to 028 * {@link SBMLDocument#convert(ConversionProperties)}. The converter 029 * offers no options. Information present in v2 that cannot be encoded in 030 * v1 is lost. 031 <p> 032 * <p> 033 * <h2>General information about the use of SBML converters</h2> 034 <p> 035 * The use of all the converters follows a similar approach. First, one 036 * creates a {@link ConversionProperties} object and calls 037 * {@link ConversionProperties#addOption(ConversionOption)} 038 * on this object with one argument: a text string that identifies the desired 039 * converter. (The text string is specific to each converter; consult the 040 * documentation for a given converter to find out how it should be enabled.) 041 <p> 042 * Next, for some converters, the caller can optionally set some 043 * converter-specific properties using additional calls to 044 * {@link ConversionProperties#addOption(ConversionOption)}. 045 * Many converters provide the ability to 046 * configure their behavior to some extent; this is realized through the use 047 * of properties that offer different options. The default property values 048 * for each converter can be interrogated using the method 049 * {@link SBMLConverter#getDefaultProperties()} on the converter class in question . 050 <p> 051 * Finally, the caller should invoke the method 052 * {@link SBMLDocument#convert(ConversionProperties)} 053 * with the {@link ConversionProperties} object as an argument. 054 <p> 055 * <h3>Example of invoking an SBML converter</h3> 056 <p> 057 * The following code fragment illustrates an example using 058 * {@link SBMLReactionConverter}, which is invoked using the option string 059 * <code>'replaceReactions':</code> 060 <p> 061<pre class='fragment'> 062{@link ConversionProperties} props = new {@link ConversionProperties}(); 063if (props != null) { 064 props.addOption('replaceReactions'); 065} else { 066 // Deal with error. 067} 068</pre> 069<p> 070 * In the case of {@link SBMLReactionConverter}, there are no options to affect 071 * its behavior, so the next step is simply to invoke the converter on 072 * an {@link SBMLDocument} object. Continuing the example code: 073 <p> 074<pre class='fragment'> 075 // Assume that the variable 'document' has been set to an {@link SBMLDocument} object. 076 status = document.convert(config); 077 if (status != libsbml.LIBSBML_OPERATION_SUCCESS) 078 { 079 // Handle error somehow. 080 System.out.println('Error: conversion failed due to the following:'); 081 document.printErrors(); 082 } 083</pre> 084<p> 085 * Here is an example of using a converter that offers an option. The 086 * following code invokes {@link SBMLStripPackageConverter} to remove the 087 * SBML Level 3 <em>Layout</em> package from a model. It sets the name 088 * of the package to be removed by adding a value for the option named 089 * <code>'package'</code> defined by that converter: 090 <p> 091<pre class='fragment'> 092{@link ConversionProperties} config = new {@link ConversionProperties}(); 093if (config != None) { 094 config.addOption('stripPackage'); 095 config.addOption('package', 'layout'); 096 status = document.convert(config); 097 if (status != LIBSBML_OPERATION_SUCCESS) { 098 // Handle error somehow. 099 System.out.println('Error: unable to strip the {@link Layout} package'); 100 document.printErrors(); 101 } 102} else { 103 // Handle error somehow. 104 System.out.println('Error: unable to create {@link ConversionProperties} object'); 105} 106</pre> 107<p> 108 * <h3>Available SBML converters in libSBML</h3> 109 <p> 110 * LibSBML provides a number of built-in converters; by convention, their 111 * names end in <em>Converter</em>. The following are the built-in converters 112 * provided by libSBML 5.15.2 113: 114 <p> 115 * <p> 116 * <ul> 117 * <li> ArraysFlatteningConverter 118 * <li> {@link CobraToFbcConverter} 119 * <li> {@link CompFlatteningConverter} 120 * <li> {@link FbcToCobraConverter} 121 * <li> {@link FbcV1ToV2Converter} 122 * <li> {@link FbcV2ToV1Converter} 123 * <li> {@link SBMLFunctionDefinitionConverter} 124 * <li> {@link SBMLIdConverter} 125 * <li> {@link SBMLInferUnitsConverter} 126 * <li> {@link SBMLInitialAssignmentConverter} 127 * <li> {@link SBMLLevel1Version1Converter} 128 * <li> {@link SBMLLevelVersionConverter} 129 * <li> {@link SBMLLocalParameterConverter} 130 * <li> SBMLRateOfConverter 131 * <li> {@link SBMLReactionConverter} 132 * <li> {@link SBMLRuleConverter} 133 * <li> {@link SBMLStripPackageConverter} 134 * <li> {@link SBMLUnitsConverter} 135 * 136 * </ul> 137 */ 138 139public class FbcV2ToV1Converter extends SBMLConverter { 140 private long swigCPtr; 141 142 protected FbcV2ToV1Converter(long cPtr, boolean cMemoryOwn) 143 { 144 super(libsbmlJNI.FbcV2ToV1Converter_SWIGUpcast(cPtr), cMemoryOwn); 145 swigCPtr = cPtr; 146 } 147 148 protected static long getCPtr(FbcV2ToV1Converter obj) 149 { 150 return (obj == null) ? 0 : obj.swigCPtr; 151 } 152 153 protected static long getCPtrAndDisown (FbcV2ToV1Converter obj) 154 { 155 long ptr = 0; 156 157 if (obj != null) 158 { 159 ptr = obj.swigCPtr; 160 obj.swigCMemOwn = false; 161 } 162 163 return ptr; 164 } 165 166 protected void finalize() { 167 delete(); 168 } 169 170 public synchronized void delete() { 171 if (swigCPtr != 0) { 172 if (swigCMemOwn) { 173 swigCMemOwn = false; 174 libsbmlJNI.delete_FbcV2ToV1Converter(swigCPtr); 175 } 176 swigCPtr = 0; 177 } 178 super.delete(); 179 } 180 181 182/** * @internal */ public 183 static void init() { 184 libsbmlJNI.FbcV2ToV1Converter_init(); 185 } 186 187 188/** 189 * Creates a new {@link FbcV2ToV1Converter} object. 190 */ public 191 FbcV2ToV1Converter() { 192 this(libsbmlJNI.new_FbcV2ToV1Converter__SWIG_0(), true); 193 } 194 195 196/** 197 * Copy constructor; creates a copy of an {@link FbcV2ToV1Converter} 198 * object. 199 <p> 200 * @param orig the {@link FbcV2ToV1Converter} object to copy. 201 */ public 202 FbcV2ToV1Converter(FbcV2ToV1Converter orig) { 203 this(libsbmlJNI.new_FbcV2ToV1Converter__SWIG_1(FbcV2ToV1Converter.getCPtr(orig), orig), true); 204 } 205 206 207/** 208 * Creates and returns a deep copy of this {@link FbcV2ToV1Converter} object. 209 <p> 210 * @return a (deep) copy of this {@link FbcV2ToV1Converter}. 211 */ public 212 SBMLConverter cloneObject() { 213 long cPtr = libsbmlJNI.FbcV2ToV1Converter_cloneObject(swigCPtr, this); 214 return (cPtr == 0) ? null : new FbcV2ToV1Converter(cPtr, true); 215 } 216 217 218/** 219 * Returns <code>true</code> if this converter object's properties match the given 220 * properties. 221 <p> 222 * A typical use of this method involves creating a {@link ConversionProperties} 223 * object, setting the options desired, and then calling this method on 224 * an {@link FbcV2ToV1Converter} object to find out if the object's 225 * property values match the given ones. This method is also used by 226 * {@link SBMLConverterRegistry#getConverterFor(ConversionProperties)} 227 * to search across all registered converters for one matching particular 228 * properties. 229 <p> 230 * @param props the properties to match. 231 <p> 232 * @return <code>true</code> if this converter's properties match, <code>false</code> 233 * otherwise. 234 */ public 235 boolean matchesProperties(ConversionProperties props) { 236 return libsbmlJNI.FbcV2ToV1Converter_matchesProperties(swigCPtr, this, ConversionProperties.getCPtr(props), props); 237 } 238 239 240/** 241 * Perform the conversion. 242 <p> 243 * This method causes the converter to do the actual conversion work, 244 * that is, to convert the {@link SBMLDocument} object set by 245 * setDocument(SBMLDocument) and 246 * with the configuration options set by 247 * setProperties(ConversionProperties). 248 <p> 249 * <p> 250 * @return integer value indicating success/failure of the 251 * function. The possible values 252 * returned by this function are: 253 * <ul> 254 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 255 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 256 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 257 * </ul> 258 */ public 259 int convert() { 260 return libsbmlJNI.FbcV2ToV1Converter_convert(swigCPtr, this); 261 } 262 263 264/** 265 * Returns the default properties of this converter. 266 <p> 267 * A given converter exposes one or more properties that can be adjusted 268 * in order to influence the behavior of the converter. This method 269 * returns the <em>default</em> property settings for this converter. It is 270 * meant to be called in order to discover all the settings for the 271 * converter object. 272 <p> 273 * @return the {@link ConversionProperties} object describing the default properties 274 * for this converter. 275 */ public 276 ConversionProperties getDefaultProperties() { 277 return new ConversionProperties(libsbmlJNI.FbcV2ToV1Converter_getDefaultProperties(swigCPtr, this), true); 278 } 279 280}