001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 2.0.11
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 * 
013 * Implementation of SBML's ListOfRules construct.
014 * <p>
015 * The various ListOf___ classes in SBML are merely containers used for
016 * organizing the main components of an SBML model.  All are derived from
017 * the abstract class {@link SBase}, and inherit the various attributes and
018 * subelements of {@link SBase}, such as 'metaid' as and 'annotation'.  The
019 * ListOf___ classes do not add any attributes of their own.
020 * <p>
021 * The relationship between the lists and the rest of an SBML model is
022 * illustrated by the following (for SBML Level&nbsp;3 and later versions
023 * of SBML Level&nbsp;2 as well):
024 * <p>
025 * <center><img src='listof-illustration.jpg'></center><br>
026 * 
027 * <p>
028 * Readers may wonder about the motivations for using the ListOf___
029 * containers.  A simpler approach in XML might be to place the components
030 * all directly at the top level of the model definition.  The choice made
031 * in SBML is to group them within XML elements named after
032 * {@link ListOf}<em>Classname</em>, in part because it helps organize the
033 * components.  More importantly, the fact that the container classes are
034 * derived from {@link SBase} means that software tools can add information <em>about</em>
035 * the lists themselves into each list container's 'annotation'.
036 * <p>
037 * @see ListOfFunctionDefinitions
038 * @see ListOfUnitDefinitions
039 * @see ListOfCompartmentTypes
040 * @see ListOfSpeciesTypes
041 * @see ListOfCompartments
042 * @see ListOfSpecies
043 * @see ListOfParameters
044 * @see ListOfInitialAssignments
045 * @see ListOfRules
046 * @see ListOfConstraints
047 * @see ListOfReactions
048 * @see ListOfEvents
049 */
050
051public class ListOfRules extends ListOf {
052   private long swigCPtr;
053
054   protected ListOfRules(long cPtr, boolean cMemoryOwn)
055   {
056     super(libsbmlJNI.ListOfRules_SWIGUpcast(cPtr), cMemoryOwn);
057     swigCPtr = cPtr;
058   }
059
060   protected static long getCPtr(ListOfRules obj)
061   {
062     return (obj == null) ? 0 : obj.swigCPtr;
063   }
064
065   protected static long getCPtrAndDisown (ListOfRules obj)
066   {
067     long ptr = 0;
068
069     if (obj != null)
070     {
071       ptr             = obj.swigCPtr;
072       obj.swigCMemOwn = false;
073     }
074
075     return ptr;
076   }
077
078  protected void finalize() {
079    delete();
080  }
081
082  public synchronized void delete() {
083    if (swigCPtr != 0) {
084      if (swigCMemOwn) {
085        swigCMemOwn = false;
086        libsbmlJNI.delete_ListOfRules(swigCPtr);
087      }
088      swigCPtr = 0;
089    }
090    super.delete();
091  }
092
093  
094/**
095   * Creates a new {@link ListOfRules} object.
096   * <p>
097   * The object is constructed such that it is valid for the given SBML
098   * Level and Version combination.
099   * <p>
100   * @param level the SBML Level
101   * <p>
102   * @param version the Version within the SBML Level
103   */ public
104 ListOfRules(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
105    this(libsbmlJNI.new_ListOfRules__SWIG_0(level, version), true);
106  }
107
108  
109/**
110   * Creates a new {@link ListOfRules} object.
111   * <p>
112   * The object is constructed such that it is valid for the SBML Level and
113   * Version combination determined by the {@link SBMLNamespaces} object in 
114   * <code>sbmlns</code>.
115   * <p>
116   * @param sbmlns an {@link SBMLNamespaces} object that is used to determine the
117   * characteristics of the {@link ListOfRules} object to be created.
118   */ public
119 ListOfRules(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
120    this(libsbmlJNI.new_ListOfRules__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
121  }
122
123  
124/**
125   * Creates and returns a deep copy of this {@link ListOfRules} instance.
126   * <p>
127   * @return a (deep) copy of this {@link ListOfRules}.
128   */ public
129 ListOfRules cloneObject() {
130    long cPtr = libsbmlJNI.ListOfRules_cloneObject(swigCPtr, this);
131    return (cPtr == 0) ? null : new ListOfRules(cPtr, true);
132  }
133
134  
135/**
136   * Returns the libSBML type code for this SBML object.
137   * <p>
138   * LibSBML attaches an identifying code to every
139   * kind of SBML object.  These are known as <em>SBML type codes</em>.  In
140   * other languages, the set of type codes is stored in an enumeration; in
141   * the Java language interface for libSBML, the type codes are defined as
142   * static integer constants in the interface class {@link
143   * libsbmlConstants}.  The names of the type codes all begin with the
144   * characters <code>SBML_.</code> 
145   * <p>
146   * @return the SBML type code for this object, or {@link  libsbmlConstants#SBML_UNKNOWN SBML_UNKNOWN} (default).
147   * <p>
148   * @see #getElementName()
149   */ public
150 int getTypeCode() {
151    return libsbmlJNI.ListOfRules_getTypeCode(swigCPtr, this);
152  }
153
154  
155/**
156   * Returns the libSBML type code for the objects contained in this {@link ListOf}
157   * (i.e., {@link Rule} objects, if the list is non-empty).
158   * <p>
159   * LibSBML attaches an identifying code to every
160   * kind of SBML object.  These are known as <em>SBML type codes</em>.  In
161   * other languages, the set of type codes is stored in an enumeration; in
162   * the Java language interface for libSBML, the type codes are defined as
163   * static integer constants in the interface class {@link
164   * libsbmlConstants}.  The names of the type codes all begin with the
165   * characters <code>SBML_.</code> 
166   * <p>
167   * @return the SBML type code for the objects contained in this {@link ListOf}
168   * instance, or {@link  libsbmlConstants#SBML_UNKNOWN SBML_UNKNOWN} (default).
169   * <p>
170   * @see #getElementName()
171   */ public
172 int getItemTypeCode() {
173    return libsbmlJNI.ListOfRules_getItemTypeCode(swigCPtr, this);
174  }
175
176  
177/**
178   * Returns the XML element name of this object.
179   * <p>
180   * For {@link ListOfRules}, the XML element name is <code>'listOfRules'.</code>
181   * <p>
182   * @return the name of this element, i.e., <code>'listOfRules'.</code>
183   */ public
184 String getElementName() {
185    return libsbmlJNI.ListOfRules_getElementName(swigCPtr, this);
186  }
187
188  
189/**
190   * Get a {@link Rule} from the {@link ListOfRules}.
191   * <p>
192   * @param n the index number of the {@link Rule} to get.
193   * <p>
194   * @return the nth {@link Rule} in this {@link ListOfRules}.
195   * <p>
196   * @see #size()
197   */ public
198 Rule get(long n) {
199  return (Rule) libsbml.DowncastSBase(libsbmlJNI.ListOfRules_get__SWIG_0(swigCPtr, this, n), false);
200}
201
202  
203/**
204   * Get a {@link Rule} from the {@link ListOfRules}
205   * based on its identifier.
206   * <p>
207   * @param sid a string representing the identifier 
208   * of the {@link Rule} to get.
209   * <p>
210   * @return {@link Rule} in this {@link ListOfRules}
211   * with the given <code>id</code> or <code>null</code> if no such
212   * {@link Rule} exists.
213   * <p>
214   * @see #get(long n)
215   * @see #size()
216   */ public
217 Rule get(String sid) {
218  return (Rule) libsbml.DowncastSBase(libsbmlJNI.ListOfRules_get__SWIG_2(swigCPtr, this, sid), false);
219}
220
221  
222/**
223   * Removes the nth item from this {@link ListOfRules} items and returns a pointer to
224   * it.
225   * <p>
226   * The caller owns the returned item and is responsible for deleting it.
227   * <p>
228   * @param n the index of the item to remove
229   * <p>
230   * @see #size()
231   */ public
232 Rule remove(long n) {
233  return (Rule) libsbml.DowncastSBase(libsbmlJNI.ListOfRules_remove__SWIG_0(swigCPtr, this, n), true);
234}
235
236  
237/**
238   * Returns the first child element found that has the given <code>id</code> in the model-wide SId namespace, or <code>null</code> if no such object is found.  Note that AssignmentRules and RateRules do not actually have IDs, but the {@link libsbml} interface pretends that they do:  no assignment rule or rate rule is returned by this function.
239   * <p>
240   * @param id string representing the id of objects to find
241   * <p>
242   * @return pointer to the first element found with the given <code>id</code>.
243   */ public
244 SBase getElementBySId(String id) {
245  return libsbml.DowncastSBase(libsbmlJNI.ListOfRules_getElementBySId(swigCPtr, this, id), false);
246}
247
248  
249/**
250   * Removes item in this {@link ListOfRules} items with the given identifier.
251   * <p>
252   * The caller owns the returned item and is responsible for deleting it.
253   * If none of the items in this list have the identifier <code>sid</code>, then 
254   * <code>null</code> is returned.
255   * <p>
256   * @param sid the identifier of the item to remove
257   * <p>
258   * @return the item removed.  As mentioned above, the caller owns the
259   * returned item.
260   */ public
261 Rule remove(String sid) {
262  return (Rule) libsbml.DowncastSBase(libsbmlJNI.ListOfRules_remove__SWIG_1(swigCPtr, this, sid), true);
263}
264
265}