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 * Parent class for the various SBML 'ListOfXYZ' classes. 014 * <p> 015 * <p style='color: #777; font-style: italic'> 016This class of objects is defined by libSBML only and has no direct 017equivalent in terms of SBML components. This class is not prescribed by 018the SBML specifications, although it is used to implement features 019defined in SBML. 020</p> 021 022 * <p> 023 * SBML defines various ListOf___ classes that are containers used for 024 * organizing the main components of an SBML model. All are derived from 025 * the abstract class {@link SBase}, and inherit the attributes and subelements of 026 * {@link SBase}, such as 'metaid' as and 'annotation'. The ListOf___ classes do 027 * not add any attributes of their own. 028 * <p> 029 * The {@link ListOf} class in libSBML is a utility class that serves as the parent 030 * class for implementing the ListOf__ classes. It provides methods for 031 * working generically with the various SBML lists of objects in a program. 032 * LibSBML uses this separate list class rather than ordinary 033 * Java lists, 034 * so that it can provide the methods and features associated with {@link SBase}. 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 ListOf extends SBase { 051 private long swigCPtr; 052 053 protected ListOf(long cPtr, boolean cMemoryOwn) 054 { 055 super(libsbmlJNI.ListOf_SWIGUpcast(cPtr), cMemoryOwn); 056 swigCPtr = cPtr; 057 } 058 059 protected static long getCPtr(ListOf obj) 060 { 061 return (obj == null) ? 0 : obj.swigCPtr; 062 } 063 064 protected static long getCPtrAndDisown (ListOf 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_ListOf(swigCPtr); 086 } 087 swigCPtr = 0; 088 } 089 super.delete(); 090 } 091 092 093/** 094 * Creates a new {@link ListOf} object. 095 * <p> 096 * @param level the SBML Level; if not assigned, defaults to the 097 * value of SBML_DEFAULT_LEVEL. 098 * <p> 099 * @param version the Version within the SBML Level; if not assigned, 100 * defaults to the value of SBML_DEFAULT_VERSION. 101 * <p> 102 * <!-- Don't remove the leading </dl> below. It's a hack for javadoc. --> 103</dl><dl class='docnote'><dt><b>Documentation note:</b></dt><dd> 104The native C++ implementation of this method defines a default argument 105value. In the documentation generated for different libSBML language 106bindings, you may or may not see corresponding arguments in the method 107declarations. For example, in Java and C#, a default argument is handled by 108declaring two separate methods, with one of them having the argument and 109the other one lacking the argument. However, the libSBML documentation will 110be <em>identical</em> for both methods. Consequently, if you are reading 111this and do not see an argument even though one is described, please look 112for descriptions of other variants of this method near where this one 113appears in the documentation. 114</dd></dl> 115 116 */ public 117 ListOf(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 118 this(libsbmlJNI.new_ListOf__SWIG_0(level, version), true); 119 } 120 121 122/** 123 * Creates a new {@link ListOf} object. 124 * <p> 125 * @param level the SBML Level; if not assigned, defaults to the 126 * value of SBML_DEFAULT_LEVEL. 127 * <p> 128 * @param version the Version within the SBML Level; if not assigned, 129 * defaults to the value of SBML_DEFAULT_VERSION. 130 * <p> 131 * <!-- Don't remove the leading </dl> below. It's a hack for javadoc. --> 132</dl><dl class='docnote'><dt><b>Documentation note:</b></dt><dd> 133The native C++ implementation of this method defines a default argument 134value. In the documentation generated for different libSBML language 135bindings, you may or may not see corresponding arguments in the method 136declarations. For example, in Java and C#, a default argument is handled by 137declaring two separate methods, with one of them having the argument and 138the other one lacking the argument. However, the libSBML documentation will 139be <em>identical</em> for both methods. Consequently, if you are reading 140this and do not see an argument even though one is described, please look 141for descriptions of other variants of this method near where this one 142appears in the documentation. 143</dd></dl> 144 145 */ public 146 ListOf(long level) throws org.sbml.libsbml.SBMLConstructorException { 147 this(libsbmlJNI.new_ListOf__SWIG_1(level), true); 148 } 149 150 151/** 152 * Creates a new {@link ListOf} object. 153 * <p> 154 * @param level the SBML Level; if not assigned, defaults to the 155 * value of SBML_DEFAULT_LEVEL. 156 * <p> 157 * @param version the Version within the SBML Level; if not assigned, 158 * defaults to the value of SBML_DEFAULT_VERSION. 159 * <p> 160 * <!-- Don't remove the leading </dl> below. It's a hack for javadoc. --> 161</dl><dl class='docnote'><dt><b>Documentation note:</b></dt><dd> 162The native C++ implementation of this method defines a default argument 163value. In the documentation generated for different libSBML language 164bindings, you may or may not see corresponding arguments in the method 165declarations. For example, in Java and C#, a default argument is handled by 166declaring two separate methods, with one of them having the argument and 167the other one lacking the argument. However, the libSBML documentation will 168be <em>identical</em> for both methods. Consequently, if you are reading 169this and do not see an argument even though one is described, please look 170for descriptions of other variants of this method near where this one 171appears in the documentation. 172</dd></dl> 173 174 */ public 175 ListOf() throws org.sbml.libsbml.SBMLConstructorException { 176 this(libsbmlJNI.new_ListOf__SWIG_2(), true); 177 } 178 179 180/** 181 * Creates a new {@link ListOf} with {@link SBMLNamespaces} object. 182 * <p> 183 * @param sbmlns the set of namespaces that this {@link ListOf} should contain. 184 */ public 185 ListOf(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException { 186 this(libsbmlJNI.new_ListOf__SWIG_3(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true); 187 } 188 189 190/** 191 * Copy constructor; creates a copy of this {@link ListOf}. 192 * <p> 193 * @param orig the {@link ListOf} instance to copy. 194 */ public 195 ListOf(ListOf orig) throws org.sbml.libsbml.SBMLConstructorException { 196 this(libsbmlJNI.new_ListOf__SWIG_4(ListOf.getCPtr(orig), orig), true); 197 } 198 199 200/** 201 * Creates and returns a deep copy of this {@link ListOf}. 202 * <p> 203 * @return a (deep) copy of this {@link ListOf}. 204 */ public 205 ListOf cloneObject() { 206 long cPtr = libsbmlJNI.ListOf_cloneObject(swigCPtr, this); 207 return (cPtr == 0) ? null : new ListOf(cPtr, true); 208 } 209 210 211/** 212 * Adds item to the end of this {@link ListOf}. 213 * <p> 214 * This variant of the method makes a clone of the <code>item</code> handed to it. 215 * This means that when the {@link ListOf} is destroyed, the original items will 216 * not be destroyed. 217 * <p> 218 * @param item the item to be added to the list. 219 * <p> 220 * @see #appendAndOwn(SBase item) 221 */ public 222 int append(SBase item) { 223 return libsbmlJNI.ListOf_append(swigCPtr, this, SBase.getCPtr(item), item); 224 } 225 226 227/** 228 * Adds item to the end of this {@link ListOf}. 229 * <p> 230 * This variant of the method does not clone the <code>item</code> handed to it; 231 * instead, it assumes ownership of it. This means that when the {@link ListOf} 232 * is destroyed, the item will be destroyed along with it. 233 * <p> 234 * @param item the item to be added to the list. 235 * <p> 236 * @see #append(SBase item) 237 */ public 238 int appendAndOwn(SBase item) { 239 return libsbmlJNI.ListOf_appendAndOwn(swigCPtr, this, SBase.getCPtrAndDisown(item), item); 240 } 241 242 243/** 244 * Adds a clone of all items in the provided {@link ListOf} to this object. This means that when this {@link ListOf} is destroyed, the original items will not be destroyed. 245 * <p> 246 * @param list A list of items to be added. 247 * <p> 248 * @see #append(SBase item) 249 */ public 250 int appendFrom(ListOf list) { 251 return libsbmlJNI.ListOf_appendFrom(swigCPtr, this, ListOf.getCPtr(list), list); 252 } 253 254 255/** 256 * Inserts the item at the given position of this {@link ListOf} 257 * <p> 258 * This variant of the method makes a clone of the <code>item</code> handet to it. 259 * This means that when the {@link ListOf} is destroyed, the original items will 260 * not be destroyed. 261 * <p> 262 * @param location the location where to insert the item 263 * @param item the item to be inserted to the list 264 * <p> 265 * @see #insertAndOwn(int location, SBase item) 266 */ public 267 int insert(int location, SBase item) { 268 return libsbmlJNI.ListOf_insert(swigCPtr, this, location, SBase.getCPtr(item), item); 269 } 270 271 272/** 273 * Inserts the item at the given position of this {@link ListOf} 274 * <p> 275 * This variant of the method makes a clone of the <code>item</code> handet to it. 276 * This means that when the {@link ListOf} is destroyed, the original items will 277 * not be destroyed. 278 * <p> 279 * @param location the location where to insert the item 280 * @param item the item to be inserted to the list 281 * <p> 282 * @see #insert(int location, SBase item) 283 */ public 284 int insertAndOwn(int location, SBase item) { 285 return libsbmlJNI.ListOf_insertAndOwn(swigCPtr, this, location, SBase.getCPtrAndDisown(item), item); 286 } 287 288 289/** 290 * Get an item from the list. 291 * <p> 292 * @param n the index number of the item to get. 293 * <p> 294 * @return the nth item in this {@link ListOf} items. 295 * <p> 296 * @see #size() 297 */ public 298 SBase get(long n) { 299 return libsbml.DowncastSBase(libsbmlJNI.ListOf_get__SWIG_0(swigCPtr, this, n), false); 300} 301 302 303/** 304 * Returns the first child element found that has the given <code>id</code> in the model-wide SId namespace, or <code>null</code> if no such object is found. 305 * <p> 306 * @param id string representing the id of objects to find 307 * <p> 308 * @return pointer to the first element found with the given <code>id</code>. 309 */ public 310 SBase getElementBySId(String id) { 311 return libsbml.DowncastSBase(libsbmlJNI.ListOf_getElementBySId(swigCPtr, this, id), false); 312} 313 314 315/** 316 * Returns the first child element it can find with the given <code>metaid</code>, or <code>null</code> if no such object is found. 317 * <p> 318 * @param metaid string representing the metaid of objects to find 319 * <p> 320 * @return pointer to the first element found with the given <code>metaid</code>. 321 */ public 322 SBase getElementByMetaId(String metaid) { 323 return libsbml.DowncastSBase(libsbmlJNI.ListOf_getElementByMetaId(swigCPtr, this, metaid), false); 324} 325 326 327/** 328 * Removes all items in this {@link ListOf} object. 329 * <p> 330 * If parameter <code>doDelete</code> is <code>true</code> (default), all items in this {@link ListOf} 331 * object are deleted and cleared, and thus the caller doesn't have to 332 * delete those items. Otherwise, all items are just cleared from this 333 * {@link ListOf} object and the caller is responsible for deleting all items. (In 334 * that case, pointers to all items should be stored elsewhere before 335 * calling this function.) 336 * <p> 337 * @param doDelete if <code>true</code> (default), all items are deleted and cleared. 338 * Otherwise, all items are just cleared and not deleted. 339 * <p> 340 * <!-- Don't remove the leading </dl> below. It's a hack for javadoc. --> 341</dl><dl class='docnote'><dt><b>Documentation note:</b></dt><dd> 342The native C++ implementation of this method defines a default argument 343value. In the documentation generated for different libSBML language 344bindings, you may or may not see corresponding arguments in the method 345declarations. For example, in Java and C#, a default argument is handled by 346declaring two separate methods, with one of them having the argument and 347the other one lacking the argument. However, the libSBML documentation will 348be <em>identical</em> for both methods. Consequently, if you are reading 349this and do not see an argument even though one is described, please look 350for descriptions of other variants of this method near where this one 351appears in the documentation. 352</dd></dl> 353 354 */ public 355 void clear(boolean doDelete) { 356 libsbmlJNI.ListOf_clear__SWIG_0(swigCPtr, this, doDelete); 357 } 358 359 360/** 361 * Removes all items in this {@link ListOf} object. 362 * <p> 363 * If parameter <code>doDelete</code> is <code>true</code> (default), all items in this {@link ListOf} 364 * object are deleted and cleared, and thus the caller doesn't have to 365 * delete those items. Otherwise, all items are just cleared from this 366 * {@link ListOf} object and the caller is responsible for deleting all items. (In 367 * that case, pointers to all items should be stored elsewhere before 368 * calling this function.) 369 * <p> 370 * @param doDelete if <code>true</code> (default), all items are deleted and cleared. 371 * Otherwise, all items are just cleared and not deleted. 372 * <p> 373 * <!-- Don't remove the leading </dl> below. It's a hack for javadoc. --> 374</dl><dl class='docnote'><dt><b>Documentation note:</b></dt><dd> 375The native C++ implementation of this method defines a default argument 376value. In the documentation generated for different libSBML language 377bindings, you may or may not see corresponding arguments in the method 378declarations. For example, in Java and C#, a default argument is handled by 379declaring two separate methods, with one of them having the argument and 380the other one lacking the argument. However, the libSBML documentation will 381be <em>identical</em> for both methods. Consequently, if you are reading 382this and do not see an argument even though one is described, please look 383for descriptions of other variants of this method near where this one 384appears in the documentation. 385</dd></dl> 386 387 */ public 388 void clear() { 389 libsbmlJNI.ListOf_clear__SWIG_1(swigCPtr, this); 390 } 391 392 393/** 394 * Because {@link ListOf} objects typically live as object children of their parent object and not as pointer children, this function clears itself, but does not attempt to do anything else. If a particular {@link ListOf} subclass does indeed exist as a pointer only, this function will need to be overridden. 395 * <p> 396 * @return integer value indicating success/failure of the 397 * function. The possible values 398 * returned by this function are: 399 * <ul> 400 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 401 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 402 * </ul> 403 */ public 404 int removeFromParentAndDelete() { 405 return libsbmlJNI.ListOf_removeFromParentAndDelete(swigCPtr, this); 406 } 407 408 409/** 410 * Removes the <em>n</em>th item from this {@link ListOf} items and returns a 411 * pointer to it. 412 * <p> 413 * The caller owns the returned item and is responsible for deleting it. 414 * <p> 415 * @param n the index of the item to remove 416 * <p> 417 * @see #size() 418 */ public 419 SBase remove(long n) { 420 return libsbml.DowncastSBase(libsbmlJNI.ListOf_remove(swigCPtr, this, n), true); 421} 422 423 424/** 425 * Get the size of this {@link ListOf}. 426 * <p> 427 * @return the number of items in this {@link ListOf} items. 428 */ public 429 long size() { 430 return libsbmlJNI.ListOf_size(swigCPtr, this); 431 } 432 433 434/** 435 * Sets this SBML object to child SBML objects (if any). 436 * (Creates a child-parent relationship by the parent) 437 * <p> 438 * Subclasses must override this function if they define 439 * one ore more child elements. 440 * Basically, this function needs to be called in 441 * constructor, copy constructor and assignment operator. 442 * <p> 443 * @see setSBMLDocument 444 * @see enablePackageInternal 445 * @internal 446 */ public 447 void connectToChild() { 448 libsbmlJNI.ListOf_connectToChild(swigCPtr, this); 449 } 450 451 452/** 453 * Returns the libSBML type code for this object, namely, 454 * <code>SBML_LIST_OF.</code> 455 * <p> 456 * LibSBML attaches an identifying code to every 457 * kind of SBML object. These are known as <em>SBML type codes</em>. In 458 * other languages, the set of type codes is stored in an enumeration; in 459 * the Java language interface for libSBML, the type codes are defined as 460 * static integer constants in the interface class {@link 461 * libsbmlConstants}. The names of the type codes all begin with the 462 * characters <code>SBML_.</code> 463 * <p> 464 * @return the SBML type code for this object, or {@link libsbmlConstants#SBML_UNKNOWN SBML_UNKNOWN} (default). 465 * <p> 466 * @see #getElementName() 467 */ public 468 int getTypeCode() { 469 return libsbmlJNI.ListOf_getTypeCode(swigCPtr, this); 470 } 471 472 473/** 474 * Get the type code of the objects contained in this {@link ListOf}. 475 * <p> 476 * LibSBML attaches an identifying code to every 477 * kind of SBML object. These are known as <em>SBML type codes</em>. In 478 * other languages, the set of type codes is stored in an enumeration; in 479 * the Java language interface for libSBML, the type codes are defined as 480 * static integer constants in the interface class {@link 481 * libsbmlConstants}. The names of the type codes all begin with the 482 * characters <code>SBML_.</code> 483 * <p> 484 * @return the SBML type code for the objects contained in this {@link ListOf} 485 * instance, or {@link libsbmlConstants#SBML_UNKNOWN SBML_UNKNOWN} (default). 486 */ public 487 int getItemTypeCode() { 488 return libsbmlJNI.ListOf_getItemTypeCode(swigCPtr, this); 489 } 490 491 492/** 493 * Returns the XML element name of this object, which for {@link ListOf}, is 494 * always <code>'listOf'.</code> 495 * <p> 496 * @return the XML name of this element. 497 */ public 498 String getElementName() { 499 return libsbmlJNI.ListOf_getElementName(swigCPtr, this); 500 } 501 502 503/** 504 * Enables/Disables the given package with this element and child 505 * elements (if any). 506 * (This is an internal implementation for enablePackage function) 507 * <p> 508 * @note Subclasses of the SBML Core package in which one or more child 509 * elements are defined must override this function. 510 * @internal 511 */ public 512 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) { 513 libsbmlJNI.ListOf_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag); 514 } 515 516}