001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.0.8
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&nbsp;2
015 * Version&nbsp;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&nbsp;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&nbsp;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&nbsp;2 Version&nbsp;2.  It is
050 * not available in earlier versions of Level&nbsp;2 nor in any version of
051 * Level&nbsp;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 &#8805; 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   * <p>
140 * @throws SBMLConstructorException
141 * Thrown if the given <code>level</code> and <code>version</code> combination are invalid
142 * or if this object is incompatible with the given level and version.
143   <p>
144   * <p>
145 * @note Attempting to add an object to an {@link SBMLDocument} having a different
146 * combination of SBML Level, Version and XML namespaces than the object
147 * itself will result in an error at the time a caller attempts to make the
148 * addition.  A parent object must have compatible Level, Version and XML
149 * namespaces.  (Strictly speaking, a parent may also have more XML
150 * namespaces than a child, but the reverse is not permitted.)  The
151 * restriction is necessary to ensure that an SBML model has a consistent
152 * overall structure.  This requires callers to manage their objects
153 * carefully, but the benefit is increased flexibility in how models can be
154 * created by permitting callers to create objects bottom-up if desired.  In
155 * situations where objects are not yet attached to parents (e.g.,
156 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
157 * libSBML determine such things as whether it is valid to assign a
158 * particular value to an attribute.
159   */ public
160 Constraint(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
161    this(libsbmlJNI.new_Constraint__SWIG_0(level, version), true);
162  }
163
164  
165/**
166   * Creates a new {@link Constraint} using the given {@link SBMLNamespaces} object
167   * <code>sbmlns</code>.
168   <p>
169   * <p>
170 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces
171 * information.  It is used to communicate the SBML Level, Version, and (in
172 * Level&nbsp;3) packages used in addition to SBML Level&nbsp;3 Core.  A
173 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an
174 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object
175 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments.
176   <p>
177   * @param sbmlns an {@link SBMLNamespaces} object.
178   <p>
179   * <p>
180 * @throws SBMLConstructorException
181 * Thrown if the given <code>sbmlns</code> is inconsistent or incompatible
182 * with this object.
183   <p>
184   * <p>
185 * @note Attempting to add an object to an {@link SBMLDocument} having a different
186 * combination of SBML Level, Version and XML namespaces than the object
187 * itself will result in an error at the time a caller attempts to make the
188 * addition.  A parent object must have compatible Level, Version and XML
189 * namespaces.  (Strictly speaking, a parent may also have more XML
190 * namespaces than a child, but the reverse is not permitted.)  The
191 * restriction is necessary to ensure that an SBML model has a consistent
192 * overall structure.  This requires callers to manage their objects
193 * carefully, but the benefit is increased flexibility in how models can be
194 * created by permitting callers to create objects bottom-up if desired.  In
195 * situations where objects are not yet attached to parents (e.g.,
196 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
197 * libSBML determine such things as whether it is valid to assign a
198 * particular value to an attribute.
199   */ public
200 Constraint(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
201    this(libsbmlJNI.new_Constraint__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
202  }
203
204  
205/**
206   * Copy constructor; creates a copy of this {@link Constraint}.
207   <p>
208   * @param orig the object to copy.
209   */ public
210 Constraint(Constraint orig) throws org.sbml.libsbml.SBMLConstructorException {
211    this(libsbmlJNI.new_Constraint__SWIG_2(Constraint.getCPtr(orig), orig), true);
212  }
213
214  
215/**
216   * Creates and returns a deep copy of this {@link Constraint} object.
217   <p>
218   * @return the (deep) copy of this {@link Constraint} object.
219   */ public
220 Constraint cloneObject() {
221    long cPtr = libsbmlJNI.Constraint_cloneObject(swigCPtr, this);
222    return (cPtr == 0) ? null : new Constraint(cPtr, true);
223  }
224
225  
226/**
227   * Get the message, if any, associated with this {@link Constraint}
228   <p>
229   * @return the message for this {@link Constraint}, as an {@link XMLNode}.
230   */ public
231 XMLNode getMessage() {
232    long cPtr = libsbmlJNI.Constraint_getMessage(swigCPtr, this);
233    return (cPtr == 0) ? null : new XMLNode(cPtr, false);
234  }
235
236  
237/**
238   * Get the message string, if any, associated with this {@link Constraint}
239   <p>
240   * @return the message for this {@link Constraint}, as a string.
241   */ public
242 String getMessageString() {
243    return libsbmlJNI.Constraint_getMessageString(swigCPtr, this);
244  }
245
246  
247/**
248   * Get the mathematical expression of this {@link Constraint}
249   <p>
250   * @return the math for this {@link Constraint}, as an {@link ASTNode}.
251   */ public
252 ASTNode getMath() {
253    long cPtr = libsbmlJNI.Constraint_getMath(swigCPtr, this);
254    return (cPtr == 0) ? null : new ASTNode(cPtr, false);
255  }
256
257  
258/**
259   * Predicate returning <code>true</code> if a
260   * message is defined for this {@link Constraint}.
261   <p>
262   * @return <code>true</code> if the message of this {@link Constraint} is set,
263   * <code>false</code> otherwise.
264   */ public
265 boolean isSetMessage() {
266    return libsbmlJNI.Constraint_isSetMessage(swigCPtr, this);
267  }
268
269  
270/**
271   * Predicate returning <code>true</code> if a
272   * mathematical formula is defined for this {@link Constraint}.
273   <p>
274   * @return <code>true</code> if the 'math' subelement for this {@link Constraint} is
275   * set, <code>false</code> otherwise.
276   */ public
277 boolean isSetMath() {
278    return libsbmlJNI.Constraint_isSetMath(swigCPtr, this);
279  }
280
281  
282/**
283   * Sets the message of this {@link Constraint}.
284   <p>
285   * The {@link XMLNode} tree passed in <code>xhtml</code> is copied.
286   <p>
287   * @param xhtml an XML tree containing XHTML content.
288   <p>
289   * <p>
290 * @return integer value indicating success/failure of the
291 * function.   The possible values
292 * returned by this function are:
293   * <ul>
294   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
295   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
296   * </ul>
297   */ public
298 int setMessage(XMLNode xhtml) {
299    return libsbmlJNI.Constraint_setMessage__SWIG_0(swigCPtr, this, XMLNode.getCPtr(xhtml), xhtml);
300  }
301
302  
303/**
304   * Sets the message of this {@link Constraint}.
305   <p>
306   * @param message an XML string that is to be used as the content of the
307   * 'message' subelement of this object
308   <p>
309   * @param addXHTMLMarkup a boolean indicating whether to wrap the contents
310   * of the <code>message</code> argument with XHTML paragraph (<code>&lt;p&gt;</code>)
311   * tags.  This is appropriate when the string in <code>message</code> does not already
312   * containg the appropriate XHTML markup.
313   <p>
314   * <p>
315 * @return integer value indicating success/failure of the
316 * function.   The possible values
317 * returned by this function are:
318   * <ul>
319   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
320   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
321   * </ul>
322   */ public
323 int setMessage(String message, boolean addXHTMLMarkup) {
324    return libsbmlJNI.Constraint_setMessage__SWIG_1(swigCPtr, this, message, addXHTMLMarkup);
325  }
326
327  
328/**
329   * Sets the message of this {@link Constraint}.
330   <p>
331   * @param message an XML string that is to be used as the content of the
332   * 'message' subelement of this object
333   <p>
334   * @param addXHTMLMarkup a boolean indicating whether to wrap the contents
335   * of the <code>message</code> argument with XHTML paragraph (<code>&lt;p&gt;</code>)
336   * tags.  This is appropriate when the string in <code>message</code> does not already
337   * containg the appropriate XHTML markup.
338   <p>
339   * <p>
340 * @return integer value indicating success/failure of the
341 * function.   The possible values
342 * returned by this function are:
343   * <ul>
344   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
345   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
346   * </ul>
347   */ public
348 int setMessage(String message) {
349    return libsbmlJNI.Constraint_setMessage__SWIG_2(swigCPtr, this, message);
350  }
351
352  
353/**
354   * Sets the mathematical expression of this {@link Constraint} to a copy of the
355   * AST given as <code>math</code>.
356   <p>
357   * @param math an {@link ASTNode} expression to be assigned as the 'math'
358   * subelement of this {@link Constraint}
359   <p>
360   * <p>
361 * @return integer value indicating success/failure of the
362 * function.   The possible values
363 * returned by this function are:
364   * <ul>
365   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
366   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
367   * </ul>
368   */ public
369 int setMath(ASTNode math) {
370    return libsbmlJNI.Constraint_setMath(swigCPtr, this, ASTNode.getCPtr(math), math);
371  }
372
373  
374/**
375   * Unsets the 'message' subelement of this {@link Constraint}.
376   <p>
377   * <p>
378 * @return integer value indicating success/failure of the
379 * function.   The possible values
380 * returned by this function are:
381   * <ul>
382   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
383   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
384   * </ul>
385   */ public
386 int unsetMessage() {
387    return libsbmlJNI.Constraint_unsetMessage(swigCPtr, this);
388  }
389
390  
391/**
392   * <p>
393 * Replaces all uses of a given <code>SIdRef</code> type attribute value with another
394 * value.
395 <p>
396 * <p>
397 * In SBML, object identifiers are of a data type called <code>SId</code>.
398 * In SBML Level&nbsp;3, an explicit data type called <code>SIdRef</code> was
399 * introduced for attribute values that refer to <code>SId</code> values; in
400 * previous Levels of SBML, this data type did not exist and attributes were
401 * simply described to as 'referring to an identifier', but the effective
402 * data type was the same as <code>SIdRef</code>in Level&nbsp;3.  These and
403 * other methods of libSBML refer to the type <code>SIdRef</code> for all
404 * Levels of SBML, even if the corresponding SBML specification did not
405 * explicitly name the data type.
406 <p>
407 * This method works by looking at all attributes and (if appropriate)
408 * mathematical formulas in MathML content, comparing the referenced
409 * identifiers to the value of <code>oldid</code>.  If any matches are found, the
410 * matching values are replaced with <code>newid</code>.  The method does <em>not</em>
411 * descend into child elements.
412 <p>
413 * @param oldid the old identifier
414 * @param newid the new identifier
415   */ public
416 void renameSIdRefs(String oldid, String newid) {
417    libsbmlJNI.Constraint_renameSIdRefs(swigCPtr, this, oldid, newid);
418  }
419
420  
421/**
422   * <p>
423 * Replaces all uses of a given <code>UnitSIdRef</code> type attribute value with
424 * another value.
425 <p>
426 * <p>
427 * In SBML, unit definitions have identifiers of type <code>UnitSId</code>.  In
428 * SBML Level&nbsp;3, an explicit data type called <code>UnitSIdRef</code> was
429 * introduced for attribute values that refer to <code>UnitSId</code> values; in
430 * previous Levels of SBML, this data type did not exist and attributes were
431 * simply described to as 'referring to a unit identifier', but the effective
432 * data type was the same as <code>UnitSIdRef</code> in Level&nbsp;3.  These and
433 * other methods of libSBML refer to the type <code>UnitSIdRef</code> for all
434 * Levels of SBML, even if the corresponding SBML specification did not
435 * explicitly name the data type.
436 <p>
437 * This method works by looking at all unit identifier attribute values
438 * (including, if appropriate, inside mathematical formulas), comparing the
439 * referenced unit identifiers to the value of <code>oldid</code>.  If any matches
440 * are found, the matching values are replaced with <code>newid</code>.  The method
441 * does <em>not</em> descend into child elements.
442 <p>
443 * @param oldid the old identifier
444 * @param newid the new identifier
445   */ public
446 void renameUnitSIdRefs(String oldid, String newid) {
447    libsbmlJNI.Constraint_renameUnitSIdRefs(swigCPtr, this, oldid, newid);
448  }
449
450  
451/** * @internal */ public
452 void replaceSIDWithFunction(String id, ASTNode function) {
453    libsbmlJNI.Constraint_replaceSIDWithFunction(swigCPtr, this, id, ASTNode.getCPtr(function), function);
454  }
455
456  
457/**
458   * Returns the libSBML type code for this SBML object.
459   <p>
460   * <p>
461 * LibSBML attaches an identifying code to every kind of SBML object.  These
462 * are integer constants known as <em>SBML type codes</em>.  The names of all
463 * the codes begin with the characters <code>SBML_</code>.
464 * In the Java language interface for libSBML, the
465 * type codes are defined as static integer constants in the interface class
466 * {@link libsbmlConstants}.    Note that different Level&nbsp;3
467 * package plug-ins may use overlapping type codes; to identify the package
468 * to which a given object belongs, call the <code>getPackageName()</code>
469 * method on the object.
470   <p>
471   * @return the SBML type code for this object:
472   * {@link libsbmlConstants#SBML_CONSTRAINT SBML_CONSTRAINT} (default).
473   <p>
474   * <p>
475 * @warning <span class='warning'>The specific integer values of the possible
476 * type codes may be reused by different Level&nbsp;3 package plug-ins.
477 * Thus, to identifiy the correct code, <strong>it is necessary to invoke
478 * both getTypeCode() and getPackageName()</strong>.</span>
479   <p>
480   * @see #getElementName()
481   * @see #getPackageName()
482   */ public
483 int getTypeCode() {
484    return libsbmlJNI.Constraint_getTypeCode(swigCPtr, this);
485  }
486
487  
488/**
489   * Returns the XML element name of this object, which for {@link Constraint}, is
490   * always <code>'constraint'.</code>
491   <p>
492   * @return the name of this element, i.e., <code>'constraint'.</code>
493   */ public
494 String getElementName() {
495    return libsbmlJNI.Constraint_getElementName(swigCPtr, this);
496  }
497
498  
499/**
500   * Predicate returning <code>true</code> if
501   * all the required elements for this {@link Constraint} object
502   * have been set.
503   <p>
504   * @note The required elements for a {@link Constraint} object are:
505   * <ul>
506   * <li> 'math'
507   *
508   * </ul> <p>
509   * @return a boolean value indicating whether all the required
510   * elements for this object have been defined.
511   */ public
512 boolean hasRequiredElements() {
513    return libsbmlJNI.Constraint_hasRequiredElements(swigCPtr, this);
514  }
515
516}