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 Level 3's LocalParameter
013 * construct.
014 <p>
015 * {@link LocalParameter} has been introduced in SBML Level&nbsp;3 to serve as the
016 * object class for parameter definitions that are intended to be local to
017 * a {@link Reaction}.  Objects of class {@link LocalParameter} never appear at the {@link Model}
018 * level; they are always contained within {@link ListOfLocalParameters} lists
019 * which are in turn contained within {@link KineticLaw} objects.
020 <p>
021 * Like its global {@link Parameter} counterpart, the {@link LocalParameter} object class
022 * is used to define a symbol associated with a value; this symbol can then
023 * be used in a model's mathematical formulas (and specifically, for
024 * {@link LocalParameter}, reaction rate formulas).  Unlike {@link Parameter}, the
025 * {@link LocalParameter} class does not have a 'constant' attribute: local
026 * parameters within reactions are <em>always</em> constant.
027 <p>
028 * {@link LocalParameter} has one required attribute, 'id', to give the
029 * parameter a unique identifier by which other parts of an SBML model
030 * definition can refer to it.  A parameter can also have an optional
031 * 'name' attribute of type <code>string.</code>  Identifiers and names must be used
032 * according to the guidelines described in the SBML specifications.
033 <p>
034 * The optional attribute 'value' determines the value (of type <code>double</code>)
035 * assigned to the parameter.  A missing value for 'value' implies that
036 * the value either is unknown, or to be obtained from an external source,
037 * or determined by an initial assignment.  The unit of measurement
038 * associated with the value of the parameter can be specified using the
039 * optional attribute 'units'.  Here we only mention briefly some notable
040 * points about the possible unit choices, but readers are urged to consult
041 * the SBML specification documents for more information:
042 * <ul>
043 <p>
044 * <li> In SBML Level&nbsp;3, there are no constraints on the units that
045 * can be assigned to parameters in a model; there are also no units to
046 * inherit from the enclosing {@link Model} object.
047 <p>
048 * <li> In SBML Level&nbsp;2, the value assigned to the parameter's 'units'
049 * attribute must be chosen from one of the following possibilities: one of
050 * the base unit identifiers defined in SBML; one of the built-in unit
051 * identifiers <code>'substance'</code>, <code>'time'</code>, <code>'volume'</code>, <code>'area'</code> or 
052 * <code>'length'</code>; or the identifier of a new unit defined in the list of unit
053 * definitions in the enclosing {@link Model} structure.  There are no constraints
054 * on the units that can be chosen from these sets.  There are no default
055 * units for local parameters.
056 * </ul>
057 <p>
058 * As with all other major SBML components, {@link LocalParameter} is derived from
059 * {@link SBase}, and the methods defined on {@link SBase} are available on {@link LocalParameter}.
060 <p>
061 * @warning <span class='warning'>LibSBML derives {@link LocalParameter} from
062 * {@link Parameter}; however, this does not precisely match the object hierarchy
063 * defined by SBML Level&nbsp;3, where {@link LocalParameter} is derived directly
064 * from {@link SBase} and not {@link Parameter}.  We believe this arrangement makes it easier
065 * for libSBML users to program applications that work with both SBML
066 * Level&nbsp;2 and SBML Level&nbsp;3, but programmers should also keep in
067 * mind this difference exists.  A side-effect of libSBML's scheme is that
068 * certain methods on {@link LocalParameter} that are inherited from {@link Parameter} do not
069 * actually have relevance to {@link LocalParameter} objects.  An example of this is
070 * the methods pertaining to {@link Parameter}'s attribute 'constant' (i.e.,
071 * isSetConstant(), setConstant(), and getConstant()).</span>
072 <p>
073 * @see ListOfLocalParameters
074 * @see KineticLaw
075 */
076
077public class LocalParameter extends Parameter {
078   private long swigCPtr;
079
080   protected LocalParameter(long cPtr, boolean cMemoryOwn)
081   {
082     super(libsbmlJNI.LocalParameter_SWIGUpcast(cPtr), cMemoryOwn);
083     swigCPtr = cPtr;
084   }
085
086   protected static long getCPtr(LocalParameter obj)
087   {
088     return (obj == null) ? 0 : obj.swigCPtr;
089   }
090
091   protected static long getCPtrAndDisown (LocalParameter obj)
092   {
093     long ptr = 0;
094
095     if (obj != null)
096     {
097       ptr             = obj.swigCPtr;
098       obj.swigCMemOwn = false;
099     }
100
101     return ptr;
102   }
103
104  protected void finalize() {
105    delete();
106  }
107
108  public synchronized void delete() {
109    if (swigCPtr != 0) {
110      if (swigCMemOwn) {
111        swigCMemOwn = false;
112        libsbmlJNI.delete_LocalParameter(swigCPtr);
113      }
114      swigCPtr = 0;
115    }
116    super.delete();
117  }
118
119  
120/**
121   * Creates a new {@link LocalParameter} object with the given SBML <code>level</code> and
122   * <code>version</code> values.
123   <p>
124   * @param level a long integer, the SBML Level to assign to this
125   * {@link LocalParameter}.
126   <p>
127   * @param version a long integer, the SBML Version to assign to this
128   * {@link LocalParameter}.
129   <p>
130   * @throws SBMLConstructorException 
131   * Thrown if the given <code>level</code> and <code>version</code> combination, or this kind
132   * of SBML object, are either invalid or mismatched with respect to the
133   * parent {@link SBMLDocument} object.
134   <p>
135   * <p>
136 * @note Upon the addition of a {@link LocalParameter} object to an {@link SBMLDocument}
137 * (e.g., using {@link KineticLaw#addLocalParameter(LocalParameter p)}), the SBML Level, SBML
138 * Version and XML namespace of the document <em>override</em> the
139 * values used when creating the {@link LocalParameter} object via this
140 * constructor.  This is necessary to ensure that an SBML document is a
141 * consistent structure.  Nevertheless, the ability to supply the values
142 * at the time of creation of a {@link LocalParameter} is an important aid to
143 * producing valid SBML.  Knowledge of the intented SBML Level and
144 * Version determine whether it is valid to assign a particular value to
145 * an attribute, or whether it is valid to add an object to an existing
146 * {@link SBMLDocument}.
147   */ public
148 LocalParameter(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
149    this(libsbmlJNI.new_LocalParameter__SWIG_0(level, version), true);
150  }
151
152  
153/**
154   * Creates a new {@link LocalParameter} object with the given {@link SBMLNamespaces}
155   * object <code>sbmlns</code>.
156   <p>
157   * <p>
158 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces
159 * information.  It is used to communicate the SBML Level, Version, and (in
160 * Level&nbsp;3) packages used in addition to SBML Level&nbsp;3 Core.  A
161 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an
162 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object
163 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments. 
164   <p>
165   * It is worth emphasizing that although this constructor does not take
166   * an identifier argument, in SBML Level&nbsp;2 and beyond, the 'id'
167   * (identifier) attribute of a {@link LocalParameter} is required to have a value.
168   * Thus, callers are cautioned to assign a value after calling this
169   * constructor if no identifier is provided as an argument.  Setting the
170   * identifier can be accomplished using the method
171   * setId(String id).
172   <p>
173   * @param sbmlns an {@link SBMLNamespaces} object.
174   <p>
175   * @throws SBMLConstructorException 
176   * Thrown if the given <code>level</code> and <code>version</code> combination, or this kind
177   * of SBML object, are either invalid or mismatched with respect to the
178   * parent {@link SBMLDocument} object.
179   <p>
180   * <p>
181 * @note Upon the addition of a {@link Compartment} object to an {@link SBMLDocument},
182 * the SBML Level, SBML Version and XML namespace of the document 
183 * <em>override</em> the values used when creating the {@link Compartment} object via the
184 * {@link Compartment} constructors.  This is necessary to ensure that an SBML
185 * document has a consistent overall structure.  Nevertheless, the ability to
186 * supply the values at the time of creation of a {@link Compartment} is an important
187 * aid to producing valid SBML.  Knowledge of the intented SBML Level and
188 * Version determine whether it is valid to assign a particular value to an
189 * attribute, or whether it is valid to add an object to an existing
190 * {@link SBMLDocument}.
191   */ public
192 LocalParameter(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException {
193    this(libsbmlJNI.new_LocalParameter__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true);
194  }
195
196  
197/**
198   * Copy constructor; creates a copy of a given {@link LocalParameter} object.
199   <p>
200   * @param orig the {@link LocalParameter} instance to copy.
201   <p>
202   * @throws SBMLConstructorException 
203   * Thrown if the argument <code>orig</code> is <code>null.</code>
204   */ public
205 LocalParameter(LocalParameter orig) throws org.sbml.libsbml.SBMLConstructorException {
206    this(libsbmlJNI.new_LocalParameter__SWIG_2(LocalParameter.getCPtr(orig), orig), true);
207  }
208
209  
210/**
211   * Copy constructor; creates a {@link LocalParameter} object by copying
212   * the attributes of a given {@link Parameter} object.
213   <p>
214   * @param orig the {@link Parameter} instance to copy.
215   <p>
216   * @throws SBMLConstructorException 
217   * Thrown if the argument <code>orig</code> is <code>null.</code>
218   */ public
219 LocalParameter(Parameter orig) throws org.sbml.libsbml.SBMLConstructorException {
220    this(libsbmlJNI.new_LocalParameter__SWIG_3(Parameter.getCPtr(orig), orig), true);
221  }
222
223  
224/**
225   * Creates and returns a deep copy of this {@link LocalParameter}.
226   <p>
227   * @return a (deep) copy of this {@link LocalParameter}.
228   */ public
229 LocalParameter cloneObject() {
230    long cPtr = libsbmlJNI.LocalParameter_cloneObject(swigCPtr, this);
231    return (cPtr == 0) ? null : new LocalParameter(cPtr, true);
232  }
233
234  
235/**
236   * Constructs and returns a {@link UnitDefinition} that corresponds to the units
237   * of this {@link LocalParameter}'s value.
238   <p>
239   * <p>
240 * LocalParameters in SBML have an attribute ('units') for declaring the
241 * units of measurement intended for the parameter's value.  <b>No
242 * defaults are defined</b> by SBML in the absence of a definition for
243 * 'units'.  This method returns a {@link UnitDefinition} object based on the
244 * units declared for this {@link LocalParameter} using its 'units' attribute, or
245 * it returns <code>null</code> if no units have been declared.
246 <p>
247 * Note that unit declarations for {@link LocalParameter} objects are specified
248 * in terms of the <em>identifier</em> of a unit (e.g., using setUnits()), but
249 * <em>this</em> method returns a {@link UnitDefinition} object, not a unit
250 * identifier.  It does this by constructing an appropriate
251 * {@link UnitDefinition}.  For SBML Level&nbsp;2 models, it will do this even
252 * when the value of the 'units' attribute is one of the predefined SBML
253 * units <code>'substance'</code>, <code>'volume'</code>, <code>'area'</code>, <code>'length'</code> or 
254 * <code>'time'.</code>  Callers may find this useful in conjunction with the helper
255 * methods provided by the {@link UnitDefinition} class for comparing different
256 * {@link UnitDefinition} objects.
257   <p>
258   * @return a {@link UnitDefinition} that expresses the units of this 
259   * {@link LocalParameter}, or <code>null</code> if one cannot be constructed.
260   <p>
261   * @note The libSBML system for unit analysis depends on the model as a
262   * whole.  In cases where the {@link LocalParameter} object has not yet been
263   * added to a model, or the model itself is incomplete, unit analysis is
264   * not possible, and consequently this method will return <code>null.</code>
265   <p>
266   * @see #isSetUnits()
267   */ public
268 UnitDefinition getDerivedUnitDefinition() {
269    long cPtr = libsbmlJNI.LocalParameter_getDerivedUnitDefinition__SWIG_0(swigCPtr, this);
270    return (cPtr == 0) ? null : new UnitDefinition(cPtr, false);
271  }
272
273  
274/**
275   * Returns the libSBML type code for this SBML object.
276   <p>
277   * <p>
278 * LibSBML attaches an identifying code to every kind of SBML object.  These
279 * are integer constants known as <em>SBML type codes</em>.  The names of all
280 * the codes begin with the characters &ldquo;<code>SBML_</code>&rdquo;. 
281 * In the Java language interface for libSBML, the
282 * type codes are defined as static integer constants in the interface class
283 * {@link libsbmlConstants}.    Note that different Level&nbsp;3 
284 * package plug-ins may use overlapping type codes; to identify the package
285 * to which a given object belongs, call the <code>getPackageName()</code>
286 * method on the object.
287   <p>
288   * @return the SBML type code for this object:
289   * {@link  libsbmlConstants#SBML_LOCAL_PARAMETER SBML_LOCAL_PARAMETER} (default).
290   <p>
291   * <p>
292 * @warning <span class='warning'>The specific integer values of the possible
293 * type codes may be reused by different Level&nbsp;3 package plug-ins.
294 * Thus, to identifiy the correct code, <strong>it is necessary to invoke
295 * both getTypeCode() and getPackageName()</strong>.</span>
296   <p>
297   * @see #getElementName()
298   * @see #getPackageName()
299   */ public
300 int getTypeCode() {
301    return libsbmlJNI.LocalParameter_getTypeCode(swigCPtr, this);
302  }
303
304  
305/**
306   * Returns the XML element name of this object, which for {@link LocalParameter},
307   * is always <code>'localParameter'.</code>
308   <p>
309   * @return the name of this element, i.e., <code>'localParameter'.</code>
310   */ public
311 String getElementName() {
312    return libsbmlJNI.LocalParameter_getElementName(swigCPtr, this);
313  }
314
315  
316/**
317   * Predicate returning <code>true</code> if all the required attributes for this
318   * {@link LocalParameter} object have been set.
319   <p>
320   * @note The required attributes for a {@link LocalParameter} object are:
321   * <ul>
322   * <li> 'id'
323   * <li> 'value'
324   *
325   * </ul> <p>
326   * @return a boolean value indicating whether all the required
327   * attributes for this object have been defined.
328   */ public
329 boolean hasRequiredAttributes() {
330    return libsbmlJNI.LocalParameter_hasRequiredAttributes(swigCPtr, this);
331  }
332
333  
334/** * @internal */ public
335 boolean getConstant() {
336    return libsbmlJNI.LocalParameter_getConstant(swigCPtr, this);
337  }
338
339  
340/** * @internal */ public
341 boolean isSetConstant() {
342    return libsbmlJNI.LocalParameter_isSetConstant(swigCPtr, this);
343  }
344
345  
346/** * @internal */ public
347 int setConstant(boolean flag) {
348    return libsbmlJNI.LocalParameter_setConstant(swigCPtr, this, flag);
349  }
350
351}