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 ListOfEventAssignments
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 ListOfEventAssignments extends ListOf {
060   private long swigCPtr;
061
062   protected ListOfEventAssignments(long cPtr, boolean cMemoryOwn)
063   {
064     super(libsbmlJNI.ListOfEventAssignments_SWIGUpcast(cPtr), cMemoryOwn);
065     swigCPtr = cPtr;
066   }
067
068   protected static long getCPtr(ListOfEventAssignments obj)
069   {
070     return (obj == null) ? 0 : obj.swigCPtr;
071   }
072
073   protected static long getCPtrAndDisown (ListOfEventAssignments 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_ListOfEventAssignments(swigCPtr);
095      }
096      swigCPtr = 0;
097    }
098    super.delete();
099  }
100
101  
102/**
103   * Creates a new {@link ListOfEventAssignments} 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 ListOfEventAssignments(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
113    this(libsbmlJNI.new_ListOfEventAssignments__SWIG_0(level, version), true);
114  }
115
116  
117/**
118   * Creates a new {@link ListOfEventAssignments} 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 ListOfEventAssignments} object to be created.
126   */ public
127 ListOfEventAssignments(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
128    this(libsbmlJNI.new_ListOfEventAssignments__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
129  }
130
131  
132/**
133   * Creates and returns a deep copy of this {@link ListOfEventAssignments}.
134   <p>
135   * @return a (deep) copy of this {@link ListOfEventAssignments}.
136   */ public
137 ListOfEventAssignments cloneObject() {
138    long cPtr = libsbmlJNI.ListOfEventAssignments_cloneObject(swigCPtr, this);
139    return (cPtr == 0) ? null : new ListOfEventAssignments(cPtr, true);
140  }
141
142  
143/**
144   * Returns the libSBML type code for the objects contained in this {@link ListOf}
145   * (i.e., {@link EventAssignment} objects, if the list is non-empty).
146   <p>
147   * <p>
148 * LibSBML attaches an identifying code to every kind of SBML object.  These
149 * are integer constants known as <em>SBML type codes</em>.  The names of all
150 * the codes begin with the characters &ldquo;<code>SBML_</code>&rdquo;. 
151 * In the Java language interface for libSBML, the
152 * type codes are defined as static integer constants in the interface class
153 * {@link libsbmlConstants}.    Note that different Level&nbsp;3 
154 * package plug-ins may use overlapping type codes; to identify the package
155 * to which a given object belongs, call the <code>getPackageName()</code>
156 * method on the object.
157   <p>
158   * @return the SBML type code for the objects contained in this ListOf:
159   * {@link  libsbmlConstants#SBML_EVENT_ASSIGNMENT SBML_EVENT_ASSIGNMENT} (default).
160   <p>
161   * @see #getElementName()
162   * @see #getPackageName()
163   */ public
164 int getItemTypeCode() {
165    return libsbmlJNI.ListOfEventAssignments_getItemTypeCode(swigCPtr, this);
166  }
167
168  
169/**
170   * Returns the XML element name of this object.
171   <p>
172   * For {@link ListOfEventAssignments}, the XML element name is 
173   * <code>'listOfEventAssignments'.</code>
174   <p>
175   * @return the name of this element, i.e., <code>'listOfEventAssignments'.</code>
176   */ public
177 String getElementName() {
178    return libsbmlJNI.ListOfEventAssignments_getElementName(swigCPtr, this);
179  }
180
181  
182/**
183   * Get a {@link EventAssignment} from the {@link ListOfEventAssignments}.
184   <p>
185   * @param n the index number of the {@link EventAssignment} to get.
186   <p>
187   * @return the nth {@link EventAssignment} in this {@link ListOfEventAssignments}.
188   <p>
189   * @see #size()
190   */ public
191 EventAssignment get(long n) {
192    long cPtr = libsbmlJNI.ListOfEventAssignments_get__SWIG_0(swigCPtr, this, n);
193    return (cPtr == 0) ? null : new EventAssignment(cPtr, false);
194  }
195
196  
197/**
198   * Get a {@link EventAssignment} from the {@link ListOfEventAssignments}
199   * based on its identifier.
200   <p>
201   * @param sid a string representing the identifier 
202   * of the {@link EventAssignment} to get.
203   <p>
204   * @return {@link EventAssignment} in this {@link ListOfEventAssignments}
205   * with the given <code>sid</code> or <code>null</code> if no such
206   * {@link EventAssignment} exists.
207   <p>
208   * @see #get(long n)
209   * @see #size()
210   */ public
211 EventAssignment get(String sid) {
212    long cPtr = libsbmlJNI.ListOfEventAssignments_get__SWIG_2(swigCPtr, this, sid);
213    return (cPtr == 0) ? null : new EventAssignment(cPtr, false);
214  }
215
216  
217/**
218   * Removes the nth item from this {@link ListOfEventAssignments} items and returns
219   * a pointer to it.
220   <p>
221   * The caller owns the returned item and is responsible for deleting it.
222   <p>
223   * @param n the index of the item to remove
224   <p>
225   * @see #size()
226   */ public
227 EventAssignment remove(long n) {
228    long cPtr = libsbmlJNI.ListOfEventAssignments_remove__SWIG_0(swigCPtr, this, n);
229    return (cPtr == 0) ? null : new EventAssignment(cPtr, true);
230  }
231
232  
233/**
234   * Removes item in this {@link ListOfEventAssignments} items with the given
235   * identifier.
236   <p>
237   * The caller owns the returned item and is responsible for deleting it.
238   * If none of the items in this list have the identifier <code>sid</code>, then 
239   * <code>null</code> is returned.
240   <p>
241   * @param sid the identifier of the item to remove
242   <p>
243   * @return the item removed.  As mentioned above, the caller owns the
244   * returned item.
245   */ public
246 EventAssignment remove(String sid) {
247    long cPtr = libsbmlJNI.ListOfEventAssignments_remove__SWIG_1(swigCPtr, this, sid);
248    return (cPtr == 0) ? null : new EventAssignment(cPtr, true);
249  }
250
251  
252/**
253   * Returns the first child element found that has the given <code>id</code> in the
254   * model-wide SId namespace, or <code>null</code> if no such object is found.
255   <p>
256   * Note that EventAssignments do not actually have IDs, but the libsbml
257   * interface pretends that they do: no event assignment is returned by this
258   * function.
259   <p>
260   * @param id string representing the id of objects to find
261   <p>
262   * @return pointer to the first element found with the given <code>id</code>.
263   */ public
264 SBase getElementBySId(String id) {
265  return libsbml.DowncastSBase(libsbmlJNI.ListOfEventAssignments_getElementBySId(swigCPtr, this, id), false);
266}
267
268}