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