chemaxon.formats
Class MolConverter

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

public class MolConverter
extends java.lang.Object

Converts between molecule file formats. See supported formats and their import and/or export options on the File Formats in Marvin page.

Version:
5.1.3, 10/20/2008
Author:
Peter Csizmadia, Szilveszter Juhos

Constructor Summary
MolConverter(java.io.InputStream in, java.io.OutputStream out, java.lang.String fmtopts, boolean useSysEOL)
          Create a MolConverter object.
MolConverter(java.io.InputStream in, java.lang.String ofname, java.lang.String fmtopts, boolean useSysEOL)
          Use this constructor if you do not need output buffering but want to determine output file positions.
MolConverter(java.util.Vector inFiles, java.io.OutputStream out, java.lang.String fmtopts, boolean useSysEOL)
          Create a MolConverter object.
MolConverter(java.util.Vector inFiles, java.lang.String ofname, java.lang.String fmtopts, boolean useSysEOL)
          Use this constructor if you do not need output buffering but want to determine output file positions.
MolConverter(java.util.Vector inFiles, java.util.Vector inOptions, java.io.OutputStream out, java.lang.String fmtopts, boolean useSysEOL)
          Create a MolConverter object.
MolConverter(java.util.Vector inFiles, java.util.Vector inOptions, java.io.OutputStream out, java.lang.String fmtopts, boolean useSysEOL, java.lang.String[] incFields)
          Create a MolConverter object.
MolConverter(java.util.Vector inFiles, java.util.Vector inOptions, java.io.OutputStream out, java.lang.String fmtopts, boolean useSysEOL, java.lang.String[] incFields, java.lang.String enc)
          Create a MolConverter object.
MolConverter(java.util.Vector inFiles, java.util.Vector inOptions, java.lang.String ofname, java.lang.String fmtopts, boolean useSysEOL)
          Use this constructor if you do not need output buffering but want to determine output file positions.
 
Method Summary
 void close()
          Close the underlying RandomAccessFile.
 boolean convert()
          Convert the next molecule.
static MolConverter createMolConverter(java.io.InputStream instream, java.io.OutputStream outstream, java.lang.String[] args, java.io.OutputStream[] theOut, int[] theVerbose)
          Creates a MolConverter instance with the attributes specified in the parameters.
static boolean isSupportedEncoding(java.lang.String enc)
          Test, whether the given charset name is supported by this JVM
static void main(java.lang.String[] args)
          Main method.
static void mainWithoutExit(java.lang.String[] args)
          Same as main(), but never calls System.exit().
 long otell()
          Get the current file position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MolConverter

public MolConverter(java.io.InputStream in,
                    java.io.OutputStream out,
                    java.lang.String fmtopts,
                    boolean useSysEOL)
             throws MolFormatException,
                    MolExportException,
                    java.io.IOException,
                    java.lang.IllegalArgumentException
Create a MolConverter object.

Parameters:
in - the input molecule stream to convert
out - the output stream
fmtopts - output file format with or without options
useSysEOL - write OS dependent line.separators instead of '\n'
Throws:
MolFormatException - If the molecule file is in a format that cannot be read
MolExportException - If the molecule cannot be exported in the specified format
java.io.IOException - If I/O error occured when determining the file format.
java.lang.IllegalArgumentException - Invalid format string (fmt).

MolConverter

public MolConverter(java.util.Vector inFiles,
                    java.util.Vector inOptions,
                    java.io.OutputStream out,
                    java.lang.String fmtopts,
                    boolean useSysEOL)
             throws MolFormatException,
                    MolExportException,
                    java.io.IOException,
                    java.lang.IllegalArgumentException
Create a MolConverter object.

Parameters:
inFiles - input file list
inOptions - import options
out - output stream
fmtopts - output file format with or without options
useSysEOL - write OS dependent line.separators instead of '\n'
Throws:
MolFormatException - If the molecule file is in a format that cannot be read
MolExportException - If the molecule cannot be exported in the specified format
java.io.IOException - If I/O error occured when determining the file format.
java.lang.IllegalArgumentException - Invalid format string (fmt).

MolConverter

public MolConverter(java.util.Vector inFiles,
                    java.util.Vector inOptions,
                    java.io.OutputStream out,
                    java.lang.String fmtopts,
                    boolean useSysEOL,
                    java.lang.String[] incFields)
             throws MolFormatException,
                    MolExportException,
                    java.io.IOException,
                    java.lang.IllegalArgumentException
Create a MolConverter object.

Parameters:
inFiles - input file list
inOptions - import options
out - output stream
fmtopts - output file format with or without options
useSysEOL - write OS dependent line.separators instead of '\n'
incFields - included fields of an SDfile to be shown in a table
Throws:
MolFormatException - If the molecule file is in a format that cannot be read
MolExportException - If the molecule cannot be exported in the specified format
java.io.IOException - If I/O error occured when determining the file format.
java.lang.IllegalArgumentException - Invalid format string (fmt).

MolConverter

public MolConverter(java.util.Vector inFiles,
                    java.util.Vector inOptions,
                    java.io.OutputStream out,
                    java.lang.String fmtopts,
                    boolean useSysEOL,
                    java.lang.String[] incFields,
                    java.lang.String enc)
             throws MolFormatException,
                    MolExportException,
                    java.io.IOException,
                    java.lang.IllegalArgumentException
Create a MolConverter object.

Parameters:
inFiles - input file list
inOptions - import options
out - output stream
fmtopts - output file format with or without options
useSysEOL - write OS dependent line.separators instead of '\n'
incFields - included fields of an SDfile to be shown in a table
enc - the input and/or output encodings in INCHARSET..OUTCHARSET format
Throws:
MolFormatException - If the molecule file is in a format that cannot be read
MolExportException - If the molecule cannot be exported in the specified format
java.io.IOException - If I/O error occured when determining the file format.
java.nio.charset.IllegalCharsetNameException - if illegal input or output encoding name specified
java.nio.charset.UnsupportedCharsetException - if the specified input or output encoding is unsupported
java.lang.IllegalArgumentException - Invalid format string (fmt).

MolConverter

public MolConverter(java.util.Vector inFiles,
                    java.io.OutputStream out,
                    java.lang.String fmtopts,
                    boolean useSysEOL)
             throws MolFormatException,
                    MolExportException,
                    java.io.IOException,
                    java.lang.IllegalArgumentException
Create a MolConverter object.

Parameters:
inFiles - input file list
out - output stream
fmtopts - output file format with or without options
useSysEOL - write OS dependent line.separators instead of '\n'
Throws:
MolFormatException - If the molecule file is in a format that cannot be read
MolExportException - If the molecule cannot be exported in the specified format
java.io.IOException - If I/O error occured when determining the file format.
java.lang.IllegalArgumentException - Invalid format string (fmt).

MolConverter

public MolConverter(java.io.InputStream in,
                    java.lang.String ofname,
                    java.lang.String fmtopts,
                    boolean useSysEOL)
             throws MolFormatException,
                    MolExportException,
                    java.io.IOException,
                    java.lang.IllegalArgumentException
Use this constructor if you do not need output buffering but want to determine output file positions.

Parameters:
in - the input molecule stream to convert
ofname - the output file name
fmtopts - output file format with or without options
useSysEOL - write OS dependent line.separators instead of '\n'
Throws:
MolFormatException - If the molecule file is in a format that cannot be read
MolExportException - If the molecule cannot be exported in the specified format
java.io.IOException - If I/O error occured when determining the file format.
java.lang.IllegalArgumentException - Invalid format string (fmt).
See Also:
otell(), close()

MolConverter

public MolConverter(java.util.Vector inFiles,
                    java.lang.String ofname,
                    java.lang.String fmtopts,
                    boolean useSysEOL)
             throws MolFormatException,
                    MolExportException,
                    java.io.IOException,
                    java.lang.IllegalArgumentException
Use this constructor if you do not need output buffering but want to determine output file positions.

Parameters:
inFiles - input file list
ofname - output file name
fmtopts - output file format with or without options
useSysEOL - write OS dependent line.separators instead of '\n'
Throws:
MolFormatException - If the molecule file is in a format that cannot be read
MolExportException - If the molecule cannot be exported in the specified format
java.io.IOException - If I/O error occured when determining the file format.
java.lang.IllegalArgumentException - Invalid format string (fmt).
See Also:
otell(), close()

MolConverter

public MolConverter(java.util.Vector inFiles,
                    java.util.Vector inOptions,
                    java.lang.String ofname,
                    java.lang.String fmtopts,
                    boolean useSysEOL)
             throws MolFormatException,
                    MolExportException,
                    java.io.IOException,
                    java.lang.IllegalArgumentException
Use this constructor if you do not need output buffering but want to determine output file positions.

Parameters:
inFiles - input file list
inOptions - import options
ofname - output file name
fmtopts - output file format with or without options
useSysEOL - write OS dependent line.separators instead of '\n'
Throws:
MolFormatException - If the molecule file is in a format that cannot be read
MolExportException - If the molecule cannot be exported in the specified format
java.io.IOException - If I/O error occured when determining the file format.
java.lang.IllegalArgumentException - Invalid format string (fmt).
See Also:
otell(), close()
Method Detail

convert

public boolean convert()
                throws MolExportException,
                       java.io.IOException
Convert the next molecule.

Returns:
true if success, false if no more molecules can be read
Throws:
java.io.IOException - If an I/O error has occurred.
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported
MolExportException

otell

public long otell()
           throws java.io.IOException
Get the current file position.

Returns:
the position
Throws:
java.io.IOException - if the position cannot be determined

close

public void close()
           throws java.io.IOException
Close the underlying RandomAccessFile. Needed only if the output file name is set in the constructor.

Throws:
java.io.IOException - If an I/O error has occurred.

isSupportedEncoding

public static boolean isSupportedEncoding(java.lang.String enc)
Test, whether the given charset name is supported by this JVM

Parameters:
enc - the name of the charset
Returns:
true if the charset is supported by this JVM, false if not

createMolConverter

public static MolConverter createMolConverter(java.io.InputStream instream,
                                              java.io.OutputStream outstream,
                                              java.lang.String[] args,
                                              java.io.OutputStream[] theOut,
                                              int[] theVerbose)
                                       throws java.io.IOException
Creates a MolConverter instance with the attributes specified in the parameters. Basically allows two usage scenario:

Parameters:
instream - the input stream to take the molecule definition from. It must be null when called for command line usage.
outstream - the output stream to write the result onto. It must be null when called for command line usage.
args - space separated options of attributes/options for the desired MolConverter instance.
Throws:
java.nio.charset.IllegalCharsetNameException - if illegal input or output encoding name specified
java.nio.charset.UnsupportedCharsetException - if the specified input or output encoding is unsupported
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Main method.

Parameters:
args - command line arguments
Throws:
java.io.IOException

mainWithoutExit

public static void mainWithoutExit(java.lang.String[] args)
                            throws java.io.IOException
Same as main(), but never calls System.exit(). Useful to call from other java programs. Instead of exiting the JVM, a RuntimeException may be thrown with text "molconvert exit:<exit status>"

Parameters:
args - arguments passed to main().
Throws:
java.io.IOException