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