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 SpeciesReference} 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 ListOfSpeciesReferences extends ListOf {
059   private long swigCPtr;
060
061   protected ListOfSpeciesReferences(long cPtr, boolean cMemoryOwn)
062   {
063     super(libsbmlJNI.ListOfSpeciesReferences_SWIGUpcast(cPtr), cMemoryOwn);
064     swigCPtr = cPtr;
065   }
066
067   protected static long getCPtr(ListOfSpeciesReferences obj)
068   {
069     return (obj == null) ? 0 : obj.swigCPtr;
070   }
071
072   protected static long getCPtrAndDisown (ListOfSpeciesReferences 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_ListOfSpeciesReferences(swigCPtr);
094      }
095      swigCPtr = 0;
096    }
097    super.delete();
098  }
099
100  
101/**
102   * Creates a new, empty {@link ListOfSpeciesReferences} 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 ListOfSpeciesReferences(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
133    this(libsbmlJNI.new_ListOfSpeciesReferences__SWIG_0(level, version), true);
134  }
135
136  
137/**
138   * Creates a new {@link ListOfSpeciesReferences} 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 ListOfSpeciesReferences} 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 ListOfSpeciesReferences(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
169    this(libsbmlJNI.new_ListOfSpeciesReferences__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
170  }
171
172  
173/**
174   * Creates and returns a deep copy of this {@link ListOfSpeciesReferences} object.
175   <p>
176   * @return the (deep) copy of this {@link ListOfSpeciesReferences} object.
177   */ public
178 ListOfSpeciesReferences cloneObject() {
179    long cPtr = libsbmlJNI.ListOfSpeciesReferences_cloneObject(swigCPtr, this);
180    return (cPtr == 0) ? null : new ListOfSpeciesReferences(cPtr, true);
181  }
182
183  
184/**
185   * Returns the libSBML type code for the objects contained in this {@link ListOf}
186   * (i.e., {@link SpeciesReference} 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 objects contained in this list:
200   * {@link libsbmlConstants#SBML_SPECIES_REFERENCE SBML_SPECIES_REFERENCE} (default).
201   <p>
202   * @see #getElementName()
203   * @see #getPackageName()
204   */ public
205 int getItemTypeCode() {
206    return libsbmlJNI.ListOfSpeciesReferences_getItemTypeCode(swigCPtr, this);
207  }
208
209  
210/**
211   * Returns the XML element name of this object.
212   <p>
213   * For {@link ListOfSpeciesReferences}, the XML element name is 
214   * <code>'listOfSpeciesReferences'.</code>
215   <p>
216   * @return the name of this element, i.e., <code>'listOfSpeciesReferences'.</code>
217   */ public
218 String getElementName() {
219    return libsbmlJNI.ListOfSpeciesReferences_getElementName(swigCPtr, this);
220  }
221
222  
223/**
224   * Get a {@link SpeciesReference} from the {@link ListOfSpeciesReferences}.
225   <p>
226   * @param n the index number of the {@link SpeciesReference} to get.
227   <p>
228   * @return the nth {@link SpeciesReference} in this {@link ListOfSpeciesReferences}.
229   <p>
230   * @see #size()
231   */ public
232 SimpleSpeciesReference get(long n) {
233  return (SimpleSpeciesReference) libsbml.DowncastSBase(libsbmlJNI.ListOfSpeciesReferences_get__SWIG_0(swigCPtr, this, n), false);
234}
235
236  
237/**
238   * Get a {@link SpeciesReference} from the {@link ListOfSpeciesReferences}
239   * based on its identifier.
240   <p>
241   * @param sid a string representing the identifier 
242   * of the {@link SpeciesReference} to get.
243   <p>
244   * @return {@link SpeciesReference} in this {@link ListOfSpeciesReferences}
245   * with the given <code>sid</code> or <code>null</code> if no such
246   * {@link SpeciesReference} exists.
247   <p>
248   * @see #get(long n)
249   * @see #size()
250   */ public
251 SimpleSpeciesReference get(String sid) {
252  return (SimpleSpeciesReference) libsbml.DowncastSBase(libsbmlJNI.ListOfSpeciesReferences_get__SWIG_2(swigCPtr, this, sid), false);
253}
254
255  
256/**
257   * Removes the nth item from this {@link ListOfSpeciesReferences} items and returns a pointer to
258   * it.
259   <p>
260   * The caller owns the returned item and is responsible for deleting it.
261   <p>
262   * @param n the index of the item to remove
263   <p>
264   * @see #size()
265   */ public
266 SimpleSpeciesReference remove(long n) {
267  return (SimpleSpeciesReference) libsbml.DowncastSBase(libsbmlJNI.ListOfSpeciesReferences_remove__SWIG_0(swigCPtr, this, n), true);
268}
269
270  
271/**
272   * Removes item in this {@link ListOfSpeciesReferences} items with the given identifier.
273   <p>
274   * The caller owns the returned item and is responsible for deleting it.
275   * If none of the items in this list have the identifier <code>sid</code>, then 
276   * <code>null</code> is returned.
277   <p>
278   * @param sid the identifier of the item to remove
279   <p>
280   * @return the item removed.  As mentioned above, the caller owns the
281   * returned item.
282   */ public
283 SimpleSpeciesReference remove(String sid) {
284  return (SimpleSpeciesReference) libsbml.DowncastSBase(libsbmlJNI.ListOfSpeciesReferences_remove__SWIG_1(swigCPtr, this, sid), true);
285}
286
287}