001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 2.0.11
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 * 
013 * Implementation of SBML's Level 2's CompartmentType 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 * <p>
052 * <p>
053 */
054
055public class CompartmentType extends SBase {
056   private long swigCPtr;
057
058   protected CompartmentType(long cPtr, boolean cMemoryOwn)
059   {
060     super(libsbmlJNI.CompartmentType_SWIGUpcast(cPtr), cMemoryOwn);
061     swigCPtr = cPtr;
062   }
063
064   protected static long getCPtr(CompartmentType obj)
065   {
066     return (obj == null) ? 0 : obj.swigCPtr;
067   }
068
069   protected static long getCPtrAndDisown (CompartmentType obj)
070   {
071     long ptr = 0;
072
073     if (obj != null)
074     {
075       ptr             = obj.swigCPtr;
076       obj.swigCMemOwn = false;
077     }
078
079     return ptr;
080   }
081
082  protected void finalize() {
083    delete();
084  }
085
086  public synchronized void delete() {
087    if (swigCPtr != 0) {
088      if (swigCMemOwn) {
089        swigCMemOwn = false;
090        libsbmlJNI.delete_CompartmentType(swigCPtr);
091      }
092      swigCPtr = 0;
093    }
094    super.delete();
095  }
096
097  
098/**
099   * Creates a new {@link CompartmentType} using the given SBML <code>level</code> and <code>version</code>
100   * values.
101   * <p>
102   * @param level a long integer, the SBML Level to assign to this {@link CompartmentType}
103   * <p>
104   * @param version a long integer, the SBML Version to assign to this
105   * {@link CompartmentType}
106   * <p>
107   * @throws SBMLConstructorException 
108   * Thrown if the given <code>level</code> and <code>version</code> combination, or this kind
109   * of SBML object, are either invalid or mismatched with respect to the
110   * parent {@link SBMLDocument} object.
111   * <p>
112   * @note Upon the addition of a {@link CompartmentType} object to an {@link SBMLDocument}
113   * (e.g., using {@link Model#addCompartmentType(CompartmentType ct)}), the SBML Level, SBML
114   * Version and XML namespace of the document <em>override</em> the
115   * values used when creating the {@link CompartmentType} object via this
116   * constructor.  This is necessary to ensure that an SBML document is a
117   * consistent structure.  Nevertheless, the ability to supply the values
118   * 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
120   * Version determine whether it is valid to assign a particular value to
121   * an 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   * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces
134   * information.  It is used to communicate the SBML Level, Version, and
135   * (in Level&nbsp;3) packages used in addition to SBML Level&nbsp;3 Core.
136   * A common approach to using this class constructor is to create an
137   * {@link SBMLNamespaces} object somewhere in a program, once, then pass it to
138   * object constructors such as this one when needed.
139   * <p>
140   * It is worth emphasizing that although this constructor does not take
141   * an identifier argument, in SBML Level&nbsp;2 and beyond, the 'id'
142   * (identifier) attribute of a {@link CompartmentType} is required to have a value.
143   * Thus, callers are cautioned to assign a value after calling this
144   * constructor.  Setting the identifier can be accomplished using the
145   * method setId(String id).
146   * <p>
147   * @param sbmlns an {@link SBMLNamespaces} object.
148   * <p>
149   * @throws SBMLConstructorException 
150   * Thrown if the given <code>level</code> and <code>version</code> combination, or this kind
151   * of SBML object, are either invalid or mismatched with respect to the
152   * parent {@link SBMLDocument} object.
153   * <p>
154   * @note Upon the addition of a {@link CompartmentType} object to an {@link SBMLDocument}
155   * (e.g., using {@link Model#addCompartmentType(CompartmentType ct)}), the SBML XML namespace of
156   * the document <em>overrides</em> the value used when creating the
157   * {@link CompartmentType} object via this constructor.  This is necessary to
158   * ensure that an SBML document is a consistent structure.  Nevertheless,
159   * the ability to supply the values at the time of creation of a
160   * {@link CompartmentType} is an important aid to producing valid SBML.
161   * Knowledge of the intented SBML Level and Version determine whether it
162   * is valid to assign a particular value to an attribute, or whether it
163   * is valid to add an object to an existing {@link SBMLDocument}.
164   */ public
165 CompartmentType(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
166    this(libsbmlJNI.new_CompartmentType__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
167  }
168
169  
170/**
171   * Copy constructor; creates a copy of this {@link CompartmentType}.
172   * <p>
173   * @param orig the object to copy.
174   * <p>
175   * @throws SBMLConstructorException 
176   * Thrown if the argument <code>orig</code> is <code>null.</code>
177   */ public
178 CompartmentType(CompartmentType orig) throws org.sbml.libsbml.SBMLConstructorException {
179    this(libsbmlJNI.new_CompartmentType__SWIG_2(CompartmentType.getCPtr(orig), orig), true);
180  }
181
182  
183/**
184   * Creates and returns a deep copy of this {@link CompartmentType}.
185   * <p>
186   * @return a (deep) copy of this {@link CompartmentType}.
187   */ public
188 CompartmentType cloneObject() {
189    long cPtr = libsbmlJNI.CompartmentType_cloneObject(swigCPtr, this);
190    return (cPtr == 0) ? null : new CompartmentType(cPtr, true);
191  }
192
193  
194/**
195   * Returns the value of the 'id' attribute of this {@link CompartmentType}.
196   * <p>
197   * @return the id of this {@link CompartmentType}.
198   */ public
199 String getId() {
200    return libsbmlJNI.CompartmentType_getId(swigCPtr, this);
201  }
202
203  
204/**
205   * Returns the value of the 'name' attribute of this {@link CompartmentType}.
206   * <p>
207   * @return the name of this {@link CompartmentType}.
208   */ public
209 String getName() {
210    return libsbmlJNI.CompartmentType_getName(swigCPtr, this);
211  }
212
213  
214/**
215   * Predicate returning <code>true</code> if this
216   * {@link CompartmentType}'s 'id' attribute is set.
217   * <p>
218   * @return <code>true</code> if the 'id' attribute of this {@link CompartmentType} is
219   * set, <code>false</code> otherwise.
220   */ public
221 boolean isSetId() {
222    return libsbmlJNI.CompartmentType_isSetId(swigCPtr, this);
223  }
224
225  
226/**
227   * Predicate returning <code>true</code> if this
228   * {@link CompartmentType}'s 'name' attribute is set.
229   * <p>
230   * @return <code>true</code> if the 'name' attribute of this CompartmentTypeType is
231   * set, <code>false</code> otherwise.
232   */ public
233 boolean isSetName() {
234    return libsbmlJNI.CompartmentType_isSetName(swigCPtr, this);
235  }
236
237  
238/**
239   * Sets the value of the 'id' attribute of this {@link CompartmentType}.
240   * <p>
241   * The string <code>sid</code> is copied.  Note that SBML has strict requirements
242   * for the syntax of identifiers.  The following is a summary of the definition of the SBML identifier type 
243<code>SId</code>, which defines the permitted syntax of identifiers.  We
244express the syntax using an extended form of BNF notation: 
245<pre style='margin-left: 2em; border: none; font-weight: bold; font-size: 13px; color: black'>
246letter .= 'a'..'z','A'..'Z'
247digit  .= '0'..'9'
248idChar .= letter | digit | '_'
249SId    .= ( letter | '_' ) idChar*
250</pre>
251The characters <code>(</code> and <code>)</code> are used for grouping, the
252character <code>*</code> 'zero or more times', and the character
253<code>|</code> indicates logical 'or'.  The equality of SBML identifiers is
254determined by an exact character sequence match; i.e., comparisons must be
255performed in a case-sensitive manner.  In addition, there are a few
256conditions for the uniqueness of identifiers in an SBML model.  Please
257consult the SBML specifications for the exact formulations.
258<p>
259
260   * <p>
261   * @param sid the string to use as the identifier of this {@link CompartmentType}
262   * <p>
263   * @return integer value indicating success/failure of the
264   * function.   The possible values
265   * returned by this function are:
266   * <ul>
267   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
268   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE }
269   * </ul>
270   */ public
271 int setId(String sid) {
272    return libsbmlJNI.CompartmentType_setId(swigCPtr, this, sid);
273  }
274
275  
276/**
277   * Sets the value of the 'name' attribute of this {@link CompartmentType}.
278   * <p>
279   * The string in <code>name</code> is copied.
280   * <p>
281   * @param name the new name for the {@link CompartmentType}
282   * <p>
283   * @return integer value indicating success/failure of the
284   * function.   The possible values
285   * returned by this function are:
286   * <ul>
287   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
288   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE }
289   * </ul>
290   */ public
291 int setName(String name) {
292    return libsbmlJNI.CompartmentType_setName(swigCPtr, this, name);
293  }
294
295  
296/**
297   * Unsets the value of the 'name' attribute of this {@link CompartmentType}.
298   * <p>
299   * @return integer value indicating success/failure of the
300   * function.   The possible values
301   * returned by this function are:
302   * <ul>
303   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
304   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED }
305   * </ul>
306   */ public
307 int unsetName() {
308    return libsbmlJNI.CompartmentType_unsetName(swigCPtr, this);
309  }
310
311  
312/**
313   * Returns the libSBML type code for this SBML object.
314   * <p>
315   * LibSBML attaches an identifying code to every
316   * kind of SBML object.  These are known as <em>SBML type codes</em>.  In
317   * other languages, the set of type codes is stored in an enumeration; in
318   * the Java language interface for libSBML, the type codes are defined as
319   * static integer constants in the interface class {@link
320   * libsbmlConstants}.  The names of the type codes all begin with the
321   * characters <code>SBML_.</code> 
322   * <p>
323   * @return the SBML type code for this object, or {@link  libsbmlConstants#SBML_UNKNOWN SBML_UNKNOWN} (default).
324   * <p>
325   * @see #getElementName()
326   */ public
327 int getTypeCode() {
328    return libsbmlJNI.CompartmentType_getTypeCode(swigCPtr, this);
329  }
330
331  
332/**
333   * Returns the XML element name of this object, which for
334   * {@link CompartmentType}, is always <code>'compartmentType'.</code>
335   * <p>
336   * @return the name of this element, i.e., <code>'compartmentType'.</code>
337   */ public
338 String getElementName() {
339    return libsbmlJNI.CompartmentType_getElementName(swigCPtr, this);
340  }
341
342  
343/**
344   * Predicate returning <code>true</code> if
345   * all the required attributes for this {@link CompartmentType} object
346   * have been set.
347   * <p>
348   * @note The required attributes for a {@link CompartmentType} object are:
349   * <ul>
350   * <li> 'id'
351   * </ul>
352   * <p>
353   * @return a boolean value indicating whether all the required
354   * attributes for this object have been defined.
355   */ public
356 boolean hasRequiredAttributes() {
357    return libsbmlJNI.CompartmentType_hasRequiredAttributes(swigCPtr, this);
358  }
359
360}