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