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 *  A list of {@link Constraint} objects.
013 <p>
014 * <p>
015 * The various ListOf___ classes in SBML
016 * are merely containers used for organizing the main components of an SBML
017 * model.  In libSBML's implementation, ListOf___
018 * classes are derived from the
019 * intermediate utility class {@link ListOf}, which
020 * is not defined by the SBML specifications but serves as a useful
021 * programmatic construct.  {@link ListOf} is itself is in turn derived from {@link SBase},
022 * which provides all of the various ListOf___
023 * classes with common features
024 * defined by the SBML specification, such as 'metaid' attributes and
025 * annotations.
026 <p>
027 * The relationship between the lists and the rest of an SBML model is
028 * illustrated by the following (for SBML Level&nbsp;2 Version&nbsp;4):
029 <p>
030 * <figure>
031  <object type="image/svg+xml" data="listof-illustration.svg" class="centered"></object>
032</figure>
033
034 <p>
035 * Readers may wonder about the motivations for using the ListOf___
036 * containers in SBML.  A simpler approach in XML might be to place the
037 * components all directly at the top level of the model definition.  The
038 * choice made in SBML is to group them within XML elements named after
039 * ListOf<em>Classname</em>, in part because it helps organize the
040 * components.  More importantly, the fact that the container classes are
041 * derived from {@link SBase} means that software tools can add information <em>about</em>
042 * the lists themselves into each list container's 'annotation'.
043 <p>
044 * @see ListOfFunctionDefinitions
045 * @see ListOfUnitDefinitions
046 * @see ListOfCompartmentTypes
047 * @see ListOfSpeciesTypes
048 * @see ListOfCompartments
049 * @see ListOfSpecies
050 * @see ListOfParameters
051 * @see ListOfInitialAssignments
052 * @see ListOfRules
053 * @see ListOfConstraints
054 * @see ListOfReactions
055 * @see ListOfEvents
056 */
057
058public class ListOfConstraints extends ListOf {
059   private long swigCPtr;
060
061   protected ListOfConstraints(long cPtr, boolean cMemoryOwn)
062   {
063     super(libsbmlJNI.ListOfConstraints_SWIGUpcast(cPtr), cMemoryOwn);
064     swigCPtr = cPtr;
065   }
066
067   protected static long getCPtr(ListOfConstraints obj)
068   {
069     return (obj == null) ? 0 : obj.swigCPtr;
070   }
071
072   protected static long getCPtrAndDisown (ListOfConstraints obj)
073   {
074     long ptr = 0;
075
076     if (obj != null)
077     {
078       ptr             = obj.swigCPtr;
079       obj.swigCMemOwn = false;
080     }
081
082     return ptr;
083   }
084
085  protected void finalize() {
086    delete();
087  }
088
089  public synchronized void delete() {
090    if (swigCPtr != 0) {
091      if (swigCMemOwn) {
092        swigCMemOwn = false;
093        libsbmlJNI.delete_ListOfConstraints(swigCPtr);
094      }
095      swigCPtr = 0;
096    }
097    super.delete();
098  }
099
100  
101/**
102   * Creates a new {@link ListOfConstraints} object.
103   <p>
104   * The object is constructed such that it is valid for the given SBML
105   * Level and Version combination.
106   <p>
107   * @param level the SBML Level
108   <p>
109   * @param version the Version within the SBML Level
110   <p>
111   * <p>
112 * @throws SBMLConstructorException
113 * Thrown if the given <code>level</code> and <code>version</code> combination are invalid
114 * or if this object is incompatible with the given level and version.
115   <p>
116   * <p>
117 * @note Attempting to add an object to an {@link SBMLDocument} having a different
118 * combination of SBML Level, Version and XML namespaces than the object
119 * itself will result in an error at the time a caller attempts to make the
120 * addition.  A parent object must have compatible Level, Version and XML
121 * namespaces.  (Strictly speaking, a parent may also have more XML
122 * namespaces than a child, but the reverse is not permitted.)  The
123 * restriction is necessary to ensure that an SBML model has a consistent
124 * overall structure.  This requires callers to manage their objects
125 * carefully, but the benefit is increased flexibility in how models can be
126 * created by permitting callers to create objects bottom-up if desired.  In
127 * situations where objects are not yet attached to parents (e.g.,
128 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
129 * libSBML determine such things as whether it is valid to assign a
130 * particular value to an attribute.
131   */ public
132 ListOfConstraints(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
133    this(libsbmlJNI.new_ListOfConstraints__SWIG_0(level, version), true);
134  }
135
136  
137/**
138   * Creates a new {@link ListOfConstraints} object.
139   <p>
140   * The object is constructed such that it is valid for the SBML Level and
141   * Version combination determined by the {@link SBMLNamespaces} object in 
142   * <code>sbmlns</code>.
143   <p>
144   * @param sbmlns an {@link SBMLNamespaces} object that is used to determine the
145   * characteristics of the {@link ListOfConstraints} object to be created.
146   <p>
147   * <p>
148 * @throws SBMLConstructorException
149 * Thrown if the given <code>sbmlns</code> is inconsistent or incompatible
150 * with this object.
151   <p>
152   * <p>
153 * @note Attempting to add an object to an {@link SBMLDocument} having a different
154 * combination of SBML Level, Version and XML namespaces than the object
155 * itself will result in an error at the time a caller attempts to make the
156 * addition.  A parent object must have compatible Level, Version and XML
157 * namespaces.  (Strictly speaking, a parent may also have more XML
158 * namespaces than a child, but the reverse is not permitted.)  The
159 * restriction is necessary to ensure that an SBML model has a consistent
160 * overall structure.  This requires callers to manage their objects
161 * carefully, but the benefit is increased flexibility in how models can be
162 * created by permitting callers to create objects bottom-up if desired.  In
163 * situations where objects are not yet attached to parents (e.g.,
164 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
165 * libSBML determine such things as whether it is valid to assign a
166 * particular value to an attribute.
167   */ public
168 ListOfConstraints(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
169    this(libsbmlJNI.new_ListOfConstraints__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
170  }
171
172  
173/**
174   * Creates and returns a deep copy of this {@link ListOfConstraints} object.
175   <p>
176   * @return the (deep) copy of this {@link ListOfConstraints} object.
177   */ public
178 ListOfConstraints cloneObject() {
179    long cPtr = libsbmlJNI.ListOfConstraints_cloneObject(swigCPtr, this);
180    return (cPtr == 0) ? null : new ListOfConstraints(cPtr, true);
181  }
182
183  
184/**
185   * Returns the libSBML type code for the objects contained in this {@link ListOf}
186   * (i.e., {@link Constraint} objects, if the list is non-empty).
187   <p>
188   * <p>
189 * LibSBML attaches an identifying code to every kind of SBML object.  These
190 * are integer constants known as <em>SBML type codes</em>.  The names of all
191 * the codes begin with the characters <code>SBML_</code>.
192 * In the Java language interface for libSBML, the
193 * type codes are defined as static integer constants in the interface class
194 * {@link libsbmlConstants}.    Note that different Level&nbsp;3
195 * package plug-ins may use overlapping type codes; to identify the package
196 * to which a given object belongs, call the <code>getPackageName()</code>
197 * method on the object.
198   <p>
199   * @return the SBML type code for the objects contained in this {@link ListOf}
200   * instance: {@link libsbmlConstants#SBML_CONSTRAINT SBML_CONSTRAINT} (default).
201   <p>
202   * @see #getElementName()
203   * @see #getPackageName()
204   */ public
205 int getItemTypeCode() {
206    return libsbmlJNI.ListOfConstraints_getItemTypeCode(swigCPtr, this);
207  }
208
209  
210/**
211   * Returns the XML element name of this object.
212   <p>
213   * For {@link ListOfConstraints}, the XML element name is <code>'listOfConstraints'.</code>
214   <p>
215   * @return the name of this element.
216   */ public
217 String getElementName() {
218    return libsbmlJNI.ListOfConstraints_getElementName(swigCPtr, this);
219  }
220
221  
222/**
223   * Get a {@link Constraint} from the {@link ListOfConstraints}.
224   <p>
225   * @param n the index number of the {@link Constraint} to get.
226   <p>
227   * @return the nth {@link Constraint} in this {@link ListOfConstraints}.
228   <p>
229   * @see #size()
230   */ public
231 Constraint get(long n) {
232    long cPtr = libsbmlJNI.ListOfConstraints_get__SWIG_0(swigCPtr, this, n);
233    return (cPtr == 0) ? null : new Constraint(cPtr, false);
234  }
235
236  
237/**
238   * Removes the nth item from this {@link ListOfConstraints} items and returns a
239   * pointer to it.
240   <p>
241   * The caller owns the returned item and is responsible for deleting it.
242   <p>
243   * @param n the index of the item to remove
244   <p>
245   * @see #size()
246   */ public
247 Constraint remove(long n) {
248    long cPtr = libsbmlJNI.ListOfConstraints_remove(swigCPtr, this, n);
249    return (cPtr == 0) ? null : new Constraint(cPtr, true);
250  }
251
252}