001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.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 * Wrapper class for the C++ standard file stream <code>ofstream</code>.
013 <p>
014 * The C++ <code>ofstream</code> ('output file stream') provides an
015 * interface for writing data to files as output streams.  This class,
016 * {@link OFStream}, wraps the C++ <code>ofstream</code> and provides an {@link OStream}
017 * interface to it.  The file to be associated with the stream can be
018 * specified as a parameter to the constructors in this class.
019 <p>
020 * This class may be useful because some libSBML methods accept an argument
021 * for indicating where to send text string output.  An example is the
022 * {@link SBMLDocument#printErrors(OStream stream)} method.  The methods use C++ style streams
023 * and not Java stream objects.  The {@link OStream} object exists to bridge the
024 * Java and underlying native implementation.  It is a simple wrapper
025 * around the underlying stream object and provides a few basic methods for
026 * manipulating it.
027 */
028
029public class OFStream extends OStream {
030   private long swigCPtr;
031
032   protected OFStream(long cPtr, boolean cMemoryOwn)
033   {
034     super(libsbmlJNI.OFStream_SWIGUpcast(cPtr), cMemoryOwn);
035     swigCPtr = cPtr;
036   }
037
038   protected static long getCPtr(OFStream obj)
039   {
040     return (obj == null) ? 0 : obj.swigCPtr;
041   }
042
043   protected static long getCPtrAndDisown (OFStream obj)
044   {
045     long ptr = 0;
046
047     if (obj != null)
048     {
049       ptr             = obj.swigCPtr;
050       obj.swigCMemOwn = false;
051     }
052
053     return ptr;
054   }
055
056  protected void finalize() {
057    delete();
058  }
059
060  public synchronized void delete() {
061    if (swigCPtr != 0) {
062      if (swigCMemOwn) {
063        swigCMemOwn = false;
064        libsbmlJNI.delete_OFStream(swigCPtr);
065      }
066      swigCPtr = 0;
067    }
068    super.delete();
069  }
070
071  
072/**
073     * Creates a new {@link OFStream} object for a file.
074     <p>
075     * This opens the given file <code>filename</code> with the <code>is_append</code> flag
076     * (default is <code>false</code>), and creates an {@link OFStream} object
077     * instance that associates the file's content with an {@link OStream} object.
078     <p>
079     * @param filename the name of the file to open
080     * @param is_append whether to open the file for appending (default:
081     * <code>false</code>, meaning overwrite the content instead)
082     <p>
083     * 
084</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd>
085The native C++ implementation of this method defines a default argument
086value. In the documentation generated for different libSBML language
087bindings, you may or may not see corresponding arguments in the method
088declarations. For example, in Java and C#, a default argument is handled by
089declaring two separate methods, with one of them having the argument and
090the other one lacking the argument. However, the libSBML documentation will
091be <em>identical</em> for both methods. Consequently, if you are reading
092this and do not see an argument even though one is described, please look
093for descriptions of other variants of this method near where this one
094appears in the documentation.
095</dd></dl>
096 
097     */ public
098 OFStream(String filename, boolean is_append) {
099    this(libsbmlJNI.new_OFStream__SWIG_0(libsbml.getAbsolutePath(filename), is_append), true);
100  }
101
102  
103/**
104     * Creates a new {@link OFStream} object for a file.
105     <p>
106     * This opens the given file <code>filename</code> with the <code>is_append</code> flag
107     * (default is <code>false</code>), and creates an {@link OFStream} object
108     * instance that associates the file's content with an {@link OStream} object.
109     <p>
110     * @param filename the name of the file to open
111     * @param is_append whether to open the file for appending (default:
112     * <code>false</code>, meaning overwrite the content instead)
113     <p>
114     * 
115</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd>
116The native C++ implementation of this method defines a default argument
117value. In the documentation generated for different libSBML language
118bindings, you may or may not see corresponding arguments in the method
119declarations. For example, in Java and C#, a default argument is handled by
120declaring two separate methods, with one of them having the argument and
121the other one lacking the argument. However, the libSBML documentation will
122be <em>identical</em> for both methods. Consequently, if you are reading
123this and do not see an argument even though one is described, please look
124for descriptions of other variants of this method near where this one
125appears in the documentation.
126</dd></dl>
127 
128     */ public
129 OFStream(String filename) {
130    this(libsbmlJNI.new_OFStream__SWIG_1(libsbml.getAbsolutePath(filename)), true);
131  }
132
133  
134/**
135     * Opens a file and associates this stream object with it.
136     <p>
137     * This method opens a given file <code>filename</code> with the given
138     * <code>is_append</code> flag (whose default value is <code>false</code>),
139     * and associates <i>this</i> stream object with the file's content.
140     <p>
141     * @param filename the name of the file to open
142     * @param is_append whether to open the file for appending (default:
143     * <code>false</code>, meaning overwrite the content instead)
144     <p>
145     * 
146</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd>
147The native C++ implementation of this method defines a default argument
148value. In the documentation generated for different libSBML language
149bindings, you may or may not see corresponding arguments in the method
150declarations. For example, in Java and C#, a default argument is handled by
151declaring two separate methods, with one of them having the argument and
152the other one lacking the argument. However, the libSBML documentation will
153be <em>identical</em> for both methods. Consequently, if you are reading
154this and do not see an argument even though one is described, please look
155for descriptions of other variants of this method near where this one
156appears in the documentation.
157</dd></dl>
158 
159     */ public
160 void open(String filename, boolean is_append) {
161    libsbmlJNI.OFStream_open__SWIG_0(swigCPtr, this, libsbml.getAbsolutePath(filename), is_append);
162  }
163
164  
165/**
166     * Opens a file and associates this stream object with it.
167     <p>
168     * This method opens a given file <code>filename</code> with the given
169     * <code>is_append</code> flag (whose default value is <code>false</code>),
170     * and associates <i>this</i> stream object with the file's content.
171     <p>
172     * @param filename the name of the file to open
173     * @param is_append whether to open the file for appending (default:
174     * <code>false</code>, meaning overwrite the content instead)
175     <p>
176     * 
177</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd>
178The native C++ implementation of this method defines a default argument
179value. In the documentation generated for different libSBML language
180bindings, you may or may not see corresponding arguments in the method
181declarations. For example, in Java and C#, a default argument is handled by
182declaring two separate methods, with one of them having the argument and
183the other one lacking the argument. However, the libSBML documentation will
184be <em>identical</em> for both methods. Consequently, if you are reading
185this and do not see an argument even though one is described, please look
186for descriptions of other variants of this method near where this one
187appears in the documentation.
188</dd></dl>
189 
190     */ public
191 void open(String filename) {
192    libsbmlJNI.OFStream_open__SWIG_1(swigCPtr, this, libsbml.getAbsolutePath(filename));
193  }
194
195  
196/**
197     * Closes the file currently associated with this stream object.
198     */ public
199 void close() {
200    libsbmlJNI.OFStream_close(swigCPtr, this);
201  }
202
203  
204/**
205     * Returns <code>true</code> if this stream object is currently
206     * associated with a file.
207     <p>
208     * @return <code>true</code> if the stream object is currently
209     * associated with a file, <code>false</code> otherwise
210     */ public
211 boolean is_open() {
212    return libsbmlJNI.OFStream_is_open(swigCPtr, this);
213  }
214
215}