Package org.openscience.cdk.io
Class CDKSourceCodeWriter
- java.lang.Object
-
- org.openscience.cdk.io.ChemObjectIO
-
- org.openscience.cdk.io.DefaultChemObjectWriter
-
- org.openscience.cdk.io.CDKSourceCodeWriter
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,IChemObjectIO
,IChemObjectWriter
public class CDKSourceCodeWriter extends DefaultChemObjectWriter
Converts a Molecule into CDK source code that would build the same molecule. It's typical use is:StringWriter stringWriter = new StringWriter(); ChemObjectWriter writer = new CDKSourceCodeWriter(stringWriter); writer.write((Molecule)molecule); writer.close(); System.out.print(stringWriter.toString());
- Author:
- Egon Willighagen <egonw@sci.kun.nl>
- Source code:
- main
- IO options:
Name Question Default write3DCoordinates Should 3D coordinates be added? true builder Which IChemObjectBuilder should be used? DefaultChemObjectBuilder write2DCoordinates Should 2D coordinates be added? true - Belongs to CDK module:
- io
- Keywords:
- file format, CDK source code
- Created on:
- 2003-10-01
-
-
Constructor Summary
Constructors Constructor Description CDKSourceCodeWriter()
CDKSourceCodeWriter(OutputStream out)
CDKSourceCodeWriter(Writer out)
Constructs a new CDKSourceCodeWriter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accepts(Class<? extends IChemObject> classObject)
Returns whether the givenIChemObject
can be read or written.void
close()
Flushes the output and closes this object.IResourceFormat
getFormat()
Returns theIResourceFormat
class for this IO class.int
getRequiredDataFeatures()
int
getSupportedDataFeatures()
void
setWriter(OutputStream output)
Sets the OutputStream from which this ChemObjectWriter should write the contents.void
setWriter(Writer out)
Sets the Writer from which this ChemObjectWriter should write the contents.void
write(IChemObject object)
Writes the content of "object" to output.-
Methods inherited from class org.openscience.cdk.io.ChemObjectIO
addChemObjectIOListener, addSetting, addSettings, fireIOSettingQuestion, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openscience.cdk.io.IChemObjectIO
addChemObjectIOListener, addSetting, addSettings, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListener
-
-
-
-
Constructor Detail
-
CDKSourceCodeWriter
public CDKSourceCodeWriter(Writer out)
Constructs a new CDKSourceCodeWriter.- Parameters:
out
- The Writer to write to
-
CDKSourceCodeWriter
public CDKSourceCodeWriter(OutputStream out)
-
CDKSourceCodeWriter
public CDKSourceCodeWriter()
-
-
Method Detail
-
getFormat
public IResourceFormat getFormat()
Description copied from interface:IChemObjectIO
Returns theIResourceFormat
class for this IO class.
-
setWriter
public void setWriter(Writer out) throws CDKException
Description copied from interface:IChemObjectWriter
Sets the Writer from which this ChemObjectWriter should write the contents.- Throws:
CDKException
-
setWriter
public void setWriter(OutputStream output) throws CDKException
Description copied from interface:IChemObjectWriter
Sets the OutputStream from which this ChemObjectWriter should write the contents.- Throws:
CDKException
-
close
public void close() throws IOException
Flushes the output and closes this object.- Throws:
IOException
- when the wrapper IO class cannot be closed.
-
accepts
public boolean accepts(Class<? extends IChemObject> classObject)
Description copied from interface:IChemObjectIO
Returns whether the givenIChemObject
can be read or written.- Parameters:
classObject
-IChemObject
of which is tested if it can be handled.- Returns:
- true, if the
IChemObject
can be handled.
-
write
public void write(IChemObject object) throws CDKException
Description copied from interface:IChemObjectWriter
Writes the content of "object" to output.- Parameters:
object
- the object of which the content is outputted- Throws:
CDKException
- is thrown if the output does not support the data in the object
-
getSupportedDataFeatures
public int getSupportedDataFeatures()
-
getRequiredDataFeatures
public int getRequiredDataFeatures()
-
-