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-fbc"><a href="group__fbc.html">fbc</a></span>
013 Implementation of the 'fbc' proposed package Association
014 * construct.
015 <p>
016 * The {@link Association} class is not part of the official Flux Balance
017 * specification, but is instead a proposed future development of the
018 * package.  If adopted, it would be a child of a {@link GeneAssociation} that would
019 * describe a single 'and' or 'or' relationship between two or more genes or
020 * other associations.
021 */
022
023public class Association extends SBase {
024   private long swigCPtr;
025
026   protected Association(long cPtr, boolean cMemoryOwn)
027   {
028     super(libsbmlJNI.Association_SWIGUpcast(cPtr), cMemoryOwn);
029     swigCPtr = cPtr;
030   }
031
032   protected static long getCPtr(Association obj)
033   {
034     return (obj == null) ? 0 : obj.swigCPtr;
035   }
036
037   protected static long getCPtrAndDisown (Association obj)
038   {
039     long ptr = 0;
040
041     if (obj != null)
042     {
043       ptr             = obj.swigCPtr;
044       obj.swigCMemOwn = false;
045     }
046
047     return ptr;
048   }
049
050  protected void finalize() {
051    delete();
052  }
053
054  public synchronized void delete() {
055    if (swigCPtr != 0) {
056      if (swigCMemOwn) {
057        swigCMemOwn = false;
058        libsbmlJNI.delete_Association(swigCPtr);
059      }
060      swigCPtr = 0;
061    }
062    super.delete();
063  }
064
065  
066/**
067   * Creates a new {@link Association} with the given level, version, and package version.
068   */ public
069 Association(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException {
070    this(libsbmlJNI.new_Association__SWIG_0(level, version, pkgVersion), true);
071  }
072
073  
074/**
075   * Creates a new {@link Association} with the given level, version, and package version.
076   */ public
077 Association(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
078    this(libsbmlJNI.new_Association__SWIG_1(level, version), true);
079  }
080
081  
082/**
083   * Creates a new {@link Association} with the given level, version, and package version.
084   */ public
085 Association(long level) throws org.sbml.libsbml.SBMLConstructorException {
086    this(libsbmlJNI.new_Association__SWIG_2(level), true);
087  }
088
089  
090/**
091   * Creates a new {@link Association} with the given level, version, and package version.
092   */ public
093 Association() throws org.sbml.libsbml.SBMLConstructorException {
094    this(libsbmlJNI.new_Association__SWIG_3(), true);
095  }
096
097  
098/** */ public
099 Association(XMLNode node, FbcPkgNamespaces fbcns) throws org.sbml.libsbml.SBMLConstructorException {
100    this(libsbmlJNI.new_Association__SWIG_4(XMLNode.getCPtr(node), node, FbcPkgNamespaces.getCPtr(fbcns), fbcns), true);
101  }
102
103  
104/**
105   * Creates a new {@link Association} with the given {@link FbcPkgNamespaces} object.
106   */ public
107 Association(FbcPkgNamespaces fbcns) throws org.sbml.libsbml.SBMLConstructorException {
108    this(libsbmlJNI.new_Association__SWIG_5(FbcPkgNamespaces.getCPtr(fbcns), fbcns), true);
109  }
110
111  
112/**
113   * Copy constructor.
114   */ public
115 Association(Association source) throws org.sbml.libsbml.SBMLConstructorException {
116    this(libsbmlJNI.new_Association__SWIG_6(Association.getCPtr(source), source), true);
117  }
118
119  
120/**
121   * Returns the string of the 'type' attribute of this {@link Association}.
122   <p>
123   * @return the string of the 'type' attribute of this {@link Association}.
124   */ public
125 int getType() {
126    return libsbmlJNI.Association_getType(swigCPtr, this);
127  }
128
129  
130/**
131   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
132   * {@link Association}'s 'type' attribute has been set.
133   <p>
134   * @return <code>true</code> if this {@link Association}'s 'type' attribute has been set, 
135   * otherwise <code>false</code> is returned.
136   */ public
137 boolean isSetType() {
138    return libsbmlJNI.Association_isSetType(swigCPtr, this);
139  }
140
141  
142/**
143   * Sets the SIdRef string of the 'type' attribute of this {@link Association}.
144   <p>
145   * @param type a SIdRef string to be set.
146   <p>
147   * @return integer value indicating success/failure of the
148   * operation. The possible return values are:
149   * <ul>
150   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
151   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE }
152   * </ul>
153   */ public
154 int setType(int type) {
155    return libsbmlJNI.Association_setType(swigCPtr, this, type);
156  }
157
158  
159/**
160   * Unsets the value of the 'id' attribute of this {@link Association}.
161   <p>
162   * @return integer value indicating success/failure of the
163   * operation. The possible return values are:
164   * <ul>
165   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
166   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED }
167   * </ul>
168   */ public
169 int unsetType() {
170    return libsbmlJNI.Association_unsetType(swigCPtr, this);
171  }
172
173  
174/**
175   * Returns the string of the 'reference' attribute of this {@link Association}.
176   <p>
177   * @return the string of the 'reference' attribute of this {@link Association}.
178   */ public
179 String getReference() {
180    return libsbmlJNI.Association_getReference(swigCPtr, this);
181  }
182
183  
184/**
185   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
186   * {@link Association}'s 'reference' attribute has been set.
187   <p>
188   * @return <code>true</code> if this {@link Association}'s 'reference' attribute has been set, 
189   * otherwise <code>false</code> is returned.
190   */ public
191 boolean isSetReference() {
192    return libsbmlJNI.Association_isSetReference(swigCPtr, this);
193  }
194
195  
196/**
197   * Sets the SIdRef string of the 'reference' attribute of this {@link Association}.
198   <p>
199   * @param reference a SIdRef string to be set.
200   <p>
201   * @return integer value indicating success/failure of the
202   * operation. The possible return values are:
203   * <ul>
204   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
205   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE }
206   * </ul>
207   */ public
208 int setReference(String reference) {
209    return libsbmlJNI.Association_setReference(swigCPtr, this, reference);
210  }
211
212  
213/**
214   * Unsets the value of the 'id' attribute of this {@link Association}.
215   <p>
216   * @return integer value indicating success/failure of the
217   * operation. The possible return values are:
218   * <ul>
219   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
220   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED }
221   * </ul>
222   */ public
223 int unsetReference() {
224    return libsbmlJNI.Association_unsetReference(swigCPtr, this);
225  }
226
227  
228/**
229   * Add a gene with the given <code>id</code> to the association.
230   */ public
231 int addGene(String id) {
232    return libsbmlJNI.Association_addGene(swigCPtr, this, id);
233  }
234
235  
236/**
237   * Returns the number of child Associations of this {@link Association}.
238   */ public
239 long getNumAssociations() {
240    return libsbmlJNI.Association_getNumAssociations(swigCPtr, this);
241  }
242
243  
244/**
245   * Adds a child {@link Association} to this {@link Association}.
246   */ public
247 int addAssociation(Association association) {
248    return libsbmlJNI.Association_addAssociation(swigCPtr, this, Association.getCPtr(association), association);
249  }
250
251  
252/**
253   * Removes the child Associations with the given <code>index</code> from this {@link Association}.
254   */ public
255 int removeAssociation(int index) {
256    return libsbmlJNI.Association_removeAssociation(swigCPtr, this, index);
257  }
258
259  
260/**
261   * Returns the number of child Associations of this {@link Association}.
262   */ public
263 int clearAssociations() {
264    return libsbmlJNI.Association_clearAssociations(swigCPtr, this);
265  }
266
267  
268/**
269   * Creates and returns a new {@link Association} of type 'and'.  Does not actually add the created {@link Association} as a child of this {@link Association} or do anything else with it--the returning pointer is now owned by the caller.
270   */ public
271 Association createAnd() {
272    long cPtr = libsbmlJNI.Association_createAnd(swigCPtr, this);
273    return (cPtr == 0) ? null : new Association(cPtr, false);
274  }
275
276  
277/**
278   * Creates and returns a new {@link Association} of type 'or'.  Does not actually add the created {@link Association} as a child of this {@link Association} or do anything else with it--the returning pointer is now owned by the caller.
279   */ public
280 Association createOr() {
281    long cPtr = libsbmlJNI.Association_createOr(swigCPtr, this);
282    return (cPtr == 0) ? null : new Association(cPtr, false);
283  }
284
285  
286/**
287   * Creates and returns a new {@link Association} of type 'and', and with the gene reference <code>reference</code>.  Does not actually add the created {@link Association} as a child of this {@link Association} or do anything else with it--the returning pointer is now owned by the caller.
288   */ public
289 Association createGene(String reference) {
290    long cPtr = libsbmlJNI.Association_createGene__SWIG_0(swigCPtr, this, reference);
291    return (cPtr == 0) ? null : new Association(cPtr, false);
292  }
293
294  
295/**
296   * Creates and returns a new {@link Association} of type 'and', and with the gene reference <code>reference</code>.  Does not actually add the created {@link Association} as a child of this {@link Association} or do anything else with it--the returning pointer is now owned by the caller.
297   */ public
298 Association createGene() {
299    long cPtr = libsbmlJNI.Association_createGene__SWIG_1(swigCPtr, this);
300    return (cPtr == 0) ? null : new Association(cPtr, false);
301  }
302
303  
304/**
305   * Creates an {@link XMLNode} object from this.
306   */ public
307 XMLNode toXML() {
308    return new XMLNode(libsbmlJNI.Association_toXML(swigCPtr, this), true);
309  }
310
311  
312/**
313   * Returns the XML element name of
314   * this SBML object.
315   <p>
316   * @return the string of the name of this element.
317   */ public
318 String getElementName() {
319    return libsbmlJNI.Association_getElementName(swigCPtr, this);
320  }
321
322  
323/**
324   * Creates and returns a deep copy of this {@link Association}.
325   <p>
326   * @return a (deep) copy of this {@link Association}.
327   */ public
328 Association cloneObject() {
329    long cPtr = libsbmlJNI.Association_cloneObject(swigCPtr, this);
330    return (cPtr == 0) ? null : new Association(cPtr, true);
331  }
332
333  
334/**
335   * Returns the libSBML type code of this object instance.
336   <p>
337   * <p>
338 * LibSBML attaches an identifying code to every kind of SBML object.  These
339 * are integer constants known as <em>SBML type codes</em>.  The names of all
340 * the codes begin with the characters &ldquo;<code>SBML_</code>&rdquo;. 
341 * In the Java language interface for libSBML, the
342 * type codes are defined as static integer constants in the interface class
343 * {@link libsbmlConstants}.    Note that different Level&nbsp;3 
344 * package plug-ins may use overlapping type codes; to identify the package
345 * to which a given object belongs, call the <code>getPackageName()</code>
346 * method on the object.
347   <p>
348   * @return the SBML type code for this object:
349   * {@link  libsbmlConstants#SBML_FBC_ASSOCIATION SBML_FBC_ASSOCIATION}
350   <p>
351   * <p>
352 * @warning <span class='warning'>The specific integer values of the possible
353 * type codes may be reused by different Level&nbsp;3 package plug-ins.
354 * Thus, to identifiy the correct code, <strong>it is necessary to invoke
355 * both getTypeCode() and getPackageName()</strong>.</span>
356   <p>
357   * @see #getElementName()
358   * @see #getPackageName()
359   */ public
360 int getTypeCode() {
361    return libsbmlJNI.Association_getTypeCode(swigCPtr, this);
362  }
363
364  
365/**
366   * Parses a gene association in infix format. These look like this: 
367   <p>
368   * (b2422) and (b2425) and (b2423) and (b2424) or (b2422) and (b2423) and (b2424) and (b2413) and (b3917)
369   <p>
370   * @return the parsed association, or <code>null</code> in case of an error.
371   */ public
372 static Association parseInfixAssociation(String association) {
373    long cPtr = libsbmlJNI.Association_parseInfixAssociation(association);
374    return (cPtr == 0) ? null : new Association(cPtr, false);
375  }
376
377  
378/** 
379   * Converts this association into an infix string.
380   <p>
381   <p>
382   * @return the association as infix string.
383   */ public
384 String toInfix() {
385    return libsbmlJNI.Association_toInfix(swigCPtr, this);
386  }
387
388}