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 ListOfUnits construct.
013 <p>
014 * {@link ListOfUnits} is entirely contained within {@link UnitDefinition}.
015 <p>
016 * <p>
017 * The various ListOf___ classes in SBML
018 * are merely containers used for organizing the main components of an SBML
019 * model.  In libSBML's implementation, ListOf___
020 * classes are derived from the
021 * intermediate utility class {@link ListOf}, which
022 * is not defined by the SBML specifications but serves as a useful
023 * programmatic construct.  {@link ListOf} is itself is in turn derived from {@link SBase},
024 * which provides all of the various ListOf___
025 * classes with common features
026 * defined by the SBML specification, such as 'metaid' attributes and
027 * annotations.
028 <p>
029 * The relationship between the lists and the rest of an SBML model is
030 * illustrated by the following (for SBML Level&nbsp;2 Version&nbsp;4):
031 <p>
032 * <figure>
033  <object type="image/svg+xml" data="listof-illustration.svg" class="centered"></object>
034</figure>
035
036 <p>
037 * Readers may wonder about the motivations for using the ListOf___
038 * containers in SBML.  A simpler approach in XML might be to place the
039 * components all directly at the top level of the model definition.  The
040 * choice made in SBML is to group them within XML elements named after
041 * ListOf<em>Classname</em>, in part because it helps organize the
042 * components.  More importantly, the fact that the container classes are
043 * derived from {@link SBase} means that software tools can add information <em>about</em>
044 * the lists themselves into each list container's 'annotation'.
045 <p>
046 * @see ListOfFunctionDefinitions
047 * @see ListOfUnitDefinitions
048 * @see ListOfCompartmentTypes
049 * @see ListOfSpeciesTypes
050 * @see ListOfCompartments
051 * @see ListOfSpecies
052 * @see ListOfParameters
053 * @see ListOfInitialAssignments
054 * @see ListOfRules
055 * @see ListOfConstraints
056 * @see ListOfReactions
057 * @see ListOfEvents
058 */
059
060public class ListOfUnits extends ListOf {
061   private long swigCPtr;
062
063   protected ListOfUnits(long cPtr, boolean cMemoryOwn)
064   {
065     super(libsbmlJNI.ListOfUnits_SWIGUpcast(cPtr), cMemoryOwn);
066     swigCPtr = cPtr;
067   }
068
069   protected static long getCPtr(ListOfUnits obj)
070   {
071     return (obj == null) ? 0 : obj.swigCPtr;
072   }
073
074   protected static long getCPtrAndDisown (ListOfUnits obj)
075   {
076     long ptr = 0;
077
078     if (obj != null)
079     {
080       ptr             = obj.swigCPtr;
081       obj.swigCMemOwn = false;
082     }
083
084     return ptr;
085   }
086
087  protected void finalize() {
088    delete();
089  }
090
091  public synchronized void delete() {
092    if (swigCPtr != 0) {
093      if (swigCMemOwn) {
094        swigCMemOwn = false;
095        libsbmlJNI.delete_ListOfUnits(swigCPtr);
096      }
097      swigCPtr = 0;
098    }
099    super.delete();
100  }
101
102  
103/**
104   * Creates a new {@link ListOfUnits} object.
105   <p>
106   * The object is constructed such that it is valid for the given SBML
107   * Level and Version combination.
108   <p>
109   * @param level the SBML Level
110   <p>
111   * @param version the Version within the SBML Level
112   */ public
113 ListOfUnits(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
114    this(libsbmlJNI.new_ListOfUnits__SWIG_0(level, version), true);
115  }
116
117  
118/**
119   * Creates a new {@link ListOfUnits} object.
120   <p>
121   * The object is constructed such that it is valid for the SBML Level and
122   * Version combination determined by the {@link SBMLNamespaces} object in 
123   * <code>sbmlns</code>.
124   <p>
125   * @param sbmlns an {@link SBMLNamespaces} object that is used to determine the
126   * characteristics of the {@link ListOfUnits} object to be created.
127   */ public
128 ListOfUnits(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
129    this(libsbmlJNI.new_ListOfUnits__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
130  }
131
132  
133/**
134   * Creates and returns a deep copy of this {@link ListOfUnits}.
135   <p>
136   * @return a (deep) copy of this {@link ListOfUnits}.
137   */ public
138 ListOfUnits cloneObject() {
139    long cPtr = libsbmlJNI.ListOfUnits_cloneObject(swigCPtr, this);
140    return (cPtr == 0) ? null : new ListOfUnits(cPtr, true);
141  }
142
143  
144/**
145   * Returns the libSBML type code for the objects contained in this {@link ListOf}
146   * (i.e., {@link Unit} objects, if the list is non-empty).
147   <p>
148   * <p>
149 * LibSBML attaches an identifying code to every kind of SBML object.  These
150 * are integer constants known as <em>SBML type codes</em>.  The names of all
151 * the codes begin with the characters &ldquo;<code>SBML_</code>&rdquo;. 
152 * In the Java language interface for libSBML, the
153 * type codes are defined as static integer constants in the interface class
154 * {@link libsbmlConstants}.    Note that different Level&nbsp;3 
155 * package plug-ins may use overlapping type codes; to identify the package
156 * to which a given object belongs, call the <code>getPackageName()</code>
157 * method on the object.
158   <p>
159   * @return the SBML type code for objects contained in this list:
160   * {@link  libsbmlConstants#SBML_UNIT SBML_UNIT} (default).
161   <p>
162   * @see #getElementName()
163   * @see #getPackageName()
164   */ public
165 int getItemTypeCode() {
166    return libsbmlJNI.ListOfUnits_getItemTypeCode(swigCPtr, this);
167  }
168
169  
170/**
171   * Returns the XML element name of this object.
172   <p>
173   * For {@link ListOfUnits}, the XML element name is <code>'listOfUnits'.</code>
174   <p>
175   * @return the name of this element, i.e., <code>'listOfUnits'.</code>
176   */ public
177 String getElementName() {
178    return libsbmlJNI.ListOfUnits_getElementName(swigCPtr, this);
179  }
180
181  
182/**
183   * Get a {@link Unit} from the {@link ListOfUnits}.
184   <p>
185   * @param n the index number of the {@link Unit} to get.
186   <p>
187   * @return the nth {@link Unit} in this {@link ListOfUnits}.
188   <p>
189   * @see #size()
190   */ public
191 Unit get(long n) {
192    long cPtr = libsbmlJNI.ListOfUnits_get__SWIG_0(swigCPtr, this, n);
193    return (cPtr == 0) ? null : new Unit(cPtr, false);
194  }
195
196  
197/**
198   * Removes the nth item from this {@link ListOfUnits} items and returns a pointer to
199   * it.
200   <p>
201   * The caller owns the returned item and is responsible for deleting it.
202   <p>
203   * @param n the index of the item to remove
204   <p>
205   * @see #size()
206   */ public
207 Unit remove(long n) {
208    long cPtr = libsbmlJNI.ListOfUnits_remove(swigCPtr, this, n);
209    return (cPtr == 0) ? null : new Unit(cPtr, true);
210  }
211
212}