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 ListOfReactions 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 ListOfReactions extends ListOf {
059   private long swigCPtr;
060
061   protected ListOfReactions(long cPtr, boolean cMemoryOwn)
062   {
063     super(libsbmlJNI.ListOfReactions_SWIGUpcast(cPtr), cMemoryOwn);
064     swigCPtr = cPtr;
065   }
066
067   protected static long getCPtr(ListOfReactions obj)
068   {
069     return (obj == null) ? 0 : obj.swigCPtr;
070   }
071
072   protected static long getCPtrAndDisown (ListOfReactions 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_ListOfReactions(swigCPtr);
094      }
095      swigCPtr = 0;
096    }
097    super.delete();
098  }
099
100  
101/**
102   * Creates a new {@link ListOfReactions} 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 ListOfReactions(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
112    this(libsbmlJNI.new_ListOfReactions__SWIG_0(level, version), true);
113  }
114
115  
116/**
117   * Creates a new {@link ListOfReactions} 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 ListOfReactions} object to be created.
125   */ public
126 ListOfReactions(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
127    this(libsbmlJNI.new_ListOfReactions__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
128  }
129
130  
131/**
132   * Creates and returns a deep copy of this {@link ListOfReactions} instance.
133   <p>
134   * @return a (deep) copy of this {@link ListOfReactions}.
135   */ public
136 ListOfReactions cloneObject() {
137    long cPtr = libsbmlJNI.ListOfReactions_cloneObject(swigCPtr, this);
138    return (cPtr == 0) ? null : new ListOfReactions(cPtr, true);
139  }
140
141  
142/**
143   * Returns the libSBML type code for the objects contained in this {@link ListOf}
144   * (i.e., {@link Reaction} 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_REACTION SBML_REACTION} (default).
159   <p>
160   * @see #getElementName()
161   * @see #getPackageName()
162   */ public
163 int getItemTypeCode() {
164    return libsbmlJNI.ListOfReactions_getItemTypeCode(swigCPtr, this);
165  }
166
167  
168/**
169   * Returns the XML element name of this object
170   <p>
171   * For {@link ListOfReactions}, the XML element name is <code>'listOfReactions'.</code>
172   <p>
173   * @return the name of this element, i.e., <code>'listOfReactions'.</code>
174   */ public
175 String getElementName() {
176    return libsbmlJNI.ListOfReactions_getElementName(swigCPtr, this);
177  }
178
179  
180/**
181   * Get a {@link Reaction} from the {@link ListOfReactions}.
182   <p>
183   * @param n the index number of the {@link Reaction} to get.
184   <p>
185   * @return the nth {@link Reaction} in this {@link ListOfReactions}.
186   <p>
187   * @see #size()
188   */ public
189 Reaction get(long n) {
190    long cPtr = libsbmlJNI.ListOfReactions_get__SWIG_0(swigCPtr, this, n);
191    return (cPtr == 0) ? null : new Reaction(cPtr, false);
192  }
193
194  
195/**
196   * Get a {@link Reaction} from the {@link ListOfReactions} based on its identifier.
197   <p>
198   * @param sid a string representing the identifier of the {@link Reaction} to get.
199   <p>
200   * @return {@link Reaction} in this {@link ListOfReactions} with the given <code>sid</code> or 
201   * <code>null</code> if no such {@link Reaction} exists.
202   <p>
203   * @see #get(long n)
204   * @see #size()
205   */ public
206 Reaction get(String sid) {
207    long cPtr = libsbmlJNI.ListOfReactions_get__SWIG_2(swigCPtr, this, sid);
208    return (cPtr == 0) ? null : new Reaction(cPtr, false);
209  }
210
211  
212/**
213   * Removes the nth item from this {@link ListOfReactions} items and returns a
214   * pointer to it.
215   <p>
216   * The caller owns the returned item and is responsible for deleting it.
217   <p>
218   * @param n the index of the item to remove
219   <p>
220   * @see #size()
221   */ public
222 Reaction remove(long n) {
223    long cPtr = libsbmlJNI.ListOfReactions_remove__SWIG_0(swigCPtr, this, n);
224    return (cPtr == 0) ? null : new Reaction(cPtr, true);
225  }
226
227  
228/**
229   * Removes item in this {@link ListOfReactions} items with the given identifier.
230   <p>
231   * The caller owns the returned item and is responsible for deleting it.
232   * If none of the items in this list have the identifier <code>sid</code>, then
233   * null is returned.
234   <p>
235   * @param sid the identifier of the item to remove
236   <p>
237   * @return the item removed.  As mentioned above, the caller owns the
238   * returned item.
239   */ public
240 Reaction remove(String sid) {
241    long cPtr = libsbmlJNI.ListOfReactions_remove__SWIG_1(swigCPtr, this, sid);
242    return (cPtr == 0) ? null : new Reaction(cPtr, true);
243  }
244
245}