001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 2.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 * <span class="pkg-marker pkg-color-comp"><a href="group__comp.html">comp</a></span> 013 Implementation of the ListOfPorts construct from the 014 * “comp” package. 015 <p> 016 * The {@link ListOfPorts} is a container for the extended 017 * {@link Model} for {@link Port} objects for that {@link Model}. 018 <p> 019 * <p> 020 * The various ListOf___ classes in SBML 021 * are merely containers used for organizing the main components of an SBML 022 * model. In libSBML's implementation, ListOf___ 023 * classes are derived from the 024 * intermediate utility class {@link ListOf}, which 025 * is not defined by the SBML specifications but serves as a useful 026 * programmatic construct. {@link ListOf} is itself is in turn derived from {@link SBase}, 027 * which provides all of the various ListOf___ 028 * classes with common features 029 * defined by the SBML specification, such as 'metaid' attributes and 030 * annotations. 031 <p> 032 * The relationship between the lists and the rest of an SBML model is 033 * illustrated by the following (for SBML Level 2 Version 4): 034 <p> 035 * <figure> 036 <object type="image/svg+xml" data="listof-illustration.svg" class="centered"></object> 037</figure> 038 039 <p> 040 * Readers may wonder about the motivations for using the ListOf___ 041 * containers in SBML. A simpler approach in XML might be to place the 042 * components all directly at the top level of the model definition. The 043 * choice made in SBML is to group them within XML elements named after 044 * ListOf<em>Classname</em>, in part because it helps organize the 045 * components. More importantly, the fact that the container classes are 046 * derived from {@link SBase} means that software tools can add information <em>about</em> 047 * the lists themselves into each list container's 'annotation'. 048 <p> 049 * @see ListOfFunctionDefinitions 050 * @see ListOfUnitDefinitions 051 * @see ListOfCompartmentTypes 052 * @see ListOfSpeciesTypes 053 * @see ListOfCompartments 054 * @see ListOfSpecies 055 * @see ListOfParameters 056 * @see ListOfInitialAssignments 057 * @see ListOfRules 058 * @see ListOfConstraints 059 * @see ListOfReactions 060 * @see ListOfEvents 061 <p> 062 * @see Port 063 * @see ListOfDeletions 064 * @see ListOfExternalModelDefinitions 065 * @see ListOfModelDefinitions 066 * @see ListOfReplacedElements 067 * @see ListOfSubmodels 068 */ 069 070public class ListOfPorts extends ListOf { 071 private long swigCPtr; 072 073 protected ListOfPorts(long cPtr, boolean cMemoryOwn) 074 { 075 super(libsbmlJNI.ListOfPorts_SWIGUpcast(cPtr), cMemoryOwn); 076 swigCPtr = cPtr; 077 } 078 079 protected static long getCPtr(ListOfPorts obj) 080 { 081 return (obj == null) ? 0 : obj.swigCPtr; 082 } 083 084 protected static long getCPtrAndDisown (ListOfPorts obj) 085 { 086 long ptr = 0; 087 088 if (obj != null) 089 { 090 ptr = obj.swigCPtr; 091 obj.swigCMemOwn = false; 092 } 093 094 return ptr; 095 } 096 097 protected void finalize() { 098 delete(); 099 } 100 101 public synchronized void delete() { 102 if (swigCPtr != 0) { 103 if (swigCMemOwn) { 104 swigCMemOwn = false; 105 libsbmlJNI.delete_ListOfPorts(swigCPtr); 106 } 107 swigCPtr = 0; 108 } 109 super.delete(); 110 } 111 112 113/** 114 * Creates and returns a deep copy of this {@link ListOfPorts} object. 115 <p> 116 * @return a (deep) copy of this {@link ListOfPorts}. 117 */ public 118 ListOfPorts cloneObject() { 119 long cPtr = libsbmlJNI.ListOfPorts_cloneObject(swigCPtr, this); 120 return (cPtr == 0) ? null : new ListOfPorts(cPtr, true); 121 } 122 123 124/** 125 * Creates a new {@link ListOfPorts} with the given level, version, and package version. 126 <p> 127 * @param level the SBML Level 128 * @param version the Version within the SBML Level 129 * @param pkgVersion the version of the package 130 */ public 131 ListOfPorts(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException { 132 this(libsbmlJNI.new_ListOfPorts__SWIG_0(level, version, pkgVersion), true); 133 } 134 135 136/** 137 * Creates a new {@link ListOfPorts} with the given level, version, and package version. 138 <p> 139 * @param level the SBML Level 140 * @param version the Version within the SBML Level 141 * @param pkgVersion the version of the package 142 */ public 143 ListOfPorts(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 144 this(libsbmlJNI.new_ListOfPorts__SWIG_1(level, version), true); 145 } 146 147 148/** 149 * Creates a new {@link ListOfPorts} with the given level, version, and package version. 150 <p> 151 * @param level the SBML Level 152 * @param version the Version within the SBML Level 153 * @param pkgVersion the version of the package 154 */ public 155 ListOfPorts(long level) throws org.sbml.libsbml.SBMLConstructorException { 156 this(libsbmlJNI.new_ListOfPorts__SWIG_2(level), true); 157 } 158 159 160/** 161 * Creates a new {@link ListOfPorts} with the given level, version, and package version. 162 <p> 163 * @param level the SBML Level 164 * @param version the Version within the SBML Level 165 * @param pkgVersion the version of the package 166 */ public 167 ListOfPorts() throws org.sbml.libsbml.SBMLConstructorException { 168 this(libsbmlJNI.new_ListOfPorts__SWIG_3(), true); 169 } 170 171 172/** 173 * Creates a new {@link ListOfPorts} with the given {@link CompPkgNamespaces} object. 174 <p> 175 * @param compns the namespace to use 176 */ public 177 ListOfPorts(CompPkgNamespaces compns) throws org.sbml.libsbml.SBMLConstructorException { 178 this(libsbmlJNI.new_ListOfPorts__SWIG_4(CompPkgNamespaces.getCPtr(compns), compns), true); 179 } 180 181 182/** 183 * Get a {@link Port} from the {@link ListOfPorts}. 184 <p> 185 * @param n the index number of the {@link Port} to get. 186 <p> 187 * @return the nth {@link Port} in this {@link ListOfPorts}. 188 <p> 189 * @see #size() 190 */ public 191 SBase get(long n) { 192 long cPtr = libsbmlJNI.ListOfPorts_get__SWIG_0(swigCPtr, this, n); 193 return (cPtr == 0) ? null : new Port(cPtr, false); 194 } 195 196 197/** 198 * Get a {@link Port} from the {@link ListOfPorts} 199 * based on its identifier. 200 <p> 201 * @param sid a string representing the identifier 202 * of the {@link Port} to get. 203 <p> 204 * @return {@link Port} in this {@link ListOfPorts} 205 * with the given <code>sid</code> or <code>null</code> if no such 206 * Member exists. 207 <p> 208 * @see #get(long n) 209 * @see #size() 210 */ public 211 Port get(String sid) { 212 long cPtr = libsbmlJNI.ListOfPorts_get__SWIG_2(swigCPtr, this, sid); 213 return (cPtr == 0) ? null : new Port(cPtr, false); 214 } 215 216 217/** 218 * Removes an item from this {@link ListOfPorts} items based on the identifier and 219 * returns a pointer to it. 220 <p> 221 * The caller owns the returned item and is responsible for deleting it. 222 <p> 223 * @param sid string representing the id of the {@link Port} to remove 224 <p> 225 * @see #size() 226 */ public 227 Port remove(String sid) { 228 long cPtr = libsbmlJNI.ListOfPorts_remove__SWIG_0(swigCPtr, this, sid); 229 return (cPtr == 0) ? null : new Port(cPtr, true); 230 } 231 232 233/** 234 * Removes the nth item from this {@link ListOfPorts} items and returns a pointer 235 * to it. 236 <p> 237 * The caller owns the returned item and is responsible for deleting it. 238 <p> 239 * @param n the index of the item to remove 240 <p> 241 * @see #size() 242 */ public 243 SBase remove(long n) { 244 long cPtr = libsbmlJNI.ListOfPorts_remove__SWIG_1(swigCPtr, this, n); 245 return (cPtr == 0) ? null : new Port(cPtr, true); 246 } 247 248 249/** 250 * Returns the libSBML type code for the objects contained in this {@link ListOf} 251 * (i.e., {@link Port} objects, if the list is non-empty). 252 <p> 253 * <p> 254 * LibSBML attaches an identifying code to every kind of SBML object. These 255 * are integer constants known as <em>SBML type codes</em>. The names of all 256 * the codes begin with the characters “<code>SBML_</code>”. 257 * In the Java language interface for libSBML, the 258 * type codes are defined as static integer constants in the interface class 259 * {@link libsbmlConstants}. Note that different Level 3 260 * package plug-ins may use overlapping type codes; to identify the package 261 * to which a given object belongs, call the <code>getPackageName()</code> 262 * method on the object. 263 <p> 264 * @return the SBML type code for objects contained in this list: 265 * {@link libsbmlConstants#SBML_COMP_PORT SBML_COMP_PORT} (default). 266 <p> 267 * @see #getElementName() 268 * @see #getPackageName() 269 */ public 270 int getItemTypeCode() { 271 return libsbmlJNI.ListOfPorts_getItemTypeCode(swigCPtr, this); 272 } 273 274 275/** 276 * Returns the XML element name of 277 * this SBML object. 278 <p> 279 * @return the string of the name of this element. 280 */ public 281 String getElementName() { 282 return libsbmlJNI.ListOfPorts_getElementName(swigCPtr, this); 283 } 284 285 286/** 287 * Returns the first child element found that has the given <code>id</code> in the 288 * model-wide SId namespace, or <code>null</code> if no such object is found. Since the 289 * id of {@link Port} objects are in the PortSId namespace, no {@link Port} object is 290 * returned by this function. 291 <p> 292 * @param id string representing the id of objects to find 293 <p> 294 * @return a pointer to the {@link SBase} element with the given <code>id</code>. 295 */ public 296 SBase getElementBySId(String id) { 297 return libsbml.DowncastSBase(libsbmlJNI.ListOfPorts_getElementBySId(swigCPtr, this, id), false); 298} 299 300}