1 /* ---------------------------------------------------------------------------- 2 * This file was automatically generated by SWIG (http://www.swig.org). 3 * Version 4.0.2 4 * 5 * Do not make changes to this file unless you know what you are doing--modify 6 * the SWIG interface file instead. 7 * ----------------------------------------------------------------------------- */ 8 9 package org.sbml.libsbml; 10 11 /** 12 * An SBML <em>constraint</em>, for stating validity assumptions. 13 <p> 14 * The {@link Constraint} object class was introduced in SBML Level 2 15 * Version 2 as a mechanism for stating the assumptions under which a 16 * model is designed to operate. The <em>constraints</em> are statements 17 * about permissible values of different quantities in a model. 18 * Constraints are not used to compute dynamical values for simulation or 19 * analysis, but rather, they serve an advisory role for 20 * simulation/analysis tools. 21 <p> 22 * SBML's {@link Constraint} object class has one required attribute, 'id', to 23 * give the parameter a unique identifier by which other parts of an SBML 24 * model definition can refer to it. A {@link Constraint} object can also have an 25 * optional 'name' attribute of type <code>string.</code> Identifiers and names must 26 * be used according to the guidelines described in the SBML specification 27 * (e.g., Section 3.3 in the Level 2 Version 4 specification). 28 <p> 29 * {@link Constraint} has one subelement, 'math', containing a MathML 30 * formula defining the condition of the constraint. This formula will 31 * return a Boolean value of <code>true</code> when the model is a <em>valid</em> 32 * state. The formula can be an arbitrary expression referencing the 33 * variables and other entities in an SBML model. The evaluation of 'math' 34 * and behavior of constraints are described in more detail below. 35 <p> 36 * In SBML Level 2 and SBML Level 3 Version 1, the 'math' 37 * subelement is required, and its formula must be a Boolean value. In 38 * SBML Level 3 Version 2, these restrictions were relaxed: 39 * the 'math' subelement is optional, and numeric values are allowed 40 * in Boolean contexts (a '0' is interpreted as <code>false</code>, and all other 41 * values are interpreted as <code>true</code>). If a {@link Constraint} with no 'math' 42 * is present in a {@link Model}, no restriction on the {@link Model}'s behavior is 43 * implied or enforced. 44 <p> 45 * A {@link Constraint} structure also has an optional subelement called 'message'. 46 * This can contain a message in XHTML format that may be displayed to the 47 * user when the condition of the formula in the 'math' subelement 48 * evaluates to a value of <code>false.</code> Software tools are not required to 49 * display the message, but it is recommended that they do so as a matter 50 * of best practice. The XHTML content within a 'message' subelement must 51 * follow the same restrictions as for the 'notes' element on {@link SBase} 52 * described in in the SBML Level 2 specification; please consult the 53 * <a target='_blank' href='http://sbml.org/Documents/Specifications'>SBML 54 * specification document</a> corresponding to the SBML Level and Version 55 * of your model for more information about the requirements for 'notes' 56 * content. 57 <p> 58 * {@link Constraint} was introduced in SBML Level 2 Version 2. It is 59 * not available in earlier versions of Level 2 nor in any version of 60 * Level 1. 61 <p> 62 * <h2>Semantics of Constraints</h2> 63 <p> 64 * In the context of a simulation, a {@link Constraint} has effect at all times 65 * <em>t ≥ 0</em>. Each {@link Constraint}'s 'math' subelement is first 66 * evaluated after any {@link InitialAssignment} definitions in a model at <em>t = 67 * 0</em> and can conceivably trigger at that point. (In other words, a 68 * simulation could fail a constraint immediately.) 69 <p> 70 * {@link Constraint} structures <em>cannot and should not</em> be used to compute 71 * the dynamical behavior of a model as part of, for example, simulation. 72 * Constraints may be used as input to non-dynamical analysis, for instance 73 * by expressing flux constraints for flux balance analysis. 74 <p> 75 * The results of a simulation of a model containing a constraint are 76 * invalid from any simulation time at and after a point when the function 77 * given by the 'math' subelement returns a value of <code>false.</code> Invalid 78 * simulation results do not make a prediction of the behavior of the 79 * biochemical reaction network represented by the model. The precise 80 * behavior of simulation tools is left undefined with respect to 81 * constraints. If invalid results are detected with respect to a given 82 * constraint, the 'message' subelement may optionally be displayed to the 83 * user. The simulation tool may also halt the simulation or clearly 84 * delimit in output data the simulation time point at which the simulation 85 * results become invalid. 86 <p> 87 * SBML does not impose restrictions on duplicate {@link Constraint} definitions or 88 * the order of evaluation of {@link Constraint} objects in a model. It is 89 * possible for a model to define multiple constraints all with the same 90 * mathematical expression. Since the failure of any constraint indicates 91 * that the model simulation has entered an invalid state, a system is not 92 * required to attempt to detect whether other constraints in the model 93 * have failed once any one constraint has failed. 94 */ 95 96 public class Constraint extends SBase { 97 private long swigCPtr; 98 Constraint(long cPtr, boolean cMemoryOwn)99 protected Constraint(long cPtr, boolean cMemoryOwn) 100 { 101 super(libsbmlJNI.Constraint_SWIGUpcast(cPtr), cMemoryOwn); 102 swigCPtr = cPtr; 103 } 104 getCPtr(Constraint obj)105 protected static long getCPtr(Constraint obj) 106 { 107 return (obj == null) ? 0 : obj.swigCPtr; 108 } 109 getCPtrAndDisown(Constraint obj)110 protected static long getCPtrAndDisown (Constraint obj) 111 { 112 long ptr = 0; 113 114 if (obj != null) 115 { 116 ptr = obj.swigCPtr; 117 obj.swigCMemOwn = false; 118 } 119 120 return ptr; 121 } 122 123 @SuppressWarnings("deprecation") finalize()124 protected void finalize() { 125 delete(); 126 } 127 delete()128 public synchronized void delete() { 129 if (swigCPtr != 0) { 130 if (swigCMemOwn) { 131 swigCMemOwn = false; 132 libsbmlJNI.delete_Constraint(swigCPtr); 133 } 134 swigCPtr = 0; 135 } 136 super.delete(); 137 } 138 139 140 /** 141 * Creates a new {@link Constraint} using the given SBML <code>level</code> and <code>version</code> 142 * values. 143 <p> 144 * @param level a long integer, the SBML Level to assign to this {@link Constraint}. 145 <p> 146 * @param version a long integer, the SBML Version to assign to this 147 * {@link Constraint}. 148 <p> 149 * <p> 150 * @throws SBMLConstructorException 151 * Thrown if the given <code>level</code> and <code>version</code> combination are invalid 152 * or if this object is incompatible with the given level and version. 153 <p> 154 * <p> 155 * @note Attempting to add an object to an {@link SBMLDocument} having a different 156 * combination of SBML Level, Version and XML namespaces than the object 157 * itself will result in an error at the time a caller attempts to make the 158 * addition. A parent object must have compatible Level, Version and XML 159 * namespaces. (Strictly speaking, a parent may also have more XML 160 * namespaces than a child, but the reverse is not permitted.) The 161 * restriction is necessary to ensure that an SBML model has a consistent 162 * overall structure. This requires callers to manage their objects 163 * carefully, but the benefit is increased flexibility in how models can be 164 * created by permitting callers to create objects bottom-up if desired. In 165 * situations where objects are not yet attached to parents (e.g., 166 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 167 * libSBML determine such things as whether it is valid to assign a 168 * particular value to an attribute. 169 */ public Constraint(long level, long version)170 Constraint(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 171 this(libsbmlJNI.new_Constraint__SWIG_0(level, version), true); 172 } 173 174 175 /** 176 * Creates a new {@link Constraint} using the given {@link SBMLNamespaces} object 177 * <code>sbmlns</code>. 178 <p> 179 * <p> 180 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces 181 * information. It is used to communicate the SBML Level, Version, and (in 182 * Level 3) packages used in addition to SBML Level 3 Core. A 183 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an 184 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object 185 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments. 186 <p> 187 * @param sbmlns an {@link SBMLNamespaces} object. 188 <p> 189 * <p> 190 * @throws SBMLConstructorException 191 * Thrown if the given <code>sbmlns</code> is inconsistent or incompatible 192 * with this object. 193 <p> 194 * <p> 195 * @note Attempting to add an object to an {@link SBMLDocument} having a different 196 * combination of SBML Level, Version and XML namespaces than the object 197 * itself will result in an error at the time a caller attempts to make the 198 * addition. A parent object must have compatible Level, Version and XML 199 * namespaces. (Strictly speaking, a parent may also have more XML 200 * namespaces than a child, but the reverse is not permitted.) The 201 * restriction is necessary to ensure that an SBML model has a consistent 202 * overall structure. This requires callers to manage their objects 203 * carefully, but the benefit is increased flexibility in how models can be 204 * created by permitting callers to create objects bottom-up if desired. In 205 * situations where objects are not yet attached to parents (e.g., 206 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 207 * libSBML determine such things as whether it is valid to assign a 208 * particular value to an attribute. 209 */ public Constraint(SBMLNamespaces sbmlns)210 Constraint(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException { 211 this(libsbmlJNI.new_Constraint__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true); 212 } 213 214 215 /** 216 * Copy constructor; creates a copy of this {@link Constraint}. 217 <p> 218 * @param orig the object to copy. 219 */ public Constraint(Constraint orig)220 Constraint(Constraint orig) throws org.sbml.libsbml.SBMLConstructorException { 221 this(libsbmlJNI.new_Constraint__SWIG_2(Constraint.getCPtr(orig), orig), true); 222 } 223 224 225 /** 226 * Creates and returns a deep copy of this {@link Constraint} object. 227 <p> 228 * @return the (deep) copy of this {@link Constraint} object. 229 */ public cloneObject()230 Constraint cloneObject() { 231 long cPtr = libsbmlJNI.Constraint_cloneObject(swigCPtr, this); 232 return (cPtr == 0) ? null : new Constraint(cPtr, true); 233 } 234 235 236 /** 237 * Get the message, if any, associated with this {@link Constraint} 238 <p> 239 * @return the message for this {@link Constraint}, as an {@link XMLNode}. 240 */ public getMessage()241 XMLNode getMessage() { 242 long cPtr = libsbmlJNI.Constraint_getMessage(swigCPtr, this); 243 return (cPtr == 0) ? null : new XMLNode(cPtr, false); 244 } 245 246 247 /** 248 * Get the message string, if any, associated with this {@link Constraint} 249 <p> 250 * @return the message for this {@link Constraint}, as a string. 251 */ public getMessageString()252 String getMessageString() { 253 return libsbmlJNI.Constraint_getMessageString(swigCPtr, this); 254 } 255 256 257 /** 258 * Get the mathematical expression of this {@link Constraint} 259 <p> 260 * @return the math for this {@link Constraint}, as an {@link ASTNode}, or <code>null</code> if the math is not set. 261 */ public getMath()262 ASTNode getMath() { 263 long cPtr = libsbmlJNI.Constraint_getMath(swigCPtr, this); 264 return (cPtr == 0) ? null : new ASTNode(cPtr, false); 265 } 266 267 268 /** 269 * Predicate returning <code>true</code> if a 270 * message is defined for this {@link Constraint}. 271 <p> 272 * @return <code>true</code> if the message of this {@link Constraint} is set, 273 * <code>false</code> otherwise. 274 */ public isSetMessage()275 boolean isSetMessage() { 276 return libsbmlJNI.Constraint_isSetMessage(swigCPtr, this); 277 } 278 279 280 /** 281 * Predicate returning <code>true</code> if a 282 * mathematical formula is defined for this {@link Constraint}. 283 <p> 284 * @return <code>true</code> if the 'math' subelement for this {@link Constraint} is 285 * set, <code>false</code> otherwise. 286 */ public isSetMath()287 boolean isSetMath() { 288 return libsbmlJNI.Constraint_isSetMath(swigCPtr, this); 289 } 290 291 292 /** 293 * Sets the message of this {@link Constraint}. 294 <p> 295 * The {@link XMLNode} tree passed in <code>xhtml</code> is copied. 296 <p> 297 * @param xhtml an XML tree containing XHTML content. 298 <p> 299 * <p> 300 * @return integer value indicating success/failure of the 301 * function. The possible values 302 * returned by this function are: 303 * <ul> 304 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 305 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 306 * </ul> 307 */ public setMessage(XMLNode xhtml)308 int setMessage(XMLNode xhtml) { 309 return libsbmlJNI.Constraint_setMessage__SWIG_0(swigCPtr, this, XMLNode.getCPtr(xhtml), xhtml); 310 } 311 312 313 /** 314 * Sets the message of this {@link Constraint}. 315 <p> 316 * @param message an XML string that is to be used as the content of the 317 * 'message' subelement of this object. 318 <p> 319 * @param addXHTMLMarkup a boolean indicating whether to wrap the contents 320 * of the <code>message</code> argument with XHTML paragraph (<code><p></code>) 321 * tags. This is appropriate when the string in <code>message</code> does not already 322 * containg the appropriate XHTML markup. 323 <p> 324 * <p> 325 * @return integer value indicating success/failure of the 326 * function. The possible values 327 * returned by this function are: 328 * <ul> 329 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 330 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 331 * </ul> 332 */ public setMessage(String message, boolean addXHTMLMarkup)333 int setMessage(String message, boolean addXHTMLMarkup) { 334 return libsbmlJNI.Constraint_setMessage__SWIG_1(swigCPtr, this, message, addXHTMLMarkup); 335 } 336 337 338 /** 339 * Sets the message of this {@link Constraint}. 340 <p> 341 * @param message an XML string that is to be used as the content of the 342 * 'message' subelement of this object. 343 <p> 344 * @param addXHTMLMarkup a boolean indicating whether to wrap the contents 345 * of the <code>message</code> argument with XHTML paragraph (<code><p></code>) 346 * tags. This is appropriate when the string in <code>message</code> does not already 347 * containg the appropriate XHTML markup. 348 <p> 349 * <p> 350 * @return integer value indicating success/failure of the 351 * function. The possible values 352 * returned by this function are: 353 * <ul> 354 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 355 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 356 * </ul> 357 */ public setMessage(String message)358 int setMessage(String message) { 359 return libsbmlJNI.Constraint_setMessage__SWIG_2(swigCPtr, this, message); 360 } 361 362 363 /** 364 * Sets the mathematical expression of this {@link Constraint} to a copy of the 365 * AST given as <code>math</code>. 366 <p> 367 * @param math an {@link ASTNode} expression to be assigned as the 'math' 368 * subelement of this {@link Constraint}. 369 <p> 370 * <p> 371 * @return integer value indicating success/failure of the 372 * function. The possible values 373 * returned by this function are: 374 * <ul> 375 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 376 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 377 * </ul> 378 */ public setMath(ASTNode math)379 int setMath(ASTNode math) { 380 return libsbmlJNI.Constraint_setMath(swigCPtr, this, ASTNode.getCPtr(math), math); 381 } 382 383 384 /** 385 * Unsets the 'message' subelement of this {@link Constraint}. 386 <p> 387 * <p> 388 * @return integer value indicating success/failure of the 389 * function. The possible values 390 * returned by this function are: 391 * <ul> 392 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 393 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 394 * </ul> 395 */ public unsetMessage()396 int unsetMessage() { 397 return libsbmlJNI.Constraint_unsetMessage(swigCPtr, this); 398 } 399 400 401 /** 402 * <p> 403 * Replaces all uses of a given <code>SIdRef</code> type attribute value with another 404 * value. 405 <p> 406 * <p> 407 * In SBML, object identifiers are of a data type called <code>SId</code>. 408 * In SBML Level 3, an explicit data type called <code>SIdRef</code> was 409 * introduced for attribute values that refer to <code>SId</code> values; in 410 * previous Levels of SBML, this data type did not exist and attributes were 411 * simply described to as 'referring to an identifier', but the effective 412 * data type was the same as <code>SIdRef</code> in Level 3. These and 413 * other methods of libSBML refer to the type <code>SIdRef</code> for all 414 * Levels of SBML, even if the corresponding SBML specification did not 415 * explicitly name the data type. 416 <p> 417 * This method works by looking at all attributes and (if appropriate) 418 * mathematical formulas in MathML content, comparing the referenced 419 * identifiers to the value of <code>oldid</code>. If any matches are found, the 420 * matching values are replaced with <code>newid</code>. The method does <em>not</em> 421 * descend into child elements. 422 <p> 423 * @param oldid the old identifier. 424 * @param newid the new identifier. 425 */ public renameSIdRefs(String oldid, String newid)426 void renameSIdRefs(String oldid, String newid) { 427 libsbmlJNI.Constraint_renameSIdRefs(swigCPtr, this, oldid, newid); 428 } 429 430 431 /** 432 * <p> 433 * Replaces all uses of a given <code>UnitSIdRef</code> type attribute value with 434 * another value. 435 <p> 436 * <p> 437 * In SBML, unit definitions have identifiers of type <code>UnitSId</code>. In 438 * SBML Level 3, an explicit data type called <code>UnitSIdRef</code> was 439 * introduced for attribute values that refer to <code>UnitSId</code> values; in 440 * previous Levels of SBML, this data type did not exist and attributes were 441 * simply described to as 'referring to a unit identifier', but the effective 442 * data type was the same as <code>UnitSIdRef</code> in Level 3. These and 443 * other methods of libSBML refer to the type <code>UnitSIdRef</code> for all 444 * Levels of SBML, even if the corresponding SBML specification did not 445 * explicitly name the data type. 446 <p> 447 * This method works by looking at all unit identifier attribute values 448 * (including, if appropriate, inside mathematical formulas), comparing the 449 * referenced unit identifiers to the value of <code>oldid</code>. If any matches 450 * are found, the matching values are replaced with <code>newid</code>. The method 451 * does <em>not</em> descend into child elements. 452 <p> 453 * @param oldid the old identifier. 454 * @param newid the new identifier. 455 */ public renameUnitSIdRefs(String oldid, String newid)456 void renameUnitSIdRefs(String oldid, String newid) { 457 libsbmlJNI.Constraint_renameUnitSIdRefs(swigCPtr, this, oldid, newid); 458 } 459 460 461 /** * @internal */ public replaceSIDWithFunction(String id, ASTNode function)462 void replaceSIDWithFunction(String id, ASTNode function) { 463 libsbmlJNI.Constraint_replaceSIDWithFunction(swigCPtr, this, id, ASTNode.getCPtr(function), function); 464 } 465 466 467 /** 468 * Returns the libSBML type code for this SBML object. 469 <p> 470 * <p> 471 * LibSBML attaches an identifying code to every kind of SBML object. These 472 * are integer constants known as <em>SBML type codes</em>. The names of all 473 * the codes begin with the characters <code>SBML_</code>. 474 * In the Java language interface for libSBML, the 475 * type codes are defined as static integer constants in the interface class 476 * {@link libsbmlConstants}. Note that different Level 3 477 * package plug-ins may use overlapping type codes; to identify the package 478 * to which a given object belongs, call the 479 * <code>{@link SBase#getPackageName()} 480 * </code> 481 * method on the object. 482 <p> 483 * The exception to this is lists: all SBML-style list elements have the type 484 * {@link libsbmlConstants#SBML_LIST_OF SBML_LIST_OF}, regardless of what package they 485 * are from. 486 <p> 487 * @return the SBML type code for this object: 488 * {@link libsbmlConstants#SBML_CONSTRAINT SBML_CONSTRAINT} (default). 489 <p> 490 * <p> 491 * @warning <span class='warning'>The specific integer values of the possible 492 * type codes may be reused by different libSBML plug-ins for SBML Level 3. 493 * packages, To fully identify the correct code, <strong>it is necessary to 494 * invoke both getPackageName() and getTypeCode()</strong> (or 495 * {@link ListOf#getItemTypeCode()}).</span> 496 <p> 497 * @see #getElementName() 498 * @see #getPackageName() 499 */ public getTypeCode()500 int getTypeCode() { 501 return libsbmlJNI.Constraint_getTypeCode(swigCPtr, this); 502 } 503 504 505 /** 506 * Returns the XML element name of this object, which for {@link Constraint}, is 507 * always <code>'constraint'.</code> 508 <p> 509 * @return the name of this element, i.e., <code>'constraint'.</code> 510 */ public getElementName()511 String getElementName() { 512 return libsbmlJNI.Constraint_getElementName(swigCPtr, this); 513 } 514 515 516 /** 517 * Predicate returning <code>true</code> if 518 * all the required elements for this {@link Constraint} object 519 * have been set. 520 <p> 521 * @note The required elements for a {@link Constraint} object are: 522 * <ul> 523 * <li> 'math' (through SBML Level 3 Version 1 only; not 524 * required in Level 3 Version 2+.) 525 * 526 * </ul> <p> 527 * @return a boolean value indicating whether all the required 528 * elements for this object have been defined. 529 */ public hasRequiredElements()530 boolean hasRequiredElements() { 531 return libsbmlJNI.Constraint_hasRequiredElements(swigCPtr, this); 532 } 533 534 } 535