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 *  Implementation of SBML's Level 2's CompartmentType
013 * construct.
014 <p>
015 * SBML Level&nbsp;2 Versions&nbsp;2&ndash;4 provide the <em>compartment
016 * type</em> as a grouping construct that can be used to establish a
017 * relationship between multiple {@link Compartment} objects.  A {@link CompartmentType}
018 * object only has an identity, and this identity can only be used to
019 * indicate that particular {@link Compartment} objects in the model belong to this
020 * type.  This may be useful for conveying a modeling intention, such as
021 * when a model contains many similar compartments, either by their
022 * biological function or the reactions they carry.  Without a compartment
023 * type construct, it would be impossible within SBML itself to indicate
024 * that all of the compartments share an underlying conceptual relationship
025 * because each SBML compartment must be given a unique and separate
026 * identity.  {@link Compartment} types have no mathematical meaning in
027 * SBML&mdash;they have no effect on a model's mathematical interpretation.
028 * Simulators and other numerical analysis software may ignore
029 * {@link CompartmentType} definitions and references to them in a model.
030 <p>
031 * There is no mechanism in SBML Level 2 for representing hierarchies of
032 * compartment types.  One {@link CompartmentType} instance cannot be the subtype
033 * of another {@link CompartmentType} instance; SBML provides no means of defining
034 * such relationships.
035 <p>
036 * As with other major structures in SBML, {@link CompartmentType} has a mandatory
037 * attribute, 'id', used to give the compartment type an identifier.  The
038 * identifier must be a text string conforming to the identifer syntax
039 * permitted in SBML.  {@link CompartmentType} also has an optional 'name'
040 * attribute, of type <code>string.</code>  The 'id' and 'name' must be used
041 * according to the guidelines described in the SBML specification (e.g.,
042 * Section 3.3 in the Level 2 Version 4 specification).
043 <p>
044 * {@link CompartmentType} was introduced in SBML Level 2 Version 2.  It is not
045 * available in SBML Level&nbsp;1 nor in Level&nbsp;3.
046 <p>
047 * @see Compartment
048 * @see ListOfCompartmentTypes
049 * @see SpeciesType
050 * @see ListOfSpeciesTypes
051 */
052
053public class CompartmentType extends SBase {
054   private long swigCPtr;
055
056   protected CompartmentType(long cPtr, boolean cMemoryOwn)
057   {
058     super(libsbmlJNI.CompartmentType_SWIGUpcast(cPtr), cMemoryOwn);
059     swigCPtr = cPtr;
060   }
061
062   protected static long getCPtr(CompartmentType obj)
063   {
064     return (obj == null) ? 0 : obj.swigCPtr;
065   }
066
067   protected static long getCPtrAndDisown (CompartmentType obj)
068   {
069     long ptr = 0;
070
071     if (obj != null)
072     {
073       ptr             = obj.swigCPtr;
074       obj.swigCMemOwn = false;
075     }
076
077     return ptr;
078   }
079
080  protected void finalize() {
081    delete();
082  }
083
084  public synchronized void delete() {
085    if (swigCPtr != 0) {
086      if (swigCMemOwn) {
087        swigCMemOwn = false;
088        libsbmlJNI.delete_CompartmentType(swigCPtr);
089      }
090      swigCPtr = 0;
091    }
092    super.delete();
093  }
094
095  
096/**
097   * Creates a new {@link CompartmentType} using the given SBML <code>level</code> and <code>version</code>
098   * values.
099   <p>
100   * @param level a long integer, the SBML Level to assign to this
101   * {@link CompartmentType}
102   <p>
103   * @param version a long integer, the SBML Version to assign to this
104   * {@link CompartmentType}
105   <p>
106   * @throws SBMLConstructorException 
107   * Thrown if the given <code>level</code> and <code>version</code> combination, or this kind
108   * of SBML object, are either invalid or mismatched with respect to the
109   * parent {@link SBMLDocument} object.
110   <p>
111   * <p>
112 * @note Upon the addition of a {@link CompartmentType} object to an {@link SBMLDocument} (e.g.,
113 * using {@link Model#addCompartmentType(CompartmentType c)}), the SBML
114 * Level, SBML Version and XML namespace of the document <em>override</em> the
115 * values used when creating the {@link CompartmentType} object via the {@link CompartmentType}
116 * constructors.  This is necessary to ensure that an SBML document has a
117 * consistent overall structure.  Nevertheless, the ability to supply the
118 * values at the time of creation of a {@link CompartmentType} is an important aid to
119 * producing valid SBML.  Knowledge of the intented SBML Level and Version
120 * determine whether it is valid to assign a particular value to an
121 * attribute, or whether it is valid to add an object to an existing
122 * {@link SBMLDocument}.
123   */ public
124 CompartmentType(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
125    this(libsbmlJNI.new_CompartmentType__SWIG_0(level, version), true);
126  }
127
128  
129/**
130   * Creates a new {@link CompartmentType} using the given {@link SBMLNamespaces} object
131   * <code>sbmlns</code>.
132   <p>
133   * <p>
134 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces
135 * information.  It is used to communicate the SBML Level, Version, and (in
136 * Level&nbsp;3) packages used in addition to SBML Level&nbsp;3 Core.  A
137 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an
138 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object
139 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments.
140   <p>
141   * It is worth emphasizing that although this constructor does not take an
142   * identifier argument, in SBML Level&nbsp;2 and beyond, the 'id'
143   * (identifier) attribute of a {@link CompartmentType} is required to have a value.
144   * Thus, callers are cautioned to assign a value after calling this
145   * constructor.  Setting the identifier can be accomplished using the
146   * method setId(String id).
147   <p>
148   * @param sbmlns an {@link SBMLNamespaces} object.
149   <p>
150   * @throws SBMLConstructorException 
151   * Thrown if the given <code>level</code> and <code>version</code> combination, or this kind
152   * of SBML object, are either invalid or mismatched with respect to the
153   * parent {@link SBMLDocument} object.
154   <p>
155   * <p>
156 * @note Upon the addition of a {@link CompartmentType} object to an {@link SBMLDocument} (e.g.,
157 * using {@link Model#addCompartmentType(CompartmentType c)}), the SBML
158 * Level, SBML Version and XML namespace of the document <em>override</em> the
159 * values used when creating the {@link CompartmentType} object via the {@link CompartmentType}
160 * constructors.  This is necessary to ensure that an SBML document has a
161 * consistent overall structure.  Nevertheless, the ability to supply the
162 * values at the time of creation of a {@link CompartmentType} is an important aid to
163 * producing valid SBML.  Knowledge of the intented SBML Level and Version
164 * determine whether it is valid to assign a particular value to an
165 * attribute, or whether it is valid to add an object to an existing
166 * {@link SBMLDocument}.
167   */ public
168 CompartmentType(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
169    this(libsbmlJNI.new_CompartmentType__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
170  }
171
172  
173/**
174   * Copy constructor; creates a copy of this {@link CompartmentType}.
175   <p>
176   * @param orig the object to copy.
177   <p>
178   * @throws SBMLConstructorException 
179   * Thrown if the argument <code>orig</code> is <code>null.</code>
180   */ public
181 CompartmentType(CompartmentType orig) throws org.sbml.libsbml.SBMLConstructorException {
182    this(libsbmlJNI.new_CompartmentType__SWIG_2(CompartmentType.getCPtr(orig), orig), true);
183  }
184
185  
186/**
187   * Creates and returns a deep copy of this {@link CompartmentType}.
188   <p>
189   * @return a (deep) copy of this {@link CompartmentType}.
190   */ public
191 CompartmentType cloneObject() {
192    long cPtr = libsbmlJNI.CompartmentType_cloneObject(swigCPtr, this);
193    return (cPtr == 0) ? null : new CompartmentType(cPtr, true);
194  }
195
196  
197/**
198   * Returns the value of the 'id' attribute of this {@link CompartmentType}.
199   <p>
200   * @return the id of this {@link CompartmentType}.
201   */ public
202 String getId() {
203    return libsbmlJNI.CompartmentType_getId(swigCPtr, this);
204  }
205
206  
207/**
208   * Returns the value of the 'name' attribute of this {@link CompartmentType}.
209   <p>
210   * @return the name of this {@link CompartmentType}.
211   */ public
212 String getName() {
213    return libsbmlJNI.CompartmentType_getName(swigCPtr, this);
214  }
215
216  
217/**
218   * Predicate returning <code>true</code> if this
219   * {@link CompartmentType}'s 'id' attribute is set.
220   <p>
221   * @return <code>true</code> if the 'id' attribute of this {@link CompartmentType} is
222   * set, <code>false</code> otherwise.
223   */ public
224 boolean isSetId() {
225    return libsbmlJNI.CompartmentType_isSetId(swigCPtr, this);
226  }
227
228  
229/**
230   * Predicate returning <code>true</code> if this
231   * {@link CompartmentType}'s 'name' attribute is set.
232   <p>
233   * @return <code>true</code> if the 'name' attribute of this {@link CompartmentType} is
234   * set, <code>false</code> otherwise.
235   */ public
236 boolean isSetName() {
237    return libsbmlJNI.CompartmentType_isSetName(swigCPtr, this);
238  }
239
240  
241/**
242   * Sets the value of the 'id' attribute of this {@link CompartmentType}.
243   <p>
244   * The string <code>sid</code> is copied.
245   <p>
246   * <p>
247 * SBML has strict requirements for the syntax of identifiers, that is, the
248 * values of the 'id' attribute present on most types of SBML objects.
249 * The following is a summary of the definition of the SBML identifier type 
250 * <code>SId</code>, which defines the permitted syntax of identifiers.  We
251 * express the syntax using an extended form of BNF notation: 
252 * <pre style='margin-left: 2em; border: none; font-weight: bold; font-size: 13px; color: black'>
253 * letter .= 'a'..'z','A'..'Z'
254 * digit  .= '0'..'9'
255 * idChar .= letter | digit | '_'
256 * SId    .= ( letter | '_' ) idChar*
257 * </pre>
258 * The characters <code>(</code> and <code>)</code> are used for grouping, the
259 * character <code>*</code> 'zero or more times', and the character
260 * <code>|</code> indicates logical 'or'.  The equality of SBML identifiers is
261 * determined by an exact character sequence match; i.e., comparisons must be
262 * performed in a case-sensitive manner.  In addition, there are a few
263 * conditions for the uniqueness of identifiers in an SBML model.  Please
264 * consult the SBML specifications for the exact details of the uniqueness
265 * requirements.
266   <p>
267   * @param sid the string to use as the identifier of this {@link CompartmentType}
268   <p>
269   * @return integer value indicating success/failure of the
270   * function.   The possible values
271   * returned by this function are:
272   * <ul>
273   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
274   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE }
275   * </ul>
276   */ public
277 int setId(String sid) {
278    return libsbmlJNI.CompartmentType_setId(swigCPtr, this, sid);
279  }
280
281  
282/**
283   * Sets the value of the 'name' attribute of this {@link CompartmentType}.
284   <p>
285   * The string in <code>name</code> is copied.
286   <p>
287   * @param name the new name for the {@link CompartmentType}
288   <p>
289   * @return integer value indicating success/failure of the
290   * function.   The possible values
291   * returned by this function are:
292   * <ul>
293   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
294   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE }
295   * </ul>
296   */ public
297 int setName(String name) {
298    return libsbmlJNI.CompartmentType_setName(swigCPtr, this, name);
299  }
300
301  
302/**
303   * Unsets the value of the 'name' attribute of this {@link CompartmentType}.
304   <p>
305   * @return integer value indicating success/failure of the
306   * function.   The possible values
307   * returned by this function are:
308   * <ul>
309   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
310   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED }
311   * </ul>
312   */ public
313 int unsetName() {
314    return libsbmlJNI.CompartmentType_unsetName(swigCPtr, this);
315  }
316
317  
318/**
319   * Returns the libSBML type code for this SBML object.
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_COMPARTMENT_TYPE SBML_COMPARTMENT_TYPE} (default).
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.CompartmentType_getTypeCode(swigCPtr, this);
346  }
347
348  
349/**
350   * Returns the XML element name of this object, which for
351   * {@link CompartmentType}, is always <code>'compartmentType'.</code>
352   <p>
353   * @return the name of this element, i.e., <code>'compartmentType'.</code>
354   */ public
355 String getElementName() {
356    return libsbmlJNI.CompartmentType_getElementName(swigCPtr, this);
357  }
358
359  
360/**
361   * Predicate returning <code>true</code> if
362   * all the required attributes for this {@link CompartmentType} object
363   * have been set.
364   <p>
365   * @note The required attributes for a {@link CompartmentType} object are:
366   * <ul>
367   * <li> 'id'
368   *
369   * </ul> <p>
370   * @return a boolean value indicating whether all the required
371   * attributes for this object have been defined.
372   */ public
373 boolean hasRequiredAttributes() {
374    return libsbmlJNI.CompartmentType_hasRequiredAttributes(swigCPtr, this);
375  }
376
377}