chemaxon.formats
Class MolExporter

java.lang.Object
  extended by chemaxon.formats.MolExporter

public class MolExporter
extends java.lang.Object

Molecule exporter class.

The output file format can be specified as an argument to the constructor of this class. Many different output file formats are supported like "mol", "sdf", "smiles", "png", "jpeg", etc.

Experimental feature (may change in the future!): "chemaxon.struc.Molecule" format for testing Molecule serialization.

Version:
5.1.1, 08/17/2008
Author:
Peter Csizmadia

Field Summary
static int C_CLOSE_STREAM
          Close the underlying stream.
static int C_FLUSH_STREAM
          Flush the output stream and force any buffered output bytes to be written out.
 
Constructor Summary
MolExporter(java.io.OutputStream out, java.lang.String fmtWithOpts)
          Creates a molecule exporter.
MolExporter(java.io.OutputStream out, java.lang.String fmtWithOpts, boolean text, java.lang.String[] incFields)
          Creates a molecule exporter.
MolExporter(java.io.OutputStream out, java.lang.String fmtWithOpts, boolean text, java.lang.String[] incFields, java.lang.String enc)
          Creates a molecule exporter.
MolExporter(java.io.OutputStream out, java.lang.String fmtWithOpts, java.lang.String enc)
          Creates a molecule exporter.
 
Method Summary
 void close()
          Closes the MolExportModule and the underlying stream.
 void close(int opts)
          Closes the MolExportModule and, optionally, the underlying stream.
protected  void finalize()
           
 void flush()
          Flushes the output stream and forces any buffered output bytes to be written out.
 java.lang.String getFormat()
          Gets the output file format.
 boolean isCleanable()
          Tests whether cleaning is meaningful for the chosen output format.
 void write(Molecule m)
          Writes a molecule into the stream.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C_CLOSE_STREAM

public static final int C_CLOSE_STREAM
Close the underlying stream.

Since:
Marvin 5.1.1, 08/17/2008
See Also:
close(int), Constant Field Values

C_FLUSH_STREAM

public static final int C_FLUSH_STREAM
Flush the output stream and force any buffered output bytes to be written out.

Since:
Marvin 5.1.1, 08/17/2008
See Also:
close(int), Constant Field Values
Constructor Detail

MolExporter

public MolExporter(java.io.OutputStream out,
                   java.lang.String fmtWithOpts)
            throws MolExportException,
                   java.io.IOException,
                   java.lang.IllegalArgumentException
Creates a molecule exporter.

Parameters:
out - the output stream
fmtWithOpts - the output file format and the options
Throws:
MolExportException - export error occured
java.io.IOException - output error occurred when writing the header
java.lang.IllegalArgumentException - Invalid format string (fmtWithOpts).
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported

MolExporter

public MolExporter(java.io.OutputStream out,
                   java.lang.String fmtWithOpts,
                   boolean text,
                   java.lang.String[] incFields)
            throws MolExportException,
                   java.io.IOException,
                   java.lang.IllegalArgumentException
Creates a molecule exporter.

Parameters:
out - the output stream
fmtWithOpts - the output file format and the options
text - write OS dependent line.separators instead of '\n'
incFields - SDF fields to include in table or null
Throws:
MolExportException - export error occured
java.io.IOException - output error occurred when writing the header
java.lang.IllegalArgumentException - Invalid format string (fmtWithOpts).
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported

MolExporter

public MolExporter(java.io.OutputStream out,
                   java.lang.String fmtWithOpts,
                   java.lang.String enc)
            throws MolExportException,
                   java.io.IOException,
                   java.lang.IllegalArgumentException
Creates a molecule exporter.

Parameters:
out - the output stream
fmtWithOpts - the output file format and the options
enc - charset name or null
Throws:
MolExportException - export error occured
java.io.IOException - output error occurred when writing the header
java.lang.IllegalArgumentException - Invalid format string (fmtWithOpts).
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported

MolExporter

public MolExporter(java.io.OutputStream out,
                   java.lang.String fmtWithOpts,
                   boolean text,
                   java.lang.String[] incFields,
                   java.lang.String enc)
            throws MolExportException,
                   java.io.IOException,
                   java.lang.IllegalArgumentException
Creates a molecule exporter.

Parameters:
out - the output stream
fmtWithOpts - the output file format and the options
text - write OS dependent line.separators instead of '\n'
incFields - SDF fields to include in table or null
enc - charset name or null
Throws:
MolExportException - export error occured
java.io.IOException - output error occurred when writing the header
java.lang.IllegalArgumentException - Invalid format string (fmtWithOpts).
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported
Method Detail

getFormat

public java.lang.String getFormat()
Gets the output file format.

Returns:
the format

isCleanable

public boolean isCleanable()
Tests whether cleaning is meaningful for the chosen output format.

Returns:
true if cleaning is meaningful, false otherwise
Since:
Marvin 4.1, 02/12/2006

write

public void write(Molecule m)
           throws MolExportException,
                  java.io.IOException
Writes a molecule into the stream.

Parameters:
m - the molecule
Throws:
MolExportException - export error
java.io.IOException

close

public void close()
           throws MolExportException,
                  java.io.IOException
Closes the MolExportModule and the underlying stream.

Throws:
MolExportException - export error.
java.io.IOException - in case of any other I/O error.

close

public void close(int opts)
           throws MolExportException,
                  java.io.IOException
Closes the MolExportModule and, optionally, the underlying stream.

Parameters:
opts - closing options, C_CLOSE_STREAM or C_FLUSH_STREAM.
Throws:
MolExportException - export error.
java.io.IOException - in case of any other I/O error.
Since:
Marvin 5.1.1, 08/17/2008

flush

public void flush()
           throws java.io.IOException
Flushes the output stream and forces any buffered output bytes to be written out.

Throws:
java.io.IOException - if an I/O error occurs.
Since:
Marvin 5.1.1, 08/15/2008

finalize

protected void finalize()
                 throws MolExportException,
                        java.io.IOException
Overrides:
finalize in class java.lang.Object
Throws:
MolExportException
java.io.IOException