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