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 011public class ListOfPorts extends ListOf { 012 private long swigCPtr; 013 014 protected ListOfPorts(long cPtr, boolean cMemoryOwn) 015 { 016 super(libsbmlJNI.ListOfPorts_SWIGUpcast(cPtr), cMemoryOwn); 017 swigCPtr = cPtr; 018 } 019 020 protected static long getCPtr(ListOfPorts obj) 021 { 022 return (obj == null) ? 0 : obj.swigCPtr; 023 } 024 025 protected static long getCPtrAndDisown (ListOfPorts obj) 026 { 027 long ptr = 0; 028 029 if (obj != null) 030 { 031 ptr = obj.swigCPtr; 032 obj.swigCMemOwn = false; 033 } 034 035 return ptr; 036 } 037 038 protected void finalize() { 039 delete(); 040 } 041 042 public synchronized void delete() { 043 if (swigCPtr != 0) { 044 if (swigCMemOwn) { 045 swigCMemOwn = false; 046 libsbmlJNI.delete_ListOfPorts(swigCPtr); 047 } 048 swigCPtr = 0; 049 } 050 super.delete(); 051 } 052 053 054/** 055 * Creates and returns a deep copy of this {@link ListOf}. 056 * <p> 057 * @return a (deep) copy of this {@link ListOf}. 058 */ public 059 ListOfPorts cloneObject() { 060 long cPtr = libsbmlJNI.ListOfPorts_cloneObject(swigCPtr, this); 061 return (cPtr == 0) ? null : new ListOfPorts(cPtr, true); 062 } 063 064 public ListOfPorts(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException { 065 this(libsbmlJNI.new_ListOfPorts__SWIG_0(level, version, pkgVersion), true); 066 } 067 068 public ListOfPorts(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 069 this(libsbmlJNI.new_ListOfPorts__SWIG_1(level, version), true); 070 } 071 072 public ListOfPorts(long level) throws org.sbml.libsbml.SBMLConstructorException { 073 this(libsbmlJNI.new_ListOfPorts__SWIG_2(level), true); 074 } 075 076 public ListOfPorts() throws org.sbml.libsbml.SBMLConstructorException { 077 this(libsbmlJNI.new_ListOfPorts__SWIG_3(), true); 078 } 079 080 public ListOfPorts(CompPkgNamespaces compns) throws org.sbml.libsbml.SBMLConstructorException { 081 this(libsbmlJNI.new_ListOfPorts__SWIG_4(CompPkgNamespaces.getCPtr(compns), compns), true); 082 } 083 084 085/** 086 * Get an item from the list. 087 * <p> 088 * @param n the index number of the item to get. 089 * <p> 090 * @return the nth item in this {@link ListOf} items. 091 * <p> 092 * @see #size() 093 */ public 094 SBase get(long n) { 095 long cPtr = libsbmlJNI.ListOfPorts_get__SWIG_0(swigCPtr, this, n); 096 return (cPtr == 0) ? null : new Port(cPtr, false); 097 } 098 099 100/** 101 * Get an item from the list based on its identifier. 102 * <p> 103 * @param sid a string representing the the identifier of the item to get. 104 * <p> 105 * @return item in this {@link ListOf} items with the given <code>sid</code> or <code>null</code> if no such 106 * item exists. 107 * <p> 108 * @see #get(long n) 109 * @see #size() 110 */ public 111 Port get(String sid) { 112 long cPtr = libsbmlJNI.ListOfPorts_get__SWIG_2(swigCPtr, this, sid); 113 return (cPtr == 0) ? null : new Port(cPtr, false); 114 } 115 116 117/** 118 * Removes item in this {@link ListOf} items with the given identifier. 119 * <p> 120 * The caller owns the returned item and is responsible for deleting it. 121 * If none of the items in this list have the identifier <code>sid</code>, then 122 * <code>null</code> is returned. 123 * <p> 124 * @param sid the identifier of the item to remove 125 * <p> 126 * @return the item removed. As mentioned above, the caller owns the 127 * returned item. 128 */ public 129 Port remove(String sid) { 130 long cPtr = libsbmlJNI.ListOfPorts_remove__SWIG_0(swigCPtr, this, sid); 131 return (cPtr == 0) ? null : new Port(cPtr, true); 132 } 133 134 135/** 136 * Removes the <em>n</em>th item from this {@link ListOf} items and returns a 137 * pointer to it. 138 * <p> 139 * The caller owns the returned item and is responsible for deleting it. 140 * <p> 141 * @param n the index of the item to remove 142 * <p> 143 * @see #size() 144 */ public 145 SBase remove(long n) { 146 long cPtr = libsbmlJNI.ListOfPorts_remove__SWIG_1(swigCPtr, this, n); 147 return (cPtr == 0) ? null : new Port(cPtr, true); 148 } 149 150 151/** 152 * Get the type code of the objects contained in this {@link ListOf}. 153 * <p> 154 * LibSBML attaches an identifying code to every 155 * kind of SBML object. These are known as <em>SBML type codes</em>. In 156 * other languages, the set of type codes is stored in an enumeration; in 157 * the Java language interface for libSBML, the type codes are defined as 158 * static integer constants in the interface class {@link 159 * libsbmlConstants}. The names of the type codes all begin with the 160 * characters <code>SBML_.</code> 161 * <p> 162 * @return the SBML type code for the objects contained in this {@link ListOf} 163 * instance, or {@link libsbmlConstants#SBML_UNKNOWN SBML_UNKNOWN} (default). 164 */ public 165 int getItemTypeCode() { 166 return libsbmlJNI.ListOfPorts_getItemTypeCode(swigCPtr, this); 167 } 168 169 170/** 171 * Returns the XML element name of this object, which for {@link ListOf}, is 172 * always <code>'listOf'.</code> 173 * <p> 174 * @return the XML name of this element. 175 */ public 176 String getElementName() { 177 return libsbmlJNI.ListOfPorts_getElementName(swigCPtr, this); 178 } 179 180 181/** 182 * 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. 183 * <p> 184 * @param id string representing the id of objects to find 185 * <p> 186 * @return pointer to the first element found with the given <code>id</code>. 187 */ public 188 SBase getElementBySId(String id) { 189 return libsbml.DowncastSBase(libsbmlJNI.ListOfPorts_getElementBySId(swigCPtr, this, id), false); 190} 191 192}