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 Reaction} 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 ListOfReactions extends ListOf { 070 private long swigCPtr; 071 072 protected ListOfReactions(long cPtr, boolean cMemoryOwn) 073 { 074 super(libsbmlJNI.ListOfReactions_SWIGUpcast(cPtr), cMemoryOwn); 075 swigCPtr = cPtr; 076 } 077 078 protected static long getCPtr(ListOfReactions obj) 079 { 080 return (obj == null) ? 0 : obj.swigCPtr; 081 } 082 083 protected static long getCPtrAndDisown (ListOfReactions 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_ListOfReactions(swigCPtr); 105 } 106 swigCPtr = 0; 107 } 108 super.delete(); 109 } 110 111 112/** 113 * Creates a new {@link ListOfReactions} 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 ListOfReactions(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 144 this(libsbmlJNI.new_ListOfReactions__SWIG_0(level, version), true); 145 } 146 147 148/** 149 * Creates a new {@link ListOfReactions} 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 ListOfReactions} 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 ListOfReactions(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException { 180 this(libsbmlJNI.new_ListOfReactions__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true); 181 } 182 183 184/** 185 * Creates and returns a deep copy of this {@link ListOfReactions} object. 186 <p> 187 * @return the (deep) copy of this {@link ListOfReactions} object. 188 */ public 189 ListOfReactions cloneObject() { 190 long cPtr = libsbmlJNI.ListOfReactions_cloneObject(swigCPtr, this); 191 return (cPtr == 0) ? null : new ListOfReactions(cPtr, true); 192 } 193 194 195/** 196 * Returns the libSBML type code for the objects contained in this {@link ListOf} 197 * (i.e., {@link Reaction} 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_REACTION SBML_REACTION} (default). 214 <p> 215 * @see #getElementName() 216 * @see #getPackageName() 217 */ public 218 int getItemTypeCode() { 219 return libsbmlJNI.ListOfReactions_getItemTypeCode(swigCPtr, this); 220 } 221 222 223/** 224 * Returns the XML element name of this object 225 <p> 226 * For {@link ListOfReactions}, the XML element name is <code>'listOfReactions'.</code> 227 <p> 228 * @return the name of this element, i.e., <code>'listOfReactions'.</code> 229 */ public 230 String getElementName() { 231 return libsbmlJNI.ListOfReactions_getElementName(swigCPtr, this); 232 } 233 234 235/** 236 * Get a {@link Reaction} from the {@link ListOfReactions}. 237 <p> 238 * @param n the index number of the {@link Reaction} to get. 239 <p> 240 * @return the nth {@link Reaction} in this {@link ListOfReactions}. 241 <p> 242 * @see #size() 243 */ public 244 Reaction get(long n) { 245 return (Reaction) libsbml.DowncastSBase(libsbmlJNI.ListOfReactions_get__SWIG_0(swigCPtr, this, n), false); 246} 247 248 249/** 250 * Get a {@link Reaction} from the {@link ListOfReactions} based on its identifier. 251 <p> 252 * @param sid a string representing the identifier of the {@link Reaction} to get. 253 <p> 254 * @return {@link Reaction} in this {@link ListOfReactions} with the given <code>sid</code> or 255 * <code>null</code> if no such {@link Reaction} exists. 256 <p> 257 * @see #get(long n) 258 * @see #size() 259 */ public 260 Reaction get(String sid) { 261 return (Reaction) libsbml.DowncastSBase(libsbmlJNI.ListOfReactions_get__SWIG_2(swigCPtr, this, sid), false); 262} 263 264 265/** 266 * Removes the nth item from this {@link ListOfReactions} items and returns a 267 * pointer to it. 268 <p> 269 * The caller owns the returned item and is responsible for deleting it. 270 <p> 271 * @param n the index of the item to remove. 272 <p> 273 * @see #size() 274 */ public 275 Reaction remove(long n) { 276 return (Reaction) libsbml.DowncastSBase(libsbmlJNI.ListOfReactions_remove__SWIG_0(swigCPtr, this, n), true); 277} 278 279 280/** 281 * Removes item in this {@link ListOfReactions} items with the given identifier. 282 <p> 283 * The caller owns the returned item and is responsible for deleting it. 284 * If none of the items in this list have the identifier <code>sid</code>, then 285 * null is returned. 286 <p> 287 * @param sid the identifier of the item to remove. 288 <p> 289 * @return the item removed. As mentioned above, the caller owns the 290 * returned item. 291 */ public 292 Reaction remove(String sid) { 293 return (Reaction) libsbml.DowncastSBase(libsbmlJNI.ListOfReactions_remove__SWIG_1(swigCPtr, this, sid), true); 294} 295 296}