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 * <span class="pkg-marker pkg-color-comp"><a href="group__comp.html">comp</a></span>
013 A list of {@link Port} objects.
014 <p>
015 * The {@link ListOfPorts} is a container for the extended 
016 * {@link Model} for {@link Port} objects for that {@link Model}.
017 <p>
018 * <p>
019 * The various ListOf___ classes in SBML
020 * are merely containers used for organizing the main components of an SBML
021 * model.  In libSBML's implementation, ListOf___
022 * classes are derived from the
023 * intermediate utility class {@link ListOf}, which
024 * is not defined by the SBML specifications but serves as a useful
025 * programmatic construct.  {@link ListOf} is itself is in turn derived from {@link SBase},
026 * which provides all of the various ListOf___
027 * classes with common features
028 * defined by the SBML specification, such as 'metaid' attributes and
029 * annotations.
030 <p>
031 * The relationship between the lists and the rest of an SBML model is
032 * illustrated by the following (for SBML Level&nbsp;2 Version&nbsp;4):
033 <p>
034 * <figure>
035  <object type="image/svg+xml" data="listof-illustration.svg" class="centered"></object>
036</figure>
037
038 <p>
039 * Readers may wonder about the motivations for using the ListOf___
040 * containers in SBML.  A simpler approach in XML might be to place the
041 * components all directly at the top level of the model definition.  The
042 * choice made in SBML is to group them within XML elements named after
043 * ListOf<em>Classname</em>, in part because it helps organize the
044 * components.  More importantly, the fact that the container classes are
045 * derived from {@link SBase} means that software tools can add information <em>about</em>
046 * the lists themselves into each list container's 'annotation'.
047 <p>
048 * @see ListOfFunctionDefinitions
049 * @see ListOfUnitDefinitions
050 * @see ListOfCompartmentTypes
051 * @see ListOfSpeciesTypes
052 * @see ListOfCompartments
053 * @see ListOfSpecies
054 * @see ListOfParameters
055 * @see ListOfInitialAssignments
056 * @see ListOfRules
057 * @see ListOfConstraints
058 * @see ListOfReactions
059 * @see ListOfEvents
060 <p>
061 * @see Port
062 * @see ListOfDeletions
063 * @see ListOfExternalModelDefinitions
064 * @see ListOfModelDefinitions
065 * @see ListOfReplacedElements
066 * @see ListOfSubmodels
067 */
068
069public class ListOfPorts extends ListOf {
070   private long swigCPtr;
071
072   protected ListOfPorts(long cPtr, boolean cMemoryOwn)
073   {
074     super(libsbmlJNI.ListOfPorts_SWIGUpcast(cPtr), cMemoryOwn);
075     swigCPtr = cPtr;
076   }
077
078   protected static long getCPtr(ListOfPorts obj)
079   {
080     return (obj == null) ? 0 : obj.swigCPtr;
081   }
082
083   protected static long getCPtrAndDisown (ListOfPorts 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_ListOfPorts(swigCPtr);
105      }
106      swigCPtr = 0;
107    }
108    super.delete();
109  }
110
111  
112/**
113   * Creates and returns a deep copy of this {@link ListOfPorts} object.
114   <p>
115   * @return a (deep) copy of this {@link ListOfPorts}.
116   */ public
117 ListOfPorts cloneObject() {
118    long cPtr = libsbmlJNI.ListOfPorts_cloneObject(swigCPtr, this);
119    return (cPtr == 0) ? null : new ListOfPorts(cPtr, true);
120  }
121
122  
123/**
124   * Creates a new {@link ListOfPorts} with the given level, version, and package version.
125   <p>
126   * @param level the SBML Level
127   * @param version the Version within the SBML Level
128   * @param pkgVersion the version of the package
129   */ public
130 ListOfPorts(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException {
131    this(libsbmlJNI.new_ListOfPorts__SWIG_0(level, version, pkgVersion), true);
132  }
133
134  
135/**
136   * Creates a new {@link ListOfPorts} with the given level, version, and package version.
137   <p>
138   * @param level the SBML Level
139   * @param version the Version within the SBML Level
140   * @param pkgVersion the version of the package
141   */ public
142 ListOfPorts(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
143    this(libsbmlJNI.new_ListOfPorts__SWIG_1(level, version), true);
144  }
145
146  
147/**
148   * Creates a new {@link ListOfPorts} with the given level, version, and package version.
149   <p>
150   * @param level the SBML Level
151   * @param version the Version within the SBML Level
152   * @param pkgVersion the version of the package
153   */ public
154 ListOfPorts(long level) throws org.sbml.libsbml.SBMLConstructorException {
155    this(libsbmlJNI.new_ListOfPorts__SWIG_2(level), true);
156  }
157
158  
159/**
160   * Creates a new {@link ListOfPorts} with the given level, version, and package version.
161   <p>
162   * @param level the SBML Level
163   * @param version the Version within the SBML Level
164   * @param pkgVersion the version of the package
165   */ public
166 ListOfPorts() throws org.sbml.libsbml.SBMLConstructorException {
167    this(libsbmlJNI.new_ListOfPorts__SWIG_3(), true);
168  }
169
170  
171/**
172   * Creates a new {@link ListOfPorts} with the given {@link CompPkgNamespaces} object.
173   <p>
174   * @param compns the namespace to use
175   */ public
176 ListOfPorts(CompPkgNamespaces compns) throws org.sbml.libsbml.SBMLConstructorException {
177    this(libsbmlJNI.new_ListOfPorts__SWIG_4(CompPkgNamespaces.getCPtr(compns), compns), true);
178  }
179
180  
181/**
182   * Get a {@link Port} from the {@link ListOfPorts}.
183   <p>
184   * @param n the index number of the {@link Port} to get.
185   <p>
186   * @return the nth {@link Port} in this {@link ListOfPorts}.
187   <p>
188   * @see #size()
189   */ public
190 SBase get(long n) {
191    long cPtr = libsbmlJNI.ListOfPorts_get__SWIG_0(swigCPtr, this, n);
192    return (cPtr == 0) ? null : new Port(cPtr, false);
193  }
194
195  
196/**
197   * Get a {@link Port} from the {@link ListOfPorts}
198   * based on its identifier.
199   <p>
200   * @param sid a string representing the identifier 
201   * of the {@link Port} to get.
202   <p>
203   * @return {@link Port} in this {@link ListOfPorts}
204   * with the given <code>sid</code> or <code>null</code> if no such
205   * Member exists.
206   <p>
207   * @see #get(long n)
208   * @see #size()
209   */ public
210 Port get(String sid) {
211    long cPtr = libsbmlJNI.ListOfPorts_get__SWIG_2(swigCPtr, this, sid);
212    return (cPtr == 0) ? null : new Port(cPtr, false);
213  }
214
215  
216/**
217   * Removes an item from this {@link ListOfPorts} items based on the identifier and
218   * returns a pointer to it.
219   <p>
220   * The caller owns the returned item and is responsible for deleting it.
221   <p>
222   * @param sid string representing the id of the {@link Port} to remove
223   <p>
224   * @see #size()
225   */ public
226 Port remove(String sid) {
227    long cPtr = libsbmlJNI.ListOfPorts_remove__SWIG_0(swigCPtr, this, sid);
228    return (cPtr == 0) ? null : new Port(cPtr, true);
229  }
230
231  
232/**
233   * Removes the nth item from this {@link ListOfPorts} items and returns a pointer
234   * to it.
235   <p>
236   * The caller owns the returned item and is responsible for deleting it.
237   <p>
238   * @param n the index of the item to remove
239   <p>
240   * @see #size()
241   */ public
242 SBase remove(long n) {
243    long cPtr = libsbmlJNI.ListOfPorts_remove__SWIG_1(swigCPtr, this, n);
244    return (cPtr == 0) ? null : new Port(cPtr, true);
245  }
246
247  
248/**
249   * Returns the libSBML type code for the objects contained in this {@link ListOf}
250   * (i.e., {@link Port} objects, if the list is non-empty).
251   <p>
252   * <p>
253 * LibSBML attaches an identifying code to every kind of SBML object.  These
254 * are integer constants known as <em>SBML type codes</em>.  The names of all
255 * the codes begin with the characters <code>SBML_</code>.
256 * In the Java language interface for libSBML, the
257 * type codes are defined as static integer constants in the interface class
258 * {@link libsbmlConstants}.    Note that different Level&nbsp;3
259 * package plug-ins may use overlapping type codes; to identify the package
260 * to which a given object belongs, call the <code>getPackageName()</code>
261 * method on the object.
262   <p>
263   * @return the SBML type code for objects contained in this list:
264   * {@link libsbmlConstants#SBML_COMP_PORT SBML_COMP_PORT} (default).
265   <p>
266   * @see #getElementName()
267   * @see #getPackageName()
268   */ public
269 int getItemTypeCode() {
270    return libsbmlJNI.ListOfPorts_getItemTypeCode(swigCPtr, this);
271  }
272
273  
274/**
275   * Returns the XML element name of
276   * this SBML object.
277   <p>
278   * @return the name of this element, as a text string.
279   */ public
280 String getElementName() {
281    return libsbmlJNI.ListOfPorts_getElementName(swigCPtr, this);
282  }
283
284  
285/**
286   * Returns the first child element found that has the given <code>id</code> in the
287   * model-wide SId namespace, or <code>null</code> if no such object is found.  Since the
288   * id of {@link Port} objects are in the PortSId namespace, no {@link Port} object is
289   * returned by this function.
290   <p>
291   * @param id string representing the id of objects to find
292   <p>
293   * @return a pointer to the {@link SBase} element with the given <code>id</code>.
294   */ public
295 SBase getElementBySId(String id) {
296  return libsbml.DowncastSBase(libsbmlJNI.ListOfPorts_getElementBySId(swigCPtr, this, id), false);
297}
298
299}