001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 2.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 * Implementation of SBML's Constraint construct. 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 required subelement, 'math', containing a MathML 030 * formula defining the condition of the constraint. This formula must 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 * A {@link Constraint} structure also has an optional subelement called 'message'. 037 * This can contain a message in XHTML format that may be displayed to the 038 * user when the condition of the formula in the 'math' subelement 039 * evaluates to a value of <code>false.</code> Software tools are not required to 040 * display the message, but it is recommended that they do so as a matter 041 * of best practice. The XHTML content within a 'message' subelement must 042 * follow the same restrictions as for the 'notes' element on {@link SBase} 043 * described in in the SBML Level 2 specification; please consult the 044 * <a target='_blank' href='http://sbml.org/Documents/Specifications'>SBML 045 * specification document</a> corresponding to the SBML Level and Version 046 * of your model for more information about the requirements for 'notes' 047 * content. 048 <p> 049 * {@link Constraint} was introduced in SBML Level 2 Version 2. It is 050 * not available in earlier versions of Level 2 nor in any version of 051 * Level 1. 052 <p> 053 * <h2>Semantics of Constraints</h2> 054 <p> 055 * In the context of a simulation, a {@link Constraint} has effect at all times 056 * <em>t ≥ 0</em>. Each {@link Constraint}'s 'math' subelement is first 057 * evaluated after any {@link InitialAssignment} definitions in a model at <em>t = 058 * 0</em> and can conceivably trigger at that point. (In other words, a 059 * simulation could fail a constraint immediately.) 060 <p> 061 * {@link Constraint} structures <em>cannot and should not</em> be used to compute 062 * the dynamical behavior of a model as part of, for example, simulation. 063 * Constraints may be used as input to non-dynamical analysis, for instance 064 * by expressing flux constraints for flux balance analysis. 065 <p> 066 * The results of a simulation of a model containing a constraint are 067 * invalid from any simulation time at and after a point when the function 068 * given by the 'math' subelement returns a value of <code>false.</code> Invalid 069 * simulation results do not make a prediction of the behavior of the 070 * biochemical reaction network represented by the model. The precise 071 * behavior of simulation tools is left undefined with respect to 072 * constraints. If invalid results are detected with respect to a given 073 * constraint, the 'message' subelement may optionally be displayed to the 074 * user. The simulation tool may also halt the simulation or clearly 075 * delimit in output data the simulation time point at which the simulation 076 * results become invalid. 077 <p> 078 * SBML does not impose restrictions on duplicate {@link Constraint} definitions or 079 * the order of evaluation of {@link Constraint} objects in a model. It is 080 * possible for a model to define multiple constraints all with the same 081 * mathematical expression. Since the failure of any constraint indicates 082 * that the model simulation has entered an invalid state, a system is not 083 * required to attempt to detect whether other constraints in the model 084 * have failed once any one constraint has failed. 085 */ 086 087public class Constraint extends SBase { 088 private long swigCPtr; 089 090 protected Constraint(long cPtr, boolean cMemoryOwn) 091 { 092 super(libsbmlJNI.Constraint_SWIGUpcast(cPtr), cMemoryOwn); 093 swigCPtr = cPtr; 094 } 095 096 protected static long getCPtr(Constraint obj) 097 { 098 return (obj == null) ? 0 : obj.swigCPtr; 099 } 100 101 protected static long getCPtrAndDisown (Constraint obj) 102 { 103 long ptr = 0; 104 105 if (obj != null) 106 { 107 ptr = obj.swigCPtr; 108 obj.swigCMemOwn = false; 109 } 110 111 return ptr; 112 } 113 114 protected void finalize() { 115 delete(); 116 } 117 118 public synchronized void delete() { 119 if (swigCPtr != 0) { 120 if (swigCMemOwn) { 121 swigCMemOwn = false; 122 libsbmlJNI.delete_Constraint(swigCPtr); 123 } 124 swigCPtr = 0; 125 } 126 super.delete(); 127 } 128 129 130/** 131 * Creates a new {@link Constraint} using the given SBML <code>level</code> and <code>version</code> 132 * values. 133 <p> 134 * @param level a long integer, the SBML Level to assign to this {@link Constraint} 135 <p> 136 * @param version a long integer, the SBML Version to assign to this 137 * {@link Constraint} 138 <p> 139 * @throws SBMLConstructorException 140 * Thrown if the given <code>level</code> and <code>version</code> combination, or this kind 141 * of SBML object, are either invalid or mismatched with respect to the 142 * parent {@link SBMLDocument} object. 143 <p> 144 * <p> 145 * @note Upon the addition of a {@link Constraint} object to an {@link SBMLDocument} 146 * (e.g., using {@link Model#addConstraint(Constraint c)}), the 147 * SBML Level, SBML Version and XML namespace of the document 148 * <em>override</em> the values used when creating the {@link Constraint} object via this 149 * constructor. This is necessary to ensure that an SBML document is a 150 * consistent structure. Nevertheless, the ability to supply the values 151 * at the time of creation of a {@link Constraint} is an important aid to 152 * producing valid SBML. Knowledge of the intented SBML Level and 153 * Version determine whether it is valid to assign a particular value to 154 * an attribute, or whether it is valid to add an object to an existing 155 * {@link SBMLDocument}. 156 */ public 157 Constraint(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 158 this(libsbmlJNI.new_Constraint__SWIG_0(level, version), true); 159 } 160 161 162/** 163 * Creates a new {@link Constraint} using the given {@link SBMLNamespaces} object 164 * <code>sbmlns</code>. 165 <p> 166 * <p> 167 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces 168 * information. It is used to communicate the SBML Level, Version, and (in 169 * Level 3) packages used in addition to SBML Level 3 Core. A 170 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an 171 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object 172 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments. 173 <p> 174 * @param sbmlns an {@link SBMLNamespaces} object. 175 <p> 176 * @throws SBMLConstructorException 177 * Thrown if the given <code>level</code> and <code>version</code> combination, or this kind 178 * of SBML object, are either invalid or mismatched with respect to the 179 * parent {@link SBMLDocument} object. 180 <p> 181 * <p> 182 * @note Upon the addition of a {@link Constraint} object to an {@link SBMLDocument} 183 * (e.g., using {@link Model#addConstraint(Constraint c)}), the 184 * SBML Level, SBML Version and XML namespace of the document 185 * <em>override</em> the values used when creating the {@link Constraint} object via this 186 * constructor. This is necessary to ensure that an SBML document is a 187 * consistent structure. Nevertheless, the ability to supply the values 188 * at the time of creation of a {@link Constraint} is an important aid to 189 * producing valid SBML. Knowledge of the intented SBML Level and 190 * Version determine whether it is valid to assign a particular value to 191 * an attribute, or whether it is valid to add an object to an existing 192 * {@link SBMLDocument}. 193 */ public 194 Constraint(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException { 195 this(libsbmlJNI.new_Constraint__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true); 196 } 197 198 199/** 200 * Copy constructor; creates a copy of this {@link Constraint}. 201 <p> 202 * @param orig the object to copy. 203 <p> 204 * @throws SBMLConstructorException 205 * Thrown if the argument <code>orig</code> is <code>null.</code> 206 */ public 207 Constraint(Constraint orig) throws org.sbml.libsbml.SBMLConstructorException { 208 this(libsbmlJNI.new_Constraint__SWIG_2(Constraint.getCPtr(orig), orig), true); 209 } 210 211 212/** 213 * Creates and returns a deep copy of this {@link Constraint}. 214 <p> 215 * @return a (deep) copy of this {@link Constraint}. 216 */ public 217 Constraint cloneObject() { 218 long cPtr = libsbmlJNI.Constraint_cloneObject(swigCPtr, this); 219 return (cPtr == 0) ? null : new Constraint(cPtr, true); 220 } 221 222 223/** 224 * Get the message, if any, associated with this {@link Constraint} 225 <p> 226 * @return the message for this {@link Constraint}, as an {@link XMLNode}. 227 */ public 228 XMLNode getMessage() { 229 long cPtr = libsbmlJNI.Constraint_getMessage(swigCPtr, this); 230 return (cPtr == 0) ? null : new XMLNode(cPtr, false); 231 } 232 233 234/** 235 * Get the message string, if any, associated with this {@link Constraint} 236 <p> 237 * @return the message for this {@link Constraint}, as a string. 238 */ public 239 String getMessageString() { 240 return libsbmlJNI.Constraint_getMessageString(swigCPtr, this); 241 } 242 243 244/** 245 * Get the mathematical expression of this {@link Constraint} 246 <p> 247 * @return the math for this {@link Constraint}, as an {@link ASTNode}. 248 */ public 249 ASTNode getMath() { 250 long cPtr = libsbmlJNI.Constraint_getMath(swigCPtr, this); 251 return (cPtr == 0) ? null : new ASTNode(cPtr, false); 252 } 253 254 255/** 256 * Predicate returning <code>true</code> if a 257 * message is defined for this {@link Constraint}. 258 <p> 259 * @return <code>true</code> if the message of this {@link Constraint} is set, 260 * <code>false</code> otherwise. 261 */ public 262 boolean isSetMessage() { 263 return libsbmlJNI.Constraint_isSetMessage(swigCPtr, this); 264 } 265 266 267/** 268 * Predicate returning <code>true</code> if a 269 * mathematical formula is defined for this {@link Constraint}. 270 <p> 271 * @return <code>true</code> if the 'math' subelement for this {@link Constraint} is 272 * set, <code>false</code> otherwise. 273 */ public 274 boolean isSetMath() { 275 return libsbmlJNI.Constraint_isSetMath(swigCPtr, this); 276 } 277 278 279/** 280 * Sets the message of this {@link Constraint}. 281 <p> 282 * The {@link XMLNode} tree passed in <code>xhtml</code> is copied. 283 <p> 284 * @param xhtml an XML tree containing XHTML content. 285 <p> 286 * @return integer value indicating success/failure of the 287 * function. The possible values 288 * returned by this function are: 289 * <ul> 290 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 291 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT } 292 * </ul> 293 */ public 294 int setMessage(XMLNode xhtml) { 295 return libsbmlJNI.Constraint_setMessage(swigCPtr, this, XMLNode.getCPtr(xhtml), xhtml); 296 } 297 298 299/** 300 * Sets the mathematical expression of this {@link Constraint} to a copy of the 301 * AST given as <code>math</code>. 302 <p> 303 * @param math an {@link ASTNode} expression to be assigned as the 'math' 304 * subelement of this {@link Constraint} 305 <p> 306 * @return integer value indicating success/failure of the 307 * function. The possible values 308 * returned by this function are: 309 * <ul> 310 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 311 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT } 312 * </ul> 313 */ public 314 int setMath(ASTNode math) { 315 return libsbmlJNI.Constraint_setMath(swigCPtr, this, ASTNode.getCPtr(math), math); 316 } 317 318 319/** 320 * Unsets the 'message' subelement of this {@link Constraint}. 321 <p> 322 * @return integer value indicating success/failure of the 323 * function. The possible values 324 * returned by this function are: 325 * <ul> 326 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 327 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 328 * </ul> 329 */ public 330 int unsetMessage() { 331 return libsbmlJNI.Constraint_unsetMessage(swigCPtr, this); 332 } 333 334 335/** 336 * Renames all the <code>SIdRef</code> attributes on this element, including any 337 * found in MathML. 338 <p> 339 * <p> 340 * In SBML, object identifiers are of a data type called <code>SId</code>. 341 * In SBML Level 3, an explicit data type called <code>SIdRef</code> was 342 * introduced for attribute values that refer to <code>SId</code> values; in 343 * previous Levels of SBML, this data type did not exist and attributes were 344 * simply described to as 'referring to an identifier', but the effective 345 * data type was the same as <code>SIdRef</code>in Level 3. These and 346 * other methods of libSBML refer to the type <code>SIdRef</code> for all 347 * Levels of SBML, even if the corresponding SBML specification did not 348 * explicitly name the data type. 349 <p> 350 * This method works by looking at all attributes and (if appropriate) 351 * mathematical formulas, comparing the identifiers to the value of 352 * <code>oldid</code>. If any matches are found, the matching identifiers are replaced 353 * with <code>newid</code>. The method does <em>not</em> descend into child elements. 354 <p> 355 * @param oldid the old identifier 356 * @param newid the new identifier 357 */ public 358 void renameSIdRefs(String oldid, String newid) { 359 libsbmlJNI.Constraint_renameSIdRefs(swigCPtr, this, oldid, newid); 360 } 361 362 363/** 364 * Renames all the <code>UnitSIdRef</code> attributes on this element. 365 <p> 366 * <p> 367 * In SBML, unit definitions have identifiers of type <code>UnitSId</code>. In 368 * SBML Level 3, an explicit data type called <code>UnitSIdRef</code> was 369 * introduced for attribute values that refer to <code>UnitSId</code> values; in 370 * previous Levels of SBML, this data type did not exist and attributes were 371 * simply described to as 'referring to a unit identifier', but the effective 372 * data type was the same as <code>UnitSIdRef</code> in Level 3. These and 373 * other methods of libSBML refer to the type <code>UnitSIdRef</code> for all 374 * Levels of SBML, even if the corresponding SBML specification did not 375 * explicitly name the data type. 376 <p> 377 * This method works by looking at all unit identifier attribute values 378 * (including, if appropriate, inside mathematical formulas), comparing the 379 * unit identifiers to the value of <code>oldid</code>. If any matches are found, 380 * the matching identifiers are replaced with <code>newid</code>. The method does 381 * <em>not</em> descend into child elements. 382 <p> 383 * @param oldid the old identifier 384 * @param newid the new identifier 385 */ public 386 void renameUnitSIdRefs(String oldid, String newid) { 387 libsbmlJNI.Constraint_renameUnitSIdRefs(swigCPtr, this, oldid, newid); 388 } 389 390 391/** 392 * Replace all nodes with the name 'id' from the child 'math' object with the provided function. 393 <p> 394 * @internal 395 */ public 396 void replaceSIDWithFunction(String id, ASTNode function) { 397 libsbmlJNI.Constraint_replaceSIDWithFunction(swigCPtr, this, id, ASTNode.getCPtr(function), function); 398 } 399 400 401/** 402 * Returns the libSBML type code for this SBML object. 403 <p> 404 * <p> 405 * LibSBML attaches an identifying code to every kind of SBML object. These 406 * are integer constants known as <em>SBML type codes</em>. The names of all 407 * the codes begin with the characters “<code>SBML_</code>”. 408 * In the Java language interface for libSBML, the 409 * type codes are defined as static integer constants in the interface class 410 * {@link libsbmlConstants}. Note that different Level 3 411 * package plug-ins may use overlapping type codes; to identify the package 412 * to which a given object belongs, call the <code>getPackageName()</code> 413 * method on the object. 414 <p> 415 * @return the SBML type code for this object: 416 * {@link libsbmlConstants#SBML_CONSTRAINT SBML_CONSTRAINT} (default). 417 <p> 418 * <p> 419 * @warning <span class='warning'>The specific integer values of the possible 420 * type codes may be reused by different Level 3 package plug-ins. 421 * Thus, to identifiy the correct code, <strong>it is necessary to invoke 422 * both getTypeCode() and getPackageName()</strong>.</span> 423 <p> 424 * @see #getElementName() 425 * @see #getPackageName() 426 */ public 427 int getTypeCode() { 428 return libsbmlJNI.Constraint_getTypeCode(swigCPtr, this); 429 } 430 431 432/** 433 * Returns the XML element name of this object, which for {@link Constraint}, is 434 * always <code>'constraint'.</code> 435 <p> 436 * @return the name of this element, i.e., <code>'constraint'.</code> 437 */ public 438 String getElementName() { 439 return libsbmlJNI.Constraint_getElementName(swigCPtr, this); 440 } 441 442 443/** 444 * Predicate returning <code>true</code> if 445 * all the required elements for this {@link Constraint} object 446 * have been set. 447 <p> 448 * @note The required elements for a {@link Constraint} object are: 449 * <ul> 450 * <li> 'math' 451 * 452 * </ul> <p> 453 * @return a boolean value indicating whether all the required 454 * elements for this object have been defined. 455 */ public 456 boolean hasRequiredElements() { 457 return libsbmlJNI.Constraint_hasRequiredElements(swigCPtr, this); 458 } 459 460}