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