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 Base class for references to objects.
014 <p>
015 * The {@link SBaseRef} class was introduced by the SBML Level&nbsp;3 <a href='../../../extensions-summary.html#comp'>Hierarchical Model Composition</a>
016 * (&ldquo;comp&rdquo;) package as the principle way by which submodel
017 * elements may be referenced.  The {@link SBaseRef} class is usually found as the
018 * base class of a {@link Port}, {@link Deletion}, {@link ReplacedElement}, or {@link ReplacedBy} class, but
019 * may appear as an child of one of the above classes if the parent object
020 * references a {@link Submodel}.
021 <p>
022 * An {@link SBaseRef} object must reference an element using exactly one of the
023 * optional attributes of the class.  Subclasses of {@link SBaseRef} may define
024 * additional optional attributes that are legal ways to reference an element.
025 <p>
026 * {@link SBaseRef} objects may reference elements that do not live in the {@link Model} parent 
027 * of the {@link SBaseRef} object.  However, the {@link SBaseRef} class itself does not 
028 * provide a method of determining which {@link Model} or {@link Submodel} is being referenced.
029 * The subclasses of {@link SBaseRef} provide methods for this instead.
030 <p>
031 * Once the {@link Model} to which the {@link SBaseRef} object is referencing has been established,
032 * there are four optional attributes defined in the {@link SBaseRef} class that
033 * are each methods of referencing an element:
034 <p>
035 * <ul>
036 * <li> 'portRef' (type <code>PortSIdRef</code>):  As its name implies, this attribute is used to
037 * refer to a port identifier, in the case when the reference being
038 * constructed with the {@link SBaseRef} is intended to refer to a port on a
039 * submodel.  The namespace of the <code>PortSIdRef</code> value is the set
040 * of identifiers of type <code>PortSId</code> defined in the submodel, not
041 * the parent model.
042 * <li> 'idRef' (type <code>SIdRef</code>): As its name implies, this attribute is used to
043 * refer to a regular identifier (i.e., the value of an 'id'
044 * attribute on some other object), in the case when the reference being
045 * constructed with the {@link SBaseRef} is intended to refer to an object that
046 * does not have a port identifier.  The namespace of the <code>SIdRef</code>
047 * value is the set of identifiers of type SId defined in the
048 * submodel, not the parent model.
049 * <li> 'unitRef' (type <code>UnitSIdRef</code>): This attribute is used to refer to the identifier
050 * of a {@link UnitDefinition} object.  The namespace of the <code>UnitSIdRef</code>
051 * value is the set of unit identifiers defined in the submodel, not the
052 * parent model. (Note that even though this attribute is of type <code>UnitSIdRef</code>,
053 * the reserved unit identifiers that are defined by SBML Level&nbsp;3 (see
054 * Section 3.1.10 of the core specification) are
055 * *not* permitted as values of 'unitRef'.  Reserved unit
056 * identifiers may not be replaced or deleted.)
057 * <li> 'metaIdRef' (type <code>IDREF</code>): This attribute is used to refer to a 'metaid'
058 * attribute value on some other object, in the case when the reference
059 * being constructed with the {@link SBaseRef} is intended to refer to an object
060 * that does not have a port identifier.  The namespace of the 'metaIdRef'
061 * value is the entire document in which the referenced model resides, but
062 * must refer to a subelement of the referenced model.  Since meta identifiers are
063 * optional attributes of {@link SBase}, all SBML objects have the potential to
064 * have a meta identifier value.
065 *
066 * </ul> <p>
067 * An {@link SBaseRef} object may have up to one subcomponent named 'sBaseRef', of
068 * type {@link SBaseRef}.  This permits recursive structures to be constructed so
069 * that objects inside submodels can be referenced.
070 <p>
071 * The form of such recursive references must be as follows.  The
072 * highest-level {@link SBaseRef} object of such a chain (which will necessarily
073 * be an object of class {@link Port}, {@link Deletion}, {@link ReplacedElement} or {@link ReplacedBy},
074 * because they are the only classes derived from the class {@link SBaseRef}) must
075 * refer to a {@link Submodel} object in the containing model.  All child
076 * {@link SBaseRef} objects in the chain must refer to components inside the
077 * {@link Model} instance to which the {@link Submodel} refers.
078 */
079
080public class SBaseRef extends CompBase {
081   private long swigCPtr;
082
083   protected SBaseRef(long cPtr, boolean cMemoryOwn)
084   {
085     super(libsbmlJNI.SBaseRef_SWIGUpcast(cPtr), cMemoryOwn);
086     swigCPtr = cPtr;
087   }
088
089   protected static long getCPtr(SBaseRef obj)
090   {
091     return (obj == null) ? 0 : obj.swigCPtr;
092   }
093
094   protected static long getCPtrAndDisown (SBaseRef obj)
095   {
096     long ptr = 0;
097
098     if (obj != null)
099     {
100       ptr             = obj.swigCPtr;
101       obj.swigCMemOwn = false;
102     }
103
104     return ptr;
105   }
106
107  protected void finalize() {
108    delete();
109  }
110
111  public synchronized void delete() {
112    if (swigCPtr != 0) {
113      if (swigCMemOwn) {
114        swigCMemOwn = false;
115        libsbmlJNI.delete_SBaseRef(swigCPtr);
116      }
117      swigCPtr = 0;
118    }
119    super.delete();
120  }
121
122  
123/**
124   * Creates a new {@link SBaseRef} with the given level, version, and package version.
125   <p>
126   * @param level the SBML Level.
127   * @param version the Version within the SBML Level.
128   * @param pkgVersion the version of the package.
129   <p>
130   * <p>
131 * @note Attempting to add an object to an {@link SBMLDocument} having a different
132 * combination of SBML Level, Version and XML namespaces than the object
133 * itself will result in an error at the time a caller attempts to make the
134 * addition.  A parent object must have compatible Level, Version and XML
135 * namespaces.  (Strictly speaking, a parent may also have more XML
136 * namespaces than a child, but the reverse is not permitted.)  The
137 * restriction is necessary to ensure that an SBML model has a consistent
138 * overall structure.  This requires callers to manage their objects
139 * carefully, but the benefit is increased flexibility in how models can be
140 * created by permitting callers to create objects bottom-up if desired.  In
141 * situations where objects are not yet attached to parents (e.g.,
142 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
143 * libSBML determine such things as whether it is valid to assign a
144 * particular value to an attribute.  For packages, this means that the 
145 * parent object to which this package element is being added must have
146 * been created with the package namespace, or that the package namespace
147 * was added to it, even if that parent is not a package object itself.
148   */ public
149 SBaseRef(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException {
150    this(libsbmlJNI.new_SBaseRef__SWIG_0(level, version, pkgVersion), true);
151  }
152
153  
154/**
155   * Creates a new {@link SBaseRef} with the given level, version, and package version.
156   <p>
157   * @param level the SBML Level.
158   * @param version the Version within the SBML Level.
159   * @param pkgVersion the version of the package.
160   <p>
161   * <p>
162 * @note Attempting to add an object to an {@link SBMLDocument} having a different
163 * combination of SBML Level, Version and XML namespaces than the object
164 * itself will result in an error at the time a caller attempts to make the
165 * addition.  A parent object must have compatible Level, Version and XML
166 * namespaces.  (Strictly speaking, a parent may also have more XML
167 * namespaces than a child, but the reverse is not permitted.)  The
168 * restriction is necessary to ensure that an SBML model has a consistent
169 * overall structure.  This requires callers to manage their objects
170 * carefully, but the benefit is increased flexibility in how models can be
171 * created by permitting callers to create objects bottom-up if desired.  In
172 * situations where objects are not yet attached to parents (e.g.,
173 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
174 * libSBML determine such things as whether it is valid to assign a
175 * particular value to an attribute.  For packages, this means that the 
176 * parent object to which this package element is being added must have
177 * been created with the package namespace, or that the package namespace
178 * was added to it, even if that parent is not a package object itself.
179   */ public
180 SBaseRef(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
181    this(libsbmlJNI.new_SBaseRef__SWIG_1(level, version), true);
182  }
183
184  
185/**
186   * Creates a new {@link SBaseRef} with the given level, version, and package version.
187   <p>
188   * @param level the SBML Level.
189   * @param version the Version within the SBML Level.
190   * @param pkgVersion the version of the package.
191   <p>
192   * <p>
193 * @note Attempting to add an object to an {@link SBMLDocument} having a different
194 * combination of SBML Level, Version and XML namespaces than the object
195 * itself will result in an error at the time a caller attempts to make the
196 * addition.  A parent object must have compatible Level, Version and XML
197 * namespaces.  (Strictly speaking, a parent may also have more XML
198 * namespaces than a child, but the reverse is not permitted.)  The
199 * restriction is necessary to ensure that an SBML model has a consistent
200 * overall structure.  This requires callers to manage their objects
201 * carefully, but the benefit is increased flexibility in how models can be
202 * created by permitting callers to create objects bottom-up if desired.  In
203 * situations where objects are not yet attached to parents (e.g.,
204 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
205 * libSBML determine such things as whether it is valid to assign a
206 * particular value to an attribute.  For packages, this means that the 
207 * parent object to which this package element is being added must have
208 * been created with the package namespace, or that the package namespace
209 * was added to it, even if that parent is not a package object itself.
210   */ public
211 SBaseRef(long level) throws org.sbml.libsbml.SBMLConstructorException {
212    this(libsbmlJNI.new_SBaseRef__SWIG_2(level), true);
213  }
214
215  
216/**
217   * Creates a new {@link SBaseRef} with the given level, version, and package version.
218   <p>
219   * @param level the SBML Level.
220   * @param version the Version within the SBML Level.
221   * @param pkgVersion the version of the package.
222   <p>
223   * <p>
224 * @note Attempting to add an object to an {@link SBMLDocument} having a different
225 * combination of SBML Level, Version and XML namespaces than the object
226 * itself will result in an error at the time a caller attempts to make the
227 * addition.  A parent object must have compatible Level, Version and XML
228 * namespaces.  (Strictly speaking, a parent may also have more XML
229 * namespaces than a child, but the reverse is not permitted.)  The
230 * restriction is necessary to ensure that an SBML model has a consistent
231 * overall structure.  This requires callers to manage their objects
232 * carefully, but the benefit is increased flexibility in how models can be
233 * created by permitting callers to create objects bottom-up if desired.  In
234 * situations where objects are not yet attached to parents (e.g.,
235 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
236 * libSBML determine such things as whether it is valid to assign a
237 * particular value to an attribute.  For packages, this means that the 
238 * parent object to which this package element is being added must have
239 * been created with the package namespace, or that the package namespace
240 * was added to it, even if that parent is not a package object itself.
241   */ public
242 SBaseRef() throws org.sbml.libsbml.SBMLConstructorException {
243    this(libsbmlJNI.new_SBaseRef__SWIG_3(), true);
244  }
245
246  
247/**
248   * Creates a new {@link SBaseRef} with the given {@link CompPkgNamespaces} object.
249   <p>
250   * <p>
251 * The package namespaces object used in this constructor is derived from a
252 * {@link SBMLNamespaces} object, which encapsulates SBML Level/Version/namespaces
253 * information.  It is used to communicate the SBML Level, Version, and 
254 * package version and name information used in addition to SBML Level&nbsp;3 Core.  A
255 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an
256 * package namespace object somewhere in a program once, then hand that object
257 * as needed to object constructors of that package that accept it as and
258 * argument, such as this one.
259   <p>
260   * @param compns the {@link CompPkgNamespaces} object.
261   <p>
262   * <p>
263 * @note Attempting to add an object to an {@link SBMLDocument} having a different
264 * combination of SBML Level, Version and XML namespaces than the object
265 * itself will result in an error at the time a caller attempts to make the
266 * addition.  A parent object must have compatible Level, Version and XML
267 * namespaces.  (Strictly speaking, a parent may also have more XML
268 * namespaces than a child, but the reverse is not permitted.)  The
269 * restriction is necessary to ensure that an SBML model has a consistent
270 * overall structure.  This requires callers to manage their objects
271 * carefully, but the benefit is increased flexibility in how models can be
272 * created by permitting callers to create objects bottom-up if desired.  In
273 * situations where objects are not yet attached to parents (e.g.,
274 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
275 * libSBML determine such things as whether it is valid to assign a
276 * particular value to an attribute.  For packages, this means that the 
277 * parent object to which this package element is being added must have
278 * been created with the package namespace, or that the package namespace
279 * was added to it, even if that parent is not a package object itself.
280   */ public
281 SBaseRef(CompPkgNamespaces compns) throws org.sbml.libsbml.SBMLConstructorException {
282    this(libsbmlJNI.new_SBaseRef__SWIG_4(CompPkgNamespaces.getCPtr(compns), compns), true);
283  }
284
285  
286/**
287   * Copy constructor.
288   <p>
289   * @param source the instance to copy.
290   */ public
291 SBaseRef(SBaseRef source) throws org.sbml.libsbml.SBMLConstructorException {
292    this(libsbmlJNI.new_SBaseRef__SWIG_5(SBaseRef.getCPtr(source), source), true);
293  }
294
295  
296/**
297   * Creates and returns a deep copy of this {@link SBaseRef} object.
298   <p>
299   * @return a (deep) copy of this {@link SBaseRef} object.
300   */ public
301 SBase cloneObject() {
302    long cPtr = libsbmlJNI.SBaseRef_cloneObject(swigCPtr, this);
303    return (cPtr == 0) ? null : new SBaseRef(cPtr, true);
304  }
305
306  
307/**
308   * Returns the first child element found that has the given <code>id</code> in the
309   * model-wide SId namespace, or <code>null</code> if no such object is found.
310   <p>
311   * @param id string representing the id of the object to find.
312   <p>
313   * @return a pointer to the {@link SBase} element with the given <code>id</code>.
314   */ public
315 SBase getElementBySId(String id) {
316  return libsbml.DowncastSBase(libsbmlJNI.SBaseRef_getElementBySId(swigCPtr, this, id), false);
317}
318
319  
320/**
321   * Returns the first child element it can find with the given <code>metaid</code>, or
322   * itself if it has the given <code>metaid</code>, or <code>null</code> if no such object is found.
323   <p>
324   * @param metaid string representing the metaid of the object to find.
325   <p>
326   * @return a pointer to the {@link SBase} element with the given <code>metaid</code>.
327   */ public
328 SBase getElementByMetaId(String metaid) {
329  return libsbml.DowncastSBase(libsbmlJNI.SBaseRef_getElementByMetaId(swigCPtr, this, metaid), false);
330}
331
332  
333/**
334   * Returns the value of the 'metaIdRef' attribute of this {@link SBaseRef}.
335   <p>
336   * @return the value of the 'metaIdRef' attribute of this {@link SBaseRef}.
337   */ public
338 String getMetaIdRef() {
339    return libsbmlJNI.SBaseRef_getMetaIdRef(swigCPtr, this);
340  }
341
342  
343/**
344   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
345   * {@link SBaseRef}'s 'metaIdRef' attribute has been set.
346   <p>
347   * @return <code>true</code> if this {@link SBaseRef}'s 'metaIdRef' attribute has been set, 
348   * otherwise <code>false</code> is returned.
349   */ public
350 boolean isSetMetaIdRef() {
351    return libsbmlJNI.SBaseRef_isSetMetaIdRef(swigCPtr, this);
352  }
353
354  
355/**
356   * Sets the value of the 'metaIdRef' attribute of this {@link SBaseRef}.
357   <p>
358   * This method fails if the id is not a valid syntax for an <code>IDREF</code> ({@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}), or if the {@link SBaseRef} already
359   * points to an element of the submodel using a different interface ({@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}).  An sBaseRef must use exactly one
360   * method to point to a submodel element.
361   <p>
362   * <p>
363 * @return integer value indicating success/failure of the
364 * function.   The possible values
365 * returned by this function are:
366   * <ul>
367   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
368   * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}
369   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
370   * </ul>
371   */ public
372 int setMetaIdRef(String id) {
373    return libsbmlJNI.SBaseRef_setMetaIdRef(swigCPtr, this, id);
374  }
375
376  
377/**
378   * Unsets the value of the 'metaIdRef' attribute of this {@link SBaseRef}.
379   <p>
380   * <p>
381 * @return integer value indicating success/failure of the
382 * function.   The possible values
383 * returned by this function are:
384   * <ul>
385   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
386   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
387   * </ul>
388   */ public
389 int unsetMetaIdRef() {
390    return libsbmlJNI.SBaseRef_unsetMetaIdRef(swigCPtr, this);
391  }
392
393  
394/**
395   * Returns the value of the 'portRef' attribute of this {@link SBaseRef}.
396   <p>
397   * @return the value of the 'portRef' attribute of this {@link SBaseRef}.
398   */ public
399 String getPortRef() {
400    return libsbmlJNI.SBaseRef_getPortRef(swigCPtr, this);
401  }
402
403  
404/**
405   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
406   * {@link SBaseRef}'s 'portRef' attribute has been set.
407   <p>
408   * @return <code>true</code> if this {@link SBaseRef}'s 'portRef' attribute has been set, 
409   * otherwise <code>false</code> is returned.
410   */ public
411 boolean isSetPortRef() {
412    return libsbmlJNI.SBaseRef_isSetPortRef(swigCPtr, this);
413  }
414
415  
416/**
417   * Sets the value of the 'portRef' attribute of this {@link SBaseRef}.  Fails if
418   * the id is not a valid syntax for a <code>PortSIdRef</code> ({@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}), or if the {@link SBaseRef} already
419   * points to an element of the submodel using a different interface ({@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}).  An {@link SBaseRef} must use exactly one
420   * method to point to a submodel element.
421   <p>
422   * <p>
423 * @return integer value indicating success/failure of the
424 * function.   The possible values
425 * returned by this function are:
426   * <ul>
427   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
428   * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}
429   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
430   * </ul>
431   */ public
432 int setPortRef(String id) {
433    return libsbmlJNI.SBaseRef_setPortRef(swigCPtr, this, id);
434  }
435
436  
437/**
438   * Unsets the value of the 'portRef' attribute of this {@link SBaseRef}.
439   <p>
440   * <p>
441 * @return integer value indicating success/failure of the
442 * function.   The possible values
443 * returned by this function are:
444   * <ul>
445   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
446   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
447   * </ul>
448   */ public
449 int unsetPortRef() {
450    return libsbmlJNI.SBaseRef_unsetPortRef(swigCPtr, this);
451  }
452
453  
454/**
455   * Returns the value of the 'idRef' attribute of this {@link SBaseRef}.
456   <p>
457   * @return the value of the 'idRef' attribute of this {@link SBaseRef}.
458   */ public
459 String getIdRef() {
460    return libsbmlJNI.SBaseRef_getIdRef(swigCPtr, this);
461  }
462
463  
464/**
465   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
466   * {@link SBaseRef}'s 'idRef' attribute has been set.
467   <p>
468   * @return <code>true</code> if this {@link SBaseRef}'s 'idRef' attribute has been set, 
469   * otherwise <code>false</code> is returned.
470   */ public
471 boolean isSetIdRef() {
472    return libsbmlJNI.SBaseRef_isSetIdRef(swigCPtr, this);
473  }
474
475  
476/**
477   * Sets the value of the 'idRef' attribute of this {@link SBaseRef}.
478   <p>
479   * This method fails if the id is not a valid syntax for an <code>SIdRef</code> ({@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}), or if the {@link SBaseRef} already
480   * points to an element of the submodel using a different interface ({@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}).  A sBaseRef must use exactly one
481   * method to point to a submodel element.
482   <p>
483   * <p>
484 * @return integer value indicating success/failure of the
485 * function.   The possible values
486 * returned by this function are:
487   * <ul>
488   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
489   * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}
490   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
491   * </ul>
492   */ public
493 int setIdRef(String id) {
494    return libsbmlJNI.SBaseRef_setIdRef(swigCPtr, this, id);
495  }
496
497  
498/**
499   * Unsets the value of the 'idRef' attribute of this {@link SBaseRef}.
500   <p>
501   * <p>
502 * <p>
503 * The identifier given by an object's 'id' attribute value
504 * is used to identify the object within the SBML model definition.
505 * Other objects can refer to the component using this identifier.  The
506 * data type of 'id' is always <code>SId</code> or a type derived
507 * from that, such as <code>UnitSId</code>, depending on the object in 
508 * question.  All data types are defined as follows:
509 * <pre style='margin-left: 2em; border: none; font-weight: bold; color: black'>
510 *   letter .= 'a'..'z','A'..'Z'
511 *   digit  .= '0'..'9'
512 *   idChar .= letter | digit | '_'
513 *   SId    .= ( letter | '_' ) idChar*
514 * </pre>
515 <p>
516 * The characters <code>(</code> and <code>)</code> are used for grouping, the
517 * character <code>*</code> 'zero or more times', and the character
518 * <code>|</code> indicates logical 'or'.  The equality of SBML identifiers is
519 * determined by an exact character sequence match; i.e., comparisons must be
520 * performed in a case-sensitive manner.  This applies to all uses of <code>SId</code>, 
521 * <code>SIdRef</code>, and derived types.
522 <p>
523 * In SBML Level&nbsp;3 Version&nbsp;2, the 'id' and 'name' attributes were
524 * moved to {@link SBase} directly, instead of being defined individually for many
525 * (but not all) objects.  Libsbml has for a long time provided functions
526 * defined on {@link SBase} itself to get, set, check, and unset those attributes, which 
527 * would fail or otherwise return empty strings if executed on any object 
528 * for which those attributes were not defined.  Now that all {@link SBase} objects 
529 * define those attributes, those functions now succeed for any object with 
530 * the appropriate level and version.
531 <p>
532 * The exception to this rule is that for {@link InitialAssignment}, {@link EventAssignment}, 
533 * {@link AssignmentRule}, and {@link RateRule} objects, the getId() function and the isSetId() 
534 * functions (though not the setId() or unsetId() functions) would instead 
535 * reference the value of the 'variable' attribute (for the rules and event 
536 * assignments) or the 'symbol' attribute (for initial assignments).  
537 * The {@link AlgebraicRule} fell into this category as well, though because it 
538 * contained neither a 'variable' nor a 'symbol' attribute, getId() would 
539 * always return an empty string, and isSetId() would always return <code>false.</code>
540 * For this reason, four new functions are now provided 
541 * (getIdAttribute(), setIdAttribute(String), 
542 * isSetIdAttribute(), and unsetIdAttribute()) that will always
543 * act on the actual 'id' attribute, regardless of the object's type.  The
544 * new functions should be used instead of the old ones unless the old behavior
545 * is somehow necessary.
546 <p>
547 * Regardless of the level and version of the SBML, these functions allow
548 * client applications to use more generalized code in some situations 
549 * (for instance, when manipulating objects that are all known to have 
550 * identifiers).  If the object in question does not posess an 'id' attribute 
551 * according to the SBML specification for the Level and Version in use,
552 * libSBML will not allow the identifier to be set, nor will it read or 
553 * write 'id' attributes for those objects.
554 <p>
555 * <p>
556 * @return integer value indicating success/failure of the
557 * function.   The possible values
558 * returned by this function are:
559 * <ul>
560 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
561 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
562 *
563 * </ul> <p>
564 * @see #getIdAttribute()
565 * @see #setIdAttribute(String sid)
566 * @see #isSetIdAttribute()
567 * @see #unsetIdAttribute()
568   */ public
569 int unsetIdRef() {
570    return libsbmlJNI.SBaseRef_unsetIdRef(swigCPtr, this);
571  }
572
573  
574/**
575   * Returns the value of the 'unitRef' attribute of this {@link SBaseRef}.
576   <p>
577   * @return the value of the 'unitRef' attribute of this {@link SBaseRef}.
578   */ public
579 String getUnitRef() {
580    return libsbmlJNI.SBaseRef_getUnitRef(swigCPtr, this);
581  }
582
583  
584/**
585   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
586   * {@link SBaseRef}'s 'unitRef' attribute has been set.
587   <p>
588   * @return <code>true</code> if this {@link SBaseRef}'s 'unitRef' attribute has been set, 
589   * otherwise <code>false</code> is returned.
590   */ public
591 boolean isSetUnitRef() {
592    return libsbmlJNI.SBaseRef_isSetUnitRef(swigCPtr, this);
593  }
594
595  
596/**
597   * Sets the value of the 'unitRef' attribute of this {@link SBaseRef}.
598   <p>
599   * This method fails if the id is not a valid syntax for a <code>UnitSIdRef</code> ({@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}), or if the {@link SBaseRef} already
600   * points to an element of the submodel using a different interface ({@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}).  A sBaseRef must use exactly one
601   * method to point to a submodel element.
602   <p>
603   * <p>
604 * @return integer value indicating success/failure of the
605 * function.   The possible values
606 * returned by this function are:
607   * <ul>
608   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
609   * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}
610   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
611   * </ul>
612   */ public
613 int setUnitRef(String id) {
614    return libsbmlJNI.SBaseRef_setUnitRef(swigCPtr, this, id);
615  }
616
617  
618/**
619   * Unsets the value of the 'unitRef' attribute of this {@link SBaseRef}.
620   <p>
621   * <p>
622 * @return integer value indicating success/failure of the
623 * function.   The possible values
624 * returned by this function are:
625   * <ul>
626   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
627   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
628   * </ul>
629   */ public
630 int unsetUnitRef() {
631    return libsbmlJNI.SBaseRef_unsetUnitRef(swigCPtr, this);
632  }
633
634  
635/**
636   * Get the child sBaseRef of this sBaseRef.
637   <p>
638   * @return the  {@link SBaseRef} child of this {@link SBaseRef}, or <code>null</code> if none exists.
639   */ public
640 SBaseRef getSBaseRef() {
641    long cPtr = libsbmlJNI.SBaseRef_getSBaseRef__SWIG_0(swigCPtr, this);
642    return (cPtr == 0) ? null : new SBaseRef(cPtr, false);
643  }
644
645  
646/**
647   * Predicate for testing whether the sBaseRef for this {@link SBaseRef} is set.
648   <p>
649   * @return <code>true</code> if the sBaseRef of this {@link SBaseRef} is set, <code>false</code>
650   * otherwise.
651   */ public
652 boolean isSetSBaseRef() {
653    return libsbmlJNI.SBaseRef_isSetSBaseRef(swigCPtr, this);
654  }
655
656  
657/**
658   * Sets the sBaseRef definition of this {@link SBaseRef} to a copy of the given
659   * {@link SBaseRef} object instance.
660   <p>
661   * This method fails if the added sBaseRef does not match the
662   * level/version/package of the parent object or if the added sBaseRef cannot
663   * be copied.
664   <p>
665   * @param sBaseRef the {@link SBaseRef} object instance to use.
666   <p>
667   * <p>
668 * @return integer value indicating success/failure of the
669 * function.   The possible values
670 * returned by this function are:
671   * <ul>
672   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
673   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
674   * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH}
675   * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH}
676   * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_PKG_VERSION_MISMATCH}
677   * </ul>
678   */ public
679 int setSBaseRef(SBaseRef sBaseRef) {
680    return libsbmlJNI.SBaseRef_setSBaseRef(swigCPtr, this, SBaseRef.getCPtr(sBaseRef), sBaseRef);
681  }
682
683  
684/**
685   * Creates a new, empty {@link SBaseRef}, adds it to this {@link SBaseRef} and 
686   * returns the created {@link SBaseRef}.
687   <p>
688   * @return the newly created {@link SBaseRef} object instance.
689   */ public
690 SBaseRef createSBaseRef() {
691    long cPtr = libsbmlJNI.SBaseRef_createSBaseRef(swigCPtr, this);
692    return (cPtr == 0) ? null : new SBaseRef(cPtr, false);
693  }
694
695  
696/**
697   * Unsets the child {@link SBaseRef} of this {@link SBaseRef}.  Deletes the former {@link SBaseRef} child,
698   * if one existed.
699   <p>
700   * <p>
701 * @return integer value indicating success/failure of the
702 * function.   The possible values
703 * returned by this function are:
704   * <ul>
705   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
706   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
707   * </ul>
708   */ public
709 int unsetSBaseRef() {
710    return libsbmlJNI.SBaseRef_unsetSBaseRef(swigCPtr, this);
711  }
712
713  
714/**
715   * Returns how many elements are being referred to by this {@link SBaseRef}.  A
716   * valid {@link SBaseRef} will have exactly one.  Possible referents are portRef,
717   * idRef, unitRef, and metaIdRef.
718   <p>
719   * @return integer value between 0 and 4: the number of different ways this element points to its referent.
720   */ public
721 int getNumReferents() {
722    return libsbmlJNI.SBaseRef_getNumReferents(swigCPtr, this);
723  }
724
725  
726/**
727   * Returns <code>true</code> if getNumReferents() is exactly 1.
728   <p>
729   * @return boolean: 'true' if the attributes are correctly set; 'false' if not.
730   */ public
731 boolean hasRequiredAttributes() {
732    return libsbmlJNI.SBaseRef_hasRequiredAttributes(swigCPtr, this);
733  }
734
735  
736/**
737   * <p>
738 * Replaces all uses of a given <code>SIdRef</code> type attribute value with another
739 * value.
740 <p>
741 * <p>
742 * In SBML, object identifiers are of a data type called <code>SId</code>.
743 * In SBML Level&nbsp;3, an explicit data type called <code>SIdRef</code> was
744 * introduced for attribute values that refer to <code>SId</code> values; in
745 * previous Levels of SBML, this data type did not exist and attributes were
746 * simply described to as 'referring to an identifier', but the effective
747 * data type was the same as <code>SIdRef</code> in Level&nbsp;3.  These and
748 * other methods of libSBML refer to the type <code>SIdRef</code> for all
749 * Levels of SBML, even if the corresponding SBML specification did not
750 * explicitly name the data type.
751 <p>
752 * This method works by looking at all attributes and (if appropriate)
753 * mathematical formulas in MathML content, comparing the referenced
754 * identifiers to the value of <code>oldid</code>.  If any matches are found, the
755 * matching values are replaced with <code>newid</code>.  The method does <em>not</em>
756 * descend into child elements.
757 <p>
758 * @param oldid the old identifier.
759 * @param newid the new identifier.
760   */ public
761 void renameSIdRefs(String oldid, String newid) {
762    libsbmlJNI.SBaseRef_renameSIdRefs(swigCPtr, this, oldid, newid);
763  }
764
765  
766/**
767   * Returns the XML element name of
768   * this SBML object.
769   <p>
770   * @return the name of this element, as a text string.
771   */ public
772 String getElementName() {
773    return libsbmlJNI.SBaseRef_getElementName(swigCPtr, this);
774  }
775
776  
777/**
778   * Returns the libSBML type code of this object instance.
779   <p>
780   * <p>
781 * LibSBML attaches an identifying code to every kind of SBML object.  These
782 * are integer constants known as <em>SBML type codes</em>.  The names of all
783 * the codes begin with the characters <code>SBML_</code>.
784 * In the Java language interface for libSBML, the
785 * type codes are defined as static integer constants in the interface class
786 * {@link libsbmlConstants}.    Note that different Level&nbsp;3
787 * package plug-ins may use overlapping type codes; to identify the package
788 * to which a given object belongs, call the <code>getPackageName()</code>
789 * method on the object.
790   <p>
791   * @return the SBML type code for this object:
792   * {@link libsbmlConstants#SBML_COMP_SBASEREF SBML_COMP_SBASEREF}.
793   <p>
794   * <p>
795 * @warning <span class='warning'>The specific integer values of the possible
796 * type codes may be reused by different libSBML plug-ins for SBML Level&nbsp;3.
797 * packages,  To fully identify the correct code, <strong>it is necessary to
798 * invoke both getTypeCode() and getPackageName()</strong>.</span>
799   <p>
800   * @see #getElementName()
801   * @see #getPackageName()
802   */ public
803 int getTypeCode() {
804    return libsbmlJNI.SBaseRef_getTypeCode(swigCPtr, this);
805  }
806
807  public void connectToChild() {
808    libsbmlJNI.SBaseRef_connectToChild(swigCPtr, this);
809  }
810
811  
812/**
813   * Examines the referenced {@link Model} for the referenced object, and returns it, if found.
814   <p>
815   * @param model the {@link Model} in which to look for the object referenced by
816   * this {@link SBaseRef}.
817   <p>
818   * @return the element in the referenced {@link Model} to which this {@link SBaseRef}
819   * refers.  If this object references an object in a {@link Submodel}, the returned
820   * object will be in the instantiated {@link Model} in that {@link Submodel}.
821   */ public
822 SBase getReferencedElementFrom(Model model) {
823  return libsbml.DowncastSBase(libsbmlJNI.SBaseRef_getReferencedElementFrom(swigCPtr, this, Model.getCPtr(model), model), false);
824}
825
826  
827/**
828   * Finds and stores the referenced object by finding the {@link Model} it needs to
829   * point to, calling 'saveReferencedElement' on its parent (which will also
830   * be a {@link SBaseRef} or one of its subclasses), and the storing the result.
831   <p>
832   * <p>
833 * @return integer value indicating success/failure of the
834 * function.   The possible values
835 * returned by this function are:
836   * <ul>
837   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
838   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
839   * </ul>
840   */ public
841 int saveReferencedElement() {
842    return libsbmlJNI.SBaseRef_saveReferencedElement(swigCPtr, this);
843  }
844
845  
846/**
847   * Returns the object pointed to by this element.  If that element was
848   * previously found and set with 'saveReferencedElement', that element is
849   * returned; otherwise, 'saveReferencedElement' is called first, and the
850   * found element is returned.
851   */ public
852 SBase getReferencedElement() {
853  return libsbml.DowncastSBase(libsbmlJNI.SBaseRef_getReferencedElement(swigCPtr, this), false);
854}
855
856  
857/**
858   * Removes the saved referenced element, if it had been saved earlier.
859   */ public
860 void clearReferencedElement() {
861    libsbmlJNI.SBaseRef_clearReferencedElement(swigCPtr, this);
862  }
863
864  
865/**
866   * DEPRECATED FUNCTION:  DO NOT USE
867   <p>
868   * Deletes the referenced object,
869   * plus any other elements that element points to through {@link ReplacedElement}
870   * or {@link ReplacedBy} children.  Instead of calling this function directly, use
871   * 'CompModelPlugin.instantiateSubmodels' instead, which deals with all the
872   * intricacies of replacements and deletions, and gives you access to the
873   * non-flattened hierarchical form of the model.
874   */ public
875 int performDeletion() {
876    return libsbmlJNI.SBaseRef_performDeletion(swigCPtr, this);
877  }
878
879  
880/**
881   * Finds this {@link SBaseRef}'s parent, which can either be a List or can be
882   * another {@link SBaseRef}, and tells it to remove this.
883   <p>
884   * <p>
885 * @return integer value indicating success/failure of the
886 * function.   The possible values
887 * returned by this function are:
888   * <ul>
889   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
890   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
891   * </ul>
892   */ public
893 int removeFromParentAndDelete() {
894    return libsbmlJNI.SBaseRef_removeFromParentAndDelete(swigCPtr, this);
895  }
896
897}