Search in sources :

Example 1 with HINWriter

use of org.openscience.cdk.io.HINWriter in project ambit-mirror by ideaconsult.

the class FileOutputState method getWriter.

public static IChemObjectWriter getWriter(OutputStream stream, String ext) throws AmbitIOException {
    String fname = ext.toLowerCase();
    IChemObjectWriter writer = null;
    try {
        if (fname.endsWith(_FILE_TYPE.SDF_INDEX.getExtension())) {
            writer = new SDFWriter(stream);
        } else if (fname.endsWith(_FILE_TYPE.CSV_INDEX.getExtension()))
            writer = new DelimitedFileWriter(stream);
        else if ((fname.endsWith(_FILE_TYPE.TXT_INDEX.getExtension())))
            writer = new DelimitedFileWriter(stream, new DelimitedFileFormat("\t", '"'));
        else if ((fname.endsWith(_FILE_TYPE.SMI_INDEX.getExtension())))
            writer = new SMILESWriter(stream);
        else /*
			else if ((fname.endsWith(extensions[HTML_INDEX]))) 
				writer = new HTMLTableWriter(stream);
			else if ((fname.endsWith(extensions[JPG_INDEX]))) 			
				writer = new ImageWriter(stream);
			else if ((fname.endsWith(extensions[PNG_INDEX])))  
				writer = new ImageWriter(stream);
				*/
        if ((fname.endsWith(_FILE_TYPE.PDF_INDEX.getExtension()))) {
            try {
                writer = createWriterByReflection("ambit2.core.io.PDFWriter", stream);
            } catch (Exception x) {
                throw new AmbitIOException(x);
            }
        } else if ((fname.endsWith(_FILE_TYPE.XYZ_INDEX.getExtension())))
            writer = new XYZWriter(stream);
        else if ((fname.endsWith(_FILE_TYPE.HIN_INDEX.getExtension())))
            writer = new HINWriter(stream);
        else if ((fname.endsWith(_FILE_TYPE.MOL_INDEX.getExtension())))
            writer = new SDFWriter(stream);
        else if ((fname.endsWith(_FILE_TYPE.VW_INDEX.getExtension()))) {
            writer = new DelimitedFileWriter(stream, new DelimitedFileFormat("|", '"'));
            ((DelimitedFileWriter) writer).setAddSMILEScolumn(false);
        } else /*
			else if ((fname.endsWith(extensions[SVG_INDEX]))) 
				writer = new SVGWriter(stream);
				*/
        if ((fname.endsWith(_FILE_TYPE.XLS_INDEX.getExtension())))
            try {
                writer = createXLSXWriterByReflection("ambit2.core.io.XLSFileWriter", stream, true);
            } catch (Exception x) {
                throw new AmbitIOException(x);
            }
        else if ((fname.endsWith(_FILE_TYPE.XLSX_INDEX.getExtension())))
            try {
                writer = createXLSXWriterByReflection("ambit2.core.io.XLSFileWriter", stream, false);
            } catch (Exception x) {
                throw new AmbitIOException(x);
            }
        else
            throw new AmbitIOException(MSG_UNSUPPORTEDFORMAT + ext);
    } catch (Exception x) {
        // logger.error(MSG_ERRORSAVE,filename);
        throw new AmbitIOException(MSG_ERRORSAVE, x);
    }
    return writer;
}
Also used : XYZWriter(org.openscience.cdk.io.XYZWriter) AmbitIOException(ambit2.base.exceptions.AmbitIOException) SMILESWriter(org.openscience.cdk.io.SMILESWriter) HINWriter(org.openscience.cdk.io.HINWriter) SDFWriter(org.openscience.cdk.io.SDFWriter) IChemObjectWriter(org.openscience.cdk.io.IChemObjectWriter) AmbitIOException(ambit2.base.exceptions.AmbitIOException)

Aggregations

AmbitIOException (ambit2.base.exceptions.AmbitIOException)1 HINWriter (org.openscience.cdk.io.HINWriter)1 IChemObjectWriter (org.openscience.cdk.io.IChemObjectWriter)1 SDFWriter (org.openscience.cdk.io.SDFWriter)1 SMILESWriter (org.openscience.cdk.io.SMILESWriter)1 XYZWriter (org.openscience.cdk.io.XYZWriter)1