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