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