public class CMLWriter extends DefaultChemObjectWriter
IAtomContainerSet or a IAtomContainer object to CML 2 code.
Chemical Markup Language is an XML-based file format (Murray-Rust, P. and Rzepa, H.S.. Journal of Chemical Information and Computer
Sciences. 1999. 39).
Output can be redirected to other Writer objects like StringWriter
and FileWriter. An example:
StringWriter output = new StringWriter(); boolean makeFragment = true; CMLWriter cmlwriter = new CMLWriter(output, makeFragment); cmlwriter.write(molecule); cmlwriter.close(); String cmlcode = output.toString();
Output to a file called "molecule.cml" can done with:
FileWriter output = new FileWriter("molecule.cml");
CMLWriter cmlwriter = new CMLWriter(output);
cmlwriter.write(molecule);
cmlwriter.close();
For atoms it outputs: coordinates, element type and formal charge. For bonds it outputs: order, atoms (2, or more) and wedges.
FileWriter,
StringWriter| Constructor and Description |
|---|
CMLWriter() |
CMLWriter(OutputStream output) |
CMLWriter(Writer writer)
Constructs a new CMLWriter class.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accepts(Class<? extends IChemObject> classObject)
Returns whether the given
IChemObject can be read or written. |
void |
close()
Flushes the output and closes this object.
|
IResourceFormat |
getFormat()
Returns the
IResourceFormat class for this IO class. |
void |
registerCustomizer(ICMLCustomizer customizer) |
void |
setWriter(OutputStream output)
Sets the OutputStream from which this ChemObjectWriter should write
the contents.
|
void |
setWriter(Writer writer)
Sets the Writer from which this ChemObjectWriter should write
the contents.
|
void |
write(IChemObject object)
Serializes the IChemObject to CML and redirects it to the output Writer.
|
addChemObjectIOListener, addSetting, addSettings, fireIOSettingQuestion, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddChemObjectIOListener, addSetting, addSettings, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListenerpublic CMLWriter(Writer writer)
writer - Writer to redirect the output to.public CMLWriter(OutputStream output)
public CMLWriter()
public void registerCustomizer(ICMLCustomizer customizer)
public IResourceFormat getFormat()
IChemObjectIOIResourceFormat class for this IO class.public void setWriter(Writer writer) throws CDKException
IChemObjectWriterCDKExceptionpublic void setWriter(OutputStream output) throws CDKException
IChemObjectWriterCDKExceptionpublic void close()
throws IOException
IOException - when the wrapper IO class cannot be closed.public boolean accepts(Class<? extends IChemObject> classObject)
IChemObjectIOIChemObject can be read or written.classObject - IChemObject of which is tested if it can be handled.IChemObject can be handled.public void write(IChemObject object) throws CDKException
object - A Molecule of AtomContaineSet objectCDKException - is thrown if the output
does not support the data in the objectCopyright © 2018. All Rights Reserved.