001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.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 * A list of {@link SpeciesType} objects. 013 <p> 014 * <p> 015 * The various ListOf___ classes in SBML 016 * are merely containers used for organizing the main components of an SBML 017 * model. In libSBML's implementation, ListOf___ 018 * classes are derived from the 019 * intermediate utility class {@link ListOf}, which 020 * is not defined by the SBML specifications but serves as a useful 021 * programmatic construct. {@link ListOf} is itself is in turn derived from {@link SBase}, 022 * which provides all of the various ListOf___ 023 * classes with common features 024 * defined by the SBML specification, such as 'metaid' attributes and 025 * annotations. 026 <p> 027 * The relationship between the lists and the rest of an SBML model is 028 * illustrated by the following (for SBML Level 2 Version 4): 029 <p> 030 * <figure> 031 <object type="image/svg+xml" data="listof-illustration.svg" class="centered"></object> 032</figure> 033 034 <p> 035 * SBML Level 3 Version 1 has essentially the same structure as 036 * Level 2 Version 4, depicted above, but SBML Level 3 037 * Version 2 allows 038 * containers to contain zero or more of the relevant object, instead of 039 * requiring at least one. As such, libsbml will write out an 040 * otherwise-empty ListOf___ element that has any optional attribute set 041 * (such as 'id' or 'metaid'), that has an optional child (such 042 * as a 'notes' or 'annotation'), or that has attributes or children set 043 * from any SBML Level 3 package, whether or not the ListOf___ has 044 * any other children. 045 <p> 046 * Readers may wonder about the motivations for using the ListOf___ 047 * containers in SBML. A simpler approach in XML might be to place the 048 * components all directly at the top level of the model definition. The 049 * choice made in SBML is to group them within XML elements named after 050 * ListOf<em>Classname</em>, in part because it helps organize the 051 * components. More importantly, the fact that the container classes are 052 * derived from {@link SBase} means that software tools can add information <em>about</em> 053 * the lists themselves into each list container's 'annotation'. 054 <p> 055 * @see ListOfFunctionDefinitions 056 * @see ListOfUnitDefinitions 057 * @see ListOfCompartmentTypes 058 * @see ListOfSpeciesTypes 059 * @see ListOfCompartments 060 * @see ListOfSpecies 061 * @see ListOfParameters 062 * @see ListOfInitialAssignments 063 * @see ListOfRules 064 * @see ListOfConstraints 065 * @see ListOfReactions 066 * @see ListOfEvents 067 */ 068 069public class ListOfSpeciesTypes extends ListOf { 070 private long swigCPtr; 071 072 protected ListOfSpeciesTypes(long cPtr, boolean cMemoryOwn) 073 { 074 super(libsbmlJNI.ListOfSpeciesTypes_SWIGUpcast(cPtr), cMemoryOwn); 075 swigCPtr = cPtr; 076 } 077 078 protected static long getCPtr(ListOfSpeciesTypes obj) 079 { 080 return (obj == null) ? 0 : obj.swigCPtr; 081 } 082 083 protected static long getCPtrAndDisown (ListOfSpeciesTypes 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_ListOfSpeciesTypes(swigCPtr); 105 } 106 swigCPtr = 0; 107 } 108 super.delete(); 109 } 110 111 112/** 113 * Creates a new {@link ListOfSpeciesTypes} object. 114 <p> 115 * The object is constructed such that it is valid for the given SBML 116 * Level and Version combination. 117 <p> 118 * @param level the SBML Level. 119 <p> 120 * @param version the Version within the SBML Level. 121 <p> 122 * <p> 123 * @throws SBMLConstructorException 124 * Thrown if the given <code>level</code> and <code>version</code> combination are invalid 125 * or if this object is incompatible with the given level and version. 126 <p> 127 * <p> 128 * @note Attempting to add an object to an {@link SBMLDocument} having a different 129 * combination of SBML Level, Version and XML namespaces than the object 130 * itself will result in an error at the time a caller attempts to make the 131 * addition. A parent object must have compatible Level, Version and XML 132 * namespaces. (Strictly speaking, a parent may also have more XML 133 * namespaces than a child, but the reverse is not permitted.) The 134 * restriction is necessary to ensure that an SBML model has a consistent 135 * overall structure. This requires callers to manage their objects 136 * carefully, but the benefit is increased flexibility in how models can be 137 * created by permitting callers to create objects bottom-up if desired. In 138 * situations where objects are not yet attached to parents (e.g., 139 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 140 * libSBML determine such things as whether it is valid to assign a 141 * particular value to an attribute. 142 */ public 143 ListOfSpeciesTypes(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 144 this(libsbmlJNI.new_ListOfSpeciesTypes__SWIG_0(level, version), true); 145 } 146 147 148/** 149 * Creates a new {@link ListOfSpeciesTypes} object. 150 <p> 151 * The object is constructed such that it is valid for the SBML Level and 152 * Version combination determined by the {@link SBMLNamespaces} object in 153 * <code>sbmlns</code>. 154 <p> 155 * @param sbmlns an {@link SBMLNamespaces} object that is used to determine the 156 * characteristics of the {@link ListOfSpeciesTypes} object to be created. 157 <p> 158 * <p> 159 * @throws SBMLConstructorException 160 * Thrown if the given <code>sbmlns</code> is inconsistent or incompatible 161 * with this object. 162 <p> 163 * <p> 164 * @note Attempting to add an object to an {@link SBMLDocument} having a different 165 * combination of SBML Level, Version and XML namespaces than the object 166 * itself will result in an error at the time a caller attempts to make the 167 * addition. A parent object must have compatible Level, Version and XML 168 * namespaces. (Strictly speaking, a parent may also have more XML 169 * namespaces than a child, but the reverse is not permitted.) The 170 * restriction is necessary to ensure that an SBML model has a consistent 171 * overall structure. This requires callers to manage their objects 172 * carefully, but the benefit is increased flexibility in how models can be 173 * created by permitting callers to create objects bottom-up if desired. In 174 * situations where objects are not yet attached to parents (e.g., 175 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 176 * libSBML determine such things as whether it is valid to assign a 177 * particular value to an attribute. 178 */ public 179 ListOfSpeciesTypes(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException { 180 this(libsbmlJNI.new_ListOfSpeciesTypes__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true); 181 } 182 183 184/** 185 * Creates and returns a deep copy of this {@link ListOfSpeciesTypes} object. 186 <p> 187 * @return the (deep) copy of this {@link ListOfSpeciesTypes} object. 188 */ public 189 ListOfSpeciesTypes cloneObject() { 190 long cPtr = libsbmlJNI.ListOfSpeciesTypes_cloneObject(swigCPtr, this); 191 return (cPtr == 0) ? null : new ListOfSpeciesTypes(cPtr, true); 192 } 193 194 195/** 196 * Returns the libSBML type code for the objects contained in this {@link ListOf} 197 * (i.e., {@link SpeciesType} objects, if the list is non-empty). 198 <p> 199 * <p> 200 * LibSBML attaches an identifying code to every kind of SBML object. These 201 * are integer constants known as <em>SBML type codes</em>. The names of all 202 * the codes begin with the characters <code>SBML_</code>. 203 * In the Java language interface for libSBML, the 204 * type codes are defined as static integer constants in the interface class 205 * {@link libsbmlConstants}. Note that different Level 3 206 * package plug-ins may use overlapping type codes; to identify the package 207 * to which a given object belongs, call the 208 * <code>{@link SBase#getPackageName()} 209 * </code> 210 * method on the object. 211 <p> 212 * @return the SBML type code for objects contained in this list: 213 * {@link libsbmlConstants#SBML_SPECIES_TYPE SBML_SPECIES_TYPE} (default). 214 <p> 215 * @see #getElementName() 216 * @see #getPackageName() 217 */ public 218 int getItemTypeCode() { 219 return libsbmlJNI.ListOfSpeciesTypes_getItemTypeCode(swigCPtr, this); 220 } 221 222 223/** 224 * Returns the XML element name of this object. 225 <p> 226 * For {@link ListOfSpeciesTypes}, the XML element name is 227 * <code>'listOfSpeciesTypes'.</code> 228 <p> 229 * @return the name of this element, i.e., <code>'listOfSpeciesTypes'.</code> 230 */ public 231 String getElementName() { 232 return libsbmlJNI.ListOfSpeciesTypes_getElementName(swigCPtr, this); 233 } 234 235 236/** 237 * Get a {@link SpeciesType} from the {@link ListOfSpeciesTypes}. 238 <p> 239 * @param n the index number of the {@link SpeciesType} to get. 240 <p> 241 * @return the nth {@link SpeciesType} in this {@link ListOfSpeciesTypes}. 242 <p> 243 * @see #size() 244 */ public 245 SpeciesType get(long n) { 246 long cPtr = libsbmlJNI.ListOfSpeciesTypes_get__SWIG_0(swigCPtr, this, n); 247 return (cPtr == 0) ? null : new SpeciesType(cPtr, false); 248 } 249 250 251/** 252 * Get a {@link SpeciesType} from the {@link ListOfSpeciesTypes} 253 * based on its identifier. 254 <p> 255 * @param sid a string representing the identifier 256 * of the {@link SpeciesType} to get. 257 <p> 258 * @return {@link SpeciesType} in this {@link ListOfSpeciesTypes} 259 * with the given <code>sid</code> or <code>null</code> if no such 260 * {@link SpeciesType} exists. 261 <p> 262 * @see #get(long n) 263 * @see #size() 264 */ public 265 SpeciesType get(String sid) { 266 long cPtr = libsbmlJNI.ListOfSpeciesTypes_get__SWIG_2(swigCPtr, this, sid); 267 return (cPtr == 0) ? null : new SpeciesType(cPtr, false); 268 } 269 270 271/** 272 * Removes the nth item from this {@link ListOfSpeciesTypes} items and returns a pointer to 273 * it. 274 <p> 275 * The caller owns the returned item and is responsible for deleting it. 276 <p> 277 * @param n the index of the item to remove. 278 <p> 279 * @see #size() 280 */ public 281 SpeciesType remove(long n) { 282 long cPtr = libsbmlJNI.ListOfSpeciesTypes_remove__SWIG_0(swigCPtr, this, n); 283 return (cPtr == 0) ? null : new SpeciesType(cPtr, true); 284 } 285 286 287/** 288 * Removes item in this {@link ListOfSpeciesTypes} items with the given identifier. 289 <p> 290 * The caller owns the returned item and is responsible for deleting it. 291 * If none of the items in this list have the identifier <code>sid</code>, then 292 * <code>null</code> is returned. 293 <p> 294 * @param sid the identifier of the item to remove. 295 <p> 296 * @return the item removed. As mentioned above, the caller owns the 297 * returned item. 298 */ public 299 SpeciesType remove(String sid) { 300 long cPtr = libsbmlJNI.ListOfSpeciesTypes_remove__SWIG_1(swigCPtr, this, sid); 301 return (cPtr == 0) ? null : new SpeciesType(cPtr, true); 302 } 303 304}