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 ListOfRules construct.
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 ListOfRules extends ListOf {
059   private long swigCPtr;
060
061   protected ListOfRules(long cPtr, boolean cMemoryOwn)
062   {
063     super(libsbmlJNI.ListOfRules_SWIGUpcast(cPtr), cMemoryOwn);
064     swigCPtr = cPtr;
065   }
066
067   protected static long getCPtr(ListOfRules obj)
068   {
069     return (obj == null) ? 0 : obj.swigCPtr;
070   }
071
072   protected static long getCPtrAndDisown (ListOfRules 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_ListOfRules(swigCPtr);
094      }
095      swigCPtr = 0;
096    }
097    super.delete();
098  }
099
100  
101/**
102   * Creates a new {@link ListOfRules} 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   */ public
111 ListOfRules(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
112    this(libsbmlJNI.new_ListOfRules__SWIG_0(level, version), true);
113  }
114
115  
116/**
117   * Creates a new {@link ListOfRules} object.
118   <p>
119   * The object is constructed such that it is valid for the SBML Level and
120   * Version combination determined by the {@link SBMLNamespaces} object in 
121   * <code>sbmlns</code>.
122   <p>
123   * @param sbmlns an {@link SBMLNamespaces} object that is used to determine the
124   * characteristics of the {@link ListOfRules} object to be created.
125   */ public
126 ListOfRules(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
127    this(libsbmlJNI.new_ListOfRules__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
128  }
129
130  
131/**
132   * Creates and returns a deep copy of this {@link ListOfRules} instance.
133   <p>
134   * @return a (deep) copy of this {@link ListOfRules}.
135   */ public
136 ListOfRules cloneObject() {
137    long cPtr = libsbmlJNI.ListOfRules_cloneObject(swigCPtr, this);
138    return (cPtr == 0) ? null : new ListOfRules(cPtr, true);
139  }
140
141  
142/**
143   * Returns the libSBML type code for the objects contained in this {@link ListOf}
144   * (i.e., {@link Rule} objects, if the list is non-empty).
145   <p>
146   * <p>
147 * LibSBML attaches an identifying code to every kind of SBML object.  These
148 * are integer constants known as <em>SBML type codes</em>.  The names of all
149 * the codes begin with the characters &ldquo;<code>SBML_</code>&rdquo;. 
150 * In the Java language interface for libSBML, the
151 * type codes are defined as static integer constants in the interface class
152 * {@link libsbmlConstants}.    Note that different Level&nbsp;3 
153 * package plug-ins may use overlapping type codes; to identify the package
154 * to which a given object belongs, call the <code>getPackageName()</code>
155 * method on the object.
156   <p>
157   * @return the SBML type code for objects contained in this list:
158   * {@link  libsbmlConstants#SBML_RULE SBML_RULE} (default).
159   <p>
160   * @see #getElementName()
161   * @see #getPackageName()
162   */ public
163 int getItemTypeCode() {
164    return libsbmlJNI.ListOfRules_getItemTypeCode(swigCPtr, this);
165  }
166
167  
168/**
169   * Returns the XML element name of this object.
170   <p>
171   * For {@link ListOfRules}, the XML element name is <code>'listOfRules'.</code>
172   <p>
173   * @return the name of this element, i.e., <code>'listOfRules'.</code>
174   */ public
175 String getElementName() {
176    return libsbmlJNI.ListOfRules_getElementName(swigCPtr, this);
177  }
178
179  
180/**
181   * Get a {@link Rule} from the {@link ListOfRules}.
182   <p>
183   * @param n the index number of the {@link Rule} to get.
184   <p>
185   * @return the nth {@link Rule} in this {@link ListOfRules}.
186   <p>
187   * @see #size()
188   */ public
189 Rule get(long n) {
190  return (Rule) libsbml.DowncastSBase(libsbmlJNI.ListOfRules_get__SWIG_0(swigCPtr, this, n), false);
191}
192
193  
194/**
195   * Get a {@link Rule} from the {@link ListOfRules} based on its identifier.
196   <p>
197   * @param sid a string representing the identifier of the {@link Rule} to get.
198   <p>
199   * @return {@link Rule} in this {@link ListOfRules} with the given <code>id</code> or <code>null</code> if no
200   * such {@link Rule} exists.
201   <p>
202   * @see #get(long n)
203   * @see #size()
204   */ public
205 Rule get(String sid) {
206  return (Rule) libsbml.DowncastSBase(libsbmlJNI.ListOfRules_get__SWIG_2(swigCPtr, this, sid), false);
207}
208
209  
210/**
211   * Removes the nth item from this {@link ListOfRules} items and returns a pointer to
212   * it.
213   <p>
214   * The caller owns the returned item and is responsible for deleting it.
215   <p>
216   * @param n the index of the item to remove
217   <p>
218   * @see #size()
219   */ public
220 Rule remove(long n) {
221  return (Rule) libsbml.DowncastSBase(libsbmlJNI.ListOfRules_remove__SWIG_0(swigCPtr, this, n), true);
222}
223
224  
225/**
226   * Returns the first child element found that has the given <code>id</code> in the
227   * model-wide SId namespace, or <code>null</code> if no such object is found.
228   <p>
229   * Note that AssignmentRules and RateRules do not actually have IDs, but
230   * the libsbml interface pretends that they do: no assignment rule or rate
231   * rule is returned by this function.
232   <p>
233   * @param id string representing the id of objects to find
234   <p>
235   * @return pointer to the first element found with the given <code>id</code>.
236   */ public
237 SBase getElementBySId(String id) {
238  return libsbml.DowncastSBase(libsbmlJNI.ListOfRules_getElementBySId(swigCPtr, this, id), false);
239}
240
241  
242/**
243   * Removes item in this {@link ListOfRules} items with the given identifier.
244   <p>
245   * The caller owns the returned item and is responsible for deleting it.
246   * If none of the items in this list have the identifier <code>sid</code>, then 
247   * <code>null</code> is returned.
248   <p>
249   * @param sid the identifier of the item to remove
250   <p>
251   * @return the item removed.  As mentioned above, the caller owns the
252   * returned item.
253   */ public
254 Rule remove(String sid) {
255  return (Rule) libsbml.DowncastSBase(libsbmlJNI.ListOfRules_remove__SWIG_1(swigCPtr, this, sid), true);
256}
257
258}