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