001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.7 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 An interface to be used in composition. 014 <p> 015 * The {@link Port} class was introduced by the SBML Level 3 016 * 'Hierarchical Model Composition' package 017 * (“comp”) to allow a {@link Model} to define a standard interface 018 * between it and other models that might use it as a submodel. It derives 019 * from the {@link SBaseRef} class, and the elements defined there refer to elements 020 * in the same parent {@link Model} as the {@link Port} object. A {@link Port} object instance 021 * therefore uses those attributes to define a port for a component in a 022 * model. When other {@link SBaseRef} or {@link SBaseRef}-derived classes refer to a {@link Port} 023 * object using a 'portRef' attribute, the element being referenced is the 024 * element the {@link Port} object itself points to. 025 <p> 026 * In the present formulation of the Hierarchical Model Composition 027 * package, the use of ports is not enforced, nor is there any 028 * mechanism to restrict which ports may be used in what ways—they are 029 * only an advisory construct. Future versions of this SBML package may 030 * provide additional functionality to support explicit restrictions on 031 * port use. For the present definition of Hierarchical Model Composition, 032 * users of models containing ports are encouraged to respect the modeler's 033 * intention in defining ports, and use the port definitions to interact 034 * with components through their ports (when they have ports defined) 035 * rather than interact directly with the components. 036 <p> 037 * The required attribute 'id' is used to give an identifier to a 038 * {@link Port} object so that other objects can refer to it. The attribute has 039 * type PortSId and is essentially identical to the SBML 040 * primitive type SId, except that its namespace is limited to 041 * the identifiers of {@link Port} objects defined within a {@link Model} object. In 042 * parallel, the PortSId type has a companion type, 043 * PortSIdRef, that corresponds to the SBML primitive type 044 * SIdRef; the value space of PortSIdRef is limited 045 * to PortSId values. 046 */ 047 048public class Port extends SBaseRef { 049 private long swigCPtr; 050 051 protected Port(long cPtr, boolean cMemoryOwn) 052 { 053 super(libsbmlJNI.Port_SWIGUpcast(cPtr), cMemoryOwn); 054 swigCPtr = cPtr; 055 } 056 057 protected static long getCPtr(Port obj) 058 { 059 return (obj == null) ? 0 : obj.swigCPtr; 060 } 061 062 protected static long getCPtrAndDisown (Port obj) 063 { 064 long ptr = 0; 065 066 if (obj != null) 067 { 068 ptr = obj.swigCPtr; 069 obj.swigCMemOwn = false; 070 } 071 072 return ptr; 073 } 074 075 protected void finalize() { 076 delete(); 077 } 078 079 public synchronized void delete() { 080 if (swigCPtr != 0) { 081 if (swigCMemOwn) { 082 swigCMemOwn = false; 083 libsbmlJNI.delete_Port(swigCPtr); 084 } 085 swigCPtr = 0; 086 } 087 super.delete(); 088 } 089 090 091/** 092 * Creates a new {@link Port} with the given level, version, and package version. 093 <p> 094 * @param level the SBML Level 095 * @param version the Version within the SBML Level 096 * @param pkgVersion the version of the package 097 */ public 098 Port(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException { 099 this(libsbmlJNI.new_Port__SWIG_0(level, version, pkgVersion), true); 100 } 101 102 103/** 104 * Creates a new {@link Port} with the given level, version, and package version. 105 <p> 106 * @param level the SBML Level 107 * @param version the Version within the SBML Level 108 * @param pkgVersion the version of the package 109 */ public 110 Port(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 111 this(libsbmlJNI.new_Port__SWIG_1(level, version), true); 112 } 113 114 115/** 116 * Creates a new {@link Port} with the given level, version, and package version. 117 <p> 118 * @param level the SBML Level 119 * @param version the Version within the SBML Level 120 * @param pkgVersion the version of the package 121 */ public 122 Port(long level) throws org.sbml.libsbml.SBMLConstructorException { 123 this(libsbmlJNI.new_Port__SWIG_2(level), true); 124 } 125 126 127/** 128 * Creates a new {@link Port} with the given level, version, and package version. 129 <p> 130 * @param level the SBML Level 131 * @param version the Version within the SBML Level 132 * @param pkgVersion the version of the package 133 */ public 134 Port() throws org.sbml.libsbml.SBMLConstructorException { 135 this(libsbmlJNI.new_Port__SWIG_3(), true); 136 } 137 138 139/** 140 * Creates a new {@link Port} with the given {@link CompPkgNamespaces} object. 141 <p> 142 * @param compns the namespace to use 143 */ public 144 Port(CompPkgNamespaces compns) throws org.sbml.libsbml.SBMLConstructorException { 145 this(libsbmlJNI.new_Port__SWIG_4(CompPkgNamespaces.getCPtr(compns), compns), true); 146 } 147 148 149/** 150 * Copy constructor. 151 */ public 152 Port(Port source) throws org.sbml.libsbml.SBMLConstructorException { 153 this(libsbmlJNI.new_Port__SWIG_5(Port.getCPtr(source), source), true); 154 } 155 156 157/** 158 * Creates and returns a deep copy of this {@link Port} object. 159 <p> 160 * @return a (deep) copy of this {@link Port} object 161 */ public 162 SBase cloneObject() { 163 long cPtr = libsbmlJNI.Port_cloneObject(swigCPtr, this); 164 return (cPtr == 0) ? null : new Port(cPtr, true); 165 } 166 167 168/** 169 * Returns the value of the 'id' attribute of this {@link Port}. 170 <p> 171 * @return the value of the 'id' attribute of this {@link Port}. 172 */ public 173 String getId() { 174 return libsbmlJNI.Port_getId(swigCPtr, this); 175 } 176 177 178/** 179 * Predicate returning <code>true</code> or <code>false</code> depending on whether this 180 * {@link Port}'s 'id' attribute has been set. 181 <p> 182 * @return <code>true</code> if this {@link Port}'s 'id' attribute has been set, 183 * otherwise <code>false</code> is returned. 184 */ public 185 boolean isSetId() { 186 return libsbmlJNI.Port_isSetId(swigCPtr, this); 187 } 188 189 190/** 191 * Sets the value of the 'id' attribute of this {@link Port}. 192 <p> 193 * This method fails if the <code>id</code> is not a valid syntax for an SId. 194 <p> 195 * @param id the identifier for the port 196 <p> 197 * <p> 198 * @return integer value indicating success/failure of the 199 * function. The possible values 200 * returned by this function are: 201 * <ul> 202 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 203 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 204 * </ul> 205 */ public 206 int setId(String id) { 207 return libsbmlJNI.Port_setId(swigCPtr, this, id); 208 } 209 210 211/** 212 * Unsets the value of the 'id' attribute of this {@link Port}. 213 <p> 214 * <p> 215 * @return integer value indicating success/failure of the 216 * function. The possible values 217 * returned by this function are: 218 * <ul> 219 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 220 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 221 * </ul> 222 */ public 223 int unsetId() { 224 return libsbmlJNI.Port_unsetId(swigCPtr, this); 225 } 226 227 228/** 229 * Returns the value of the 'name' attribute of this {@link Port}. 230 <p> 231 * @return the value of the 'name' attribute of this {@link Port}. 232 */ public 233 String getName() { 234 return libsbmlJNI.Port_getName(swigCPtr, this); 235 } 236 237 238/** 239 * Predicate returning <code>true</code> or <code>false</code> depending on whether this 240 * {@link Port}'s 'name' attribute has been set. 241 <p> 242 * @return <code>true</code> if this {@link Port}'s 'name' attribute has been set, 243 * otherwise <code>false</code> is returned. 244 */ public 245 boolean isSetName() { 246 return libsbmlJNI.Port_isSetName(swigCPtr, this); 247 } 248 249 250/** 251 * Sets the value of the 'name' attribute of this {@link Port}. 252 <p> 253 * <p> 254 * @return integer value indicating success/failure of the 255 * function. The possible values 256 * returned by this function are: 257 * <ul> 258 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 259 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 260 * </ul> 261 */ public 262 int setName(String name) { 263 return libsbmlJNI.Port_setName(swigCPtr, this, name); 264 } 265 266 267/** 268 * Unsets the value of the 'name' attribute of this {@link Port}. 269 <p> 270 * <p> 271 * @return integer value indicating success/failure of the 272 * function. The possible values 273 * returned by this function are: 274 * <ul> 275 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 276 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 277 * </ul> 278 */ public 279 int unsetName() { 280 return libsbmlJNI.Port_unsetName(swigCPtr, this); 281 } 282 283 284/** 285 * Overrides SBaseRef.setPortRef to always fail, because {@link Port} objects 286 * themselves cannot refer to model elements by PortSId. 287 <p> 288 * @param id the identifier to set for the port reference 289 <p> 290 * @return integer value indicating failure of the 291 * function. The possible value 292 * returned by this function is: 293 * <ul> 294 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 295 * </ul> 296 */ public 297 int setPortRef(String id) { 298 return libsbmlJNI.Port_setPortRef(swigCPtr, this, id); 299 } 300 301 302/** 303 * Returns true if the 'id' attribute is set, and if exactly one of 304 * the optional attributes of {@link SBaseRef} (portRef, idRef, metaIdRef, 305 * and unitRef)are set. 306 <p> 307 * @return boolean: 'true' if the attributes are correctly set; 'false' if not. 308 */ public 309 boolean hasRequiredAttributes() { 310 return libsbmlJNI.Port_hasRequiredAttributes(swigCPtr, this); 311 } 312 313 314/** 315 * Returns the XML element name of 316 * this SBML object. 317 <p> 318 * @return the name of this element, as a text string. 319 */ public 320 String getElementName() { 321 return libsbmlJNI.Port_getElementName(swigCPtr, this); 322 } 323 324 325/** 326 * Returns the libSBML type code of this object instance. 327 <p> 328 * <p> 329 * LibSBML attaches an identifying code to every kind of SBML object. These 330 * are integer constants known as <em>SBML type codes</em>. The names of all 331 * the codes begin with the characters <code>SBML_</code>. 332 * In the Java language interface for libSBML, the 333 * type codes are defined as static integer constants in the interface class 334 * {@link libsbmlConstants}. Note that different Level 3 335 * package plug-ins may use overlapping type codes; to identify the package 336 * to which a given object belongs, call the <code>getPackageName()</code> 337 * method on the object. 338 <p> 339 * @return the SBML type code for this object: 340 * {@link libsbmlConstants#SBML_COMP_PORT SBML_COMP_PORT} 341 <p> 342 * <p> 343 * @warning <span class='warning'>The specific integer values of the possible 344 * type codes may be reused by different Level 3 package plug-ins. 345 * Thus, to identifiy the correct code, <strong>it is necessary to invoke 346 * both getTypeCode() and getPackageName()</strong>.</span> 347 <p> 348 * @see #getElementName() 349 * @see #getPackageName() 350 */ public 351 int getTypeCode() { 352 return libsbmlJNI.Port_getTypeCode(swigCPtr, this); 353 } 354 355 356/** 357 * Finds and stores the referenced object by finding its {@link Model} parent, 358 * calling 'getReferencedElementFrom()' on that model, and storing the 359 * result. 360 <p> 361 * <p> 362 * @return integer value indicating success/failure of the 363 * function. The possible values 364 * returned by this function are: 365 * <ul> 366 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 367 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 368 * </ul> 369 */ public 370 int saveReferencedElement() { 371 return libsbmlJNI.Port_saveReferencedElement(swigCPtr, this); 372 } 373 374 375/** 376 * <p> 377 * Replaces all uses of a given <code>SIdRef</code> type attribute value with another 378 * value. 379 <p> 380 * <p> 381 * In SBML, object identifiers are of a data type called <code>SId</code>. 382 * In SBML Level 3, an explicit data type called <code>SIdRef</code> was 383 * introduced for attribute values that refer to <code>SId</code> values; in 384 * previous Levels of SBML, this data type did not exist and attributes were 385 * simply described to as 'referring to an identifier', but the effective 386 * data type was the same as <code>SIdRef</code>in Level 3. These and 387 * other methods of libSBML refer to the type <code>SIdRef</code> for all 388 * Levels of SBML, even if the corresponding SBML specification did not 389 * explicitly name the data type. 390 <p> 391 * This method works by looking at all attributes and (if appropriate) 392 * mathematical formulas in MathML content, comparing the referenced 393 * identifiers to the value of <code>oldid</code>. If any matches are found, the 394 * matching values are replaced with <code>newid</code>. The method does <em>not</em> 395 * descend into child elements. 396 <p> 397 * @param oldid the old identifier 398 * @param newid the new identifier 399 */ public 400 void renameSIdRefs(String oldid, String newid) { 401 libsbmlJNI.Port_renameSIdRefs(swigCPtr, this, oldid, newid); 402 } 403 404 405/** 406 * <p> 407 * Replaces all uses of a given <code>UnitSIdRef</code> type attribute value with 408 * another value. 409 <p> 410 * <p> 411 * In SBML, unit definitions have identifiers of type <code>UnitSId</code>. In 412 * SBML Level 3, an explicit data type called <code>UnitSIdRef</code> was 413 * introduced for attribute values that refer to <code>UnitSId</code> values; in 414 * previous Levels of SBML, this data type did not exist and attributes were 415 * simply described to as 'referring to a unit identifier', but the effective 416 * data type was the same as <code>UnitSIdRef</code> in Level 3. These and 417 * other methods of libSBML refer to the type <code>UnitSIdRef</code> for all 418 * Levels of SBML, even if the corresponding SBML specification did not 419 * explicitly name the data type. 420 <p> 421 * This method works by looking at all unit identifier attribute values 422 * (including, if appropriate, inside mathematical formulas), comparing the 423 * referenced unit identifiers to the value of <code>oldid</code>. If any matches 424 * are found, the matching values are replaced with <code>newid</code>. The method 425 * does <em>not</em> descend into child elements. 426 <p> 427 * @param oldid the old identifier 428 * @param newid the new identifier 429 */ public 430 void renameUnitSIdRefs(String oldid, String newid) { 431 libsbmlJNI.Port_renameUnitSIdRefs(swigCPtr, this, oldid, newid); 432 } 433 434 435/** 436 * <p> 437 * Replaces all uses of a given meta identifier attribute value with 438 * another value. 439 <p> 440 * <p> 441 * In SBML, object 'meta' identifiers are of the XML data type <code>ID</code>; 442 * the SBML object attribute itself is typically named <code>metaid</code>. All 443 * attributes that hold values <em>referring</em> to values of type 444 * <code>ID</code> are of the XML data type <code>IDREF</code>. They are also 445 * sometimes informally referred to as 'metaid refs', in analogy to the 446 * SBML-defined type <code>SIdRef</code>. 447 <p> 448 * This method works by looking at all meta-identifier attribute values, 449 * comparing the identifiers to the value of <code>oldid</code>. If any matches are 450 * found, the matching identifiers are replaced with <code>newid</code>. The method 451 * does <em>not</em> descend into child elements. 452 <p> 453 * @param oldid the old identifier 454 * @param newid the new identifier 455 */ public 456 void renameMetaIdRefs(String oldid, String newid) { 457 libsbmlJNI.Port_renameMetaIdRefs(swigCPtr, this, oldid, newid); 458 } 459 460}