001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.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 *  A list of {@link Event} 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 * SBML Level&nbsp;3 Version&nbsp;1 has essentially the same structure as 
036 * Level&nbsp;2 Version&nbsp;4, depicted above, but SBML Level&nbsp;3 
037 * Version&nbsp;2 allows
038 * containers to contain zero or more of the relevant object, instead of 
039 * requiring at least one.  As such, libsbml will write out an 
040 * otherwise-empty ListOf___ element that has any optional attribute set 
041 * (such as 'id' or 'metaid'), that has an optional child (such 
042 * as a 'notes' or 'annotation'), or that has attributes or children set
043 * from any SBML Level&nbsp;3 package, whether or not the ListOf___ has 
044 * any other children.
045 <p>
046 * Readers may wonder about the motivations for using the ListOf___
047 * containers in SBML.  A simpler approach in XML might be to place the
048 * components all directly at the top level of the model definition.  The
049 * choice made in SBML is to group them within XML elements named after
050 * ListOf<em>Classname</em>, in part because it helps organize the
051 * components.  More importantly, the fact that the container classes are
052 * derived from {@link SBase} means that software tools can add information <em>about</em>
053 * the lists themselves into each list container's 'annotation'.
054 <p>
055 * @see ListOfFunctionDefinitions
056 * @see ListOfUnitDefinitions
057 * @see ListOfCompartmentTypes
058 * @see ListOfSpeciesTypes
059 * @see ListOfCompartments
060 * @see ListOfSpecies
061 * @see ListOfParameters
062 * @see ListOfInitialAssignments
063 * @see ListOfRules
064 * @see ListOfConstraints
065 * @see ListOfReactions
066 * @see ListOfEvents
067 */
068
069public class ListOfEvents extends ListOf {
070   private long swigCPtr;
071
072   protected ListOfEvents(long cPtr, boolean cMemoryOwn)
073   {
074     super(libsbmlJNI.ListOfEvents_SWIGUpcast(cPtr), cMemoryOwn);
075     swigCPtr = cPtr;
076   }
077
078   protected static long getCPtr(ListOfEvents obj)
079   {
080     return (obj == null) ? 0 : obj.swigCPtr;
081   }
082
083   protected static long getCPtrAndDisown (ListOfEvents obj)
084   {
085     long ptr = 0;
086
087     if (obj != null)
088     {
089       ptr             = obj.swigCPtr;
090       obj.swigCMemOwn = false;
091     }
092
093     return ptr;
094   }
095
096  protected void finalize() {
097    delete();
098  }
099
100  public synchronized void delete() {
101    if (swigCPtr != 0) {
102      if (swigCMemOwn) {
103        swigCMemOwn = false;
104        libsbmlJNI.delete_ListOfEvents(swigCPtr);
105      }
106      swigCPtr = 0;
107    }
108    super.delete();
109  }
110
111  
112/**
113   * Creates a new {@link ListOfEvents} object.
114   <p>
115   * The object is constructed such that it is valid for the given SBML
116   * Level and Version combination.
117   <p>
118   * @param level the SBML Level.
119   <p>
120   * @param version the Version within the SBML Level.
121   <p>
122   * <p>
123 * @throws SBMLConstructorException
124 * Thrown if the given <code>level</code> and <code>version</code> combination are invalid
125 * or if this object is incompatible with the given level and version.
126   <p>
127   * <p>
128 * @note Attempting to add an object to an {@link SBMLDocument} having a different
129 * combination of SBML Level, Version and XML namespaces than the object
130 * itself will result in an error at the time a caller attempts to make the
131 * addition.  A parent object must have compatible Level, Version and XML
132 * namespaces.  (Strictly speaking, a parent may also have more XML
133 * namespaces than a child, but the reverse is not permitted.)  The
134 * restriction is necessary to ensure that an SBML model has a consistent
135 * overall structure.  This requires callers to manage their objects
136 * carefully, but the benefit is increased flexibility in how models can be
137 * created by permitting callers to create objects bottom-up if desired.  In
138 * situations where objects are not yet attached to parents (e.g.,
139 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
140 * libSBML determine such things as whether it is valid to assign a
141 * particular value to an attribute.
142   */ public
143 ListOfEvents(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
144    this(libsbmlJNI.new_ListOfEvents__SWIG_0(level, version), true);
145  }
146
147  
148/**
149   * Creates a new {@link ListOfEvents} object.
150   <p>
151   * The object is constructed such that it is valid for the SBML Level and
152   * Version combination determined by the {@link SBMLNamespaces} object in 
153   * <code>sbmlns</code>.
154   <p>
155   * @param sbmlns an {@link SBMLNamespaces} object that is used to determine the
156   * characteristics of the {@link ListOfEvents} object to be created.
157   <p>
158   * <p>
159 * @throws SBMLConstructorException
160 * Thrown if the given <code>sbmlns</code> is inconsistent or incompatible
161 * with this object.
162   <p>
163   * <p>
164 * @note Attempting to add an object to an {@link SBMLDocument} having a different
165 * combination of SBML Level, Version and XML namespaces than the object
166 * itself will result in an error at the time a caller attempts to make the
167 * addition.  A parent object must have compatible Level, Version and XML
168 * namespaces.  (Strictly speaking, a parent may also have more XML
169 * namespaces than a child, but the reverse is not permitted.)  The
170 * restriction is necessary to ensure that an SBML model has a consistent
171 * overall structure.  This requires callers to manage their objects
172 * carefully, but the benefit is increased flexibility in how models can be
173 * created by permitting callers to create objects bottom-up if desired.  In
174 * situations where objects are not yet attached to parents (e.g.,
175 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
176 * libSBML determine such things as whether it is valid to assign a
177 * particular value to an attribute.
178   */ public
179 ListOfEvents(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
180    this(libsbmlJNI.new_ListOfEvents__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
181  }
182
183  
184/**
185   * Creates and returns a deep copy of this {@link ListOfEvents} object.
186   <p>
187   * @return the (deep) copy of this {@link ListOfEvents} object.
188   */ public
189 ListOfEvents cloneObject() {
190    long cPtr = libsbmlJNI.ListOfEvents_cloneObject(swigCPtr, this);
191    return (cPtr == 0) ? null : new ListOfEvents(cPtr, true);
192  }
193
194  
195/**
196   * Returns the libSBML type code for the objects contained in this {@link ListOf}
197   * (i.e., {@link Event} objects, if the list is non-empty).
198   <p>
199   * <p>
200 * LibSBML attaches an identifying code to every kind of SBML object.  These
201 * are integer constants known as <em>SBML type codes</em>.  The names of all
202 * the codes begin with the characters <code>SBML_</code>.
203 * In the Java language interface for libSBML, the
204 * type codes are defined as static integer constants in the interface class
205 * {@link libsbmlConstants}.    Note that different Level&nbsp;3
206 * package plug-ins may use overlapping type codes; to identify the package
207 * to which a given object belongs, call the 
208 * <code>{@link SBase#getPackageName()}
209 * </code>
210 * method on the object.
211   <p>
212   * @return the SBML type code for the objects contained in this ListOf:
213   * {@link libsbmlConstants#SBML_EVENT SBML_EVENT} (default).
214   <p>
215   * @see #getElementName()
216   * @see #getPackageName()
217   */ public
218 int getItemTypeCode() {
219    return libsbmlJNI.ListOfEvents_getItemTypeCode(swigCPtr, this);
220  }
221
222  
223/**
224   * Returns the XML element name of this object.
225   <p>
226   * For {@link ListOfEvents}, the XML element name is <code>'listOfEvents'.</code>
227   <p>
228   * @return the name of this element, i.e., <code>'listOfEvents'.</code>
229   */ public
230 String getElementName() {
231    return libsbmlJNI.ListOfEvents_getElementName(swigCPtr, this);
232  }
233
234  
235/**
236   * Get an {@link Event} from the {@link ListOfEvents}.
237   <p>
238   * @param n the index number of the {@link Event} to get.
239   <p>
240   * @return the <code>n</code>th {@link Event} in this {@link ListOfEvents}.
241   <p>
242   * @see #size()
243   */ public
244 Event get(long n) {
245    long cPtr = libsbmlJNI.ListOfEvents_get__SWIG_0(swigCPtr, this, n);
246    return (cPtr == 0) ? null : new Event(cPtr, false);
247  }
248
249  
250/**
251   * Get an {@link Event} from the {@link ListOfEvents}
252   * based on its identifier.
253   <p>
254   * @param sid a string representing the identifier 
255   * of the {@link Event} to get.
256   <p>
257   * @return {@link Event} in this {@link ListOfEvents}
258   * with the given <code>sid</code> or <code>null</code> if no such
259   * {@link Event} exists.
260   <p>
261   * @see #get(long n)
262   * @see #size()
263   */ public
264 Event get(String sid) {
265    long cPtr = libsbmlJNI.ListOfEvents_get__SWIG_2(swigCPtr, this, sid);
266    return (cPtr == 0) ? null : new Event(cPtr, false);
267  }
268
269  
270/**
271   * Removes the nth item from this {@link ListOfEvents} items and returns a pointer to
272   * it.
273   <p>
274   * The caller owns the returned item and is responsible for deleting it.
275   <p>
276   * @param n the index of the item to remove.
277   <p>
278   * @see #size()
279   */ public
280 Event remove(long n) {
281    long cPtr = libsbmlJNI.ListOfEvents_remove__SWIG_0(swigCPtr, this, n);
282    return (cPtr == 0) ? null : new Event(cPtr, true);
283  }
284
285  
286/**
287   * Removes item in this {@link ListOfEvents} items with the given identifier.
288   <p>
289   * The caller owns the returned item and is responsible for deleting it.
290   * If none of the items in this list have the identifier <code>sid</code>, then
291   * <code>null</code> is returned.
292   <p>
293   * @param sid the identifier of the item to remove.
294   <p>
295   * @return the item removed.  As mentioned above, the caller owns the
296   * returned item.
297   */ public
298 Event remove(String sid) {
299    long cPtr = libsbmlJNI.ListOfEvents_remove__SWIG_1(swigCPtr, this, sid);
300    return (cPtr == 0) ? null : new Event(cPtr, true);
301  }
302
303}