001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 2.0.11
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 * 
013 * Implementation of SBML's ListOfUnits construct.
014 * <p>
015 * The various ListOf___ classes in SBML are merely containers used for
016 * organizing the main components of an SBML model.  All are derived from
017 * the abstract class {@link SBase}, and inherit the various attributes and
018 * subelements of {@link SBase}, such as 'metaid' as and 'annotation'.  The
019 * ListOf___ classes do not add any attributes of their own.
020 * <p>
021 * {@link ListOfUnits} is entirely contained within {@link UnitDefinition}.
022 */
023
024public class ListOfUnits extends ListOf {
025   private long swigCPtr;
026
027   protected ListOfUnits(long cPtr, boolean cMemoryOwn)
028   {
029     super(libsbmlJNI.ListOfUnits_SWIGUpcast(cPtr), cMemoryOwn);
030     swigCPtr = cPtr;
031   }
032
033   protected static long getCPtr(ListOfUnits obj)
034   {
035     return (obj == null) ? 0 : obj.swigCPtr;
036   }
037
038   protected static long getCPtrAndDisown (ListOfUnits obj)
039   {
040     long ptr = 0;
041
042     if (obj != null)
043     {
044       ptr             = obj.swigCPtr;
045       obj.swigCMemOwn = false;
046     }
047
048     return ptr;
049   }
050
051  protected void finalize() {
052    delete();
053  }
054
055  public synchronized void delete() {
056    if (swigCPtr != 0) {
057      if (swigCMemOwn) {
058        swigCMemOwn = false;
059        libsbmlJNI.delete_ListOfUnits(swigCPtr);
060      }
061      swigCPtr = 0;
062    }
063    super.delete();
064  }
065
066  
067/**
068   * Creates a new {@link ListOfUnits} object.
069   * <p>
070   * The object is constructed such that it is valid for the given SBML
071   * Level and Version combination.
072   * <p>
073   * @param level the SBML Level
074   * <p>
075   * @param version the Version within the SBML Level
076   */ public
077 ListOfUnits(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
078    this(libsbmlJNI.new_ListOfUnits__SWIG_0(level, version), true);
079  }
080
081  
082/**
083   * Creates a new {@link ListOfUnits} object.
084   * <p>
085   * The object is constructed such that it is valid for the SBML Level and
086   * Version combination determined by the {@link SBMLNamespaces} object in 
087   * <code>sbmlns</code>.
088   * <p>
089   * @param sbmlns an {@link SBMLNamespaces} object that is used to determine the
090   * characteristics of the {@link ListOfUnits} object to be created.
091   */ public
092 ListOfUnits(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
093    this(libsbmlJNI.new_ListOfUnits__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
094  }
095
096  
097/**
098   * Creates and returns a deep copy of this {@link ListOfUnits}.
099   * <p>
100   * @return a (deep) copy of this {@link ListOfUnits}.
101   */ public
102 ListOfUnits cloneObject() {
103    long cPtr = libsbmlJNI.ListOfUnits_cloneObject(swigCPtr, this);
104    return (cPtr == 0) ? null : new ListOfUnits(cPtr, true);
105  }
106
107  
108/**
109   * Returns the libSBML type code for this SBML object.
110   * <p>
111   * LibSBML attaches an identifying code to every
112   * kind of SBML object.  These are known as <em>SBML type codes</em>.  In
113   * other languages, the set of type codes is stored in an enumeration; in
114   * the Java language interface for libSBML, the type codes are defined as
115   * static integer constants in the interface class {@link
116   * libsbmlConstants}.  The names of the type codes all begin with the
117   * characters <code>SBML_.</code> 
118   * <p>
119   * @return the SBML type code for this object, or {@link  libsbmlConstants#SBML_UNKNOWN SBML_UNKNOWN} (default).
120   * <p>
121   * @see #getElementName()
122   */ public
123 int getTypeCode() {
124    return libsbmlJNI.ListOfUnits_getTypeCode(swigCPtr, this);
125  }
126
127  
128/**
129   * Returns the libSBML type code for the objects contained in this {@link ListOf}
130   * (i.e., {@link Unit} objects, if the list is non-empty).
131   * <p>
132   * LibSBML attaches an identifying code to every
133   * kind of SBML object.  These are known as <em>SBML type codes</em>.  In
134   * other languages, the set of type codes is stored in an enumeration; in
135   * the Java language interface for libSBML, the type codes are defined as
136   * static integer constants in the interface class {@link
137   * libsbmlConstants}.  The names of the type codes all begin with the
138   * characters <code>SBML_.</code> 
139   * <p>
140   * @return the SBML type code for the objects contained in this {@link ListOf}
141   * instance, or {@link  libsbmlConstants#SBML_UNKNOWN SBML_UNKNOWN} (default).
142   * <p>
143   * @see #getElementName()
144   */ public
145 int getItemTypeCode() {
146    return libsbmlJNI.ListOfUnits_getItemTypeCode(swigCPtr, this);
147  }
148
149  
150/**
151   * Returns the XML element name of this object.
152   * <p>
153   * For {@link ListOfUnits}, the XML element name is <code>'listOfUnits'.</code>
154   * <p>
155   * @return the name of this element, i.e., <code>'listOfUnits'.</code>
156   */ public
157 String getElementName() {
158    return libsbmlJNI.ListOfUnits_getElementName(swigCPtr, this);
159  }
160
161  
162/**
163   * Get a {@link Unit} from the {@link ListOfUnits}.
164   * <p>
165   * @param n the index number of the {@link Unit} to get.
166   * <p>
167   * @return the nth {@link Unit} in this {@link ListOfUnits}.
168   * <p>
169   * @see #size()
170   */ public
171 Unit get(long n) {
172    long cPtr = libsbmlJNI.ListOfUnits_get__SWIG_0(swigCPtr, this, n);
173    return (cPtr == 0) ? null : new Unit(cPtr, false);
174  }
175
176  
177/**
178   * Removes the nth item from this {@link ListOfUnits} items and returns a pointer to
179   * it.
180   * <p>
181   * The caller owns the returned item and is responsible for deleting it.
182   * <p>
183   * @param n the index of the item to remove
184   * <p>
185   * @see #size()
186   */ public
187 Unit remove(long n) {
188    long cPtr = libsbmlJNI.ListOfUnits_remove(swigCPtr, this, n);
189    return (cPtr == 0) ? null : new Unit(cPtr, true);
190  }
191
192}