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