Class CMLReader

All Implemented Interfaces:
Closeable, AutoCloseable, IChemObjectIO, IChemObjectReader, ISimpleChemObjectReader

public class CMLReader extends DefaultChemObjectReader
Reads a molecule in CML 1.x and 2.0 format. CML is an XML based application [Murray-Rust, P. and Rzepa, H.S.. Journal of Chemical Information and Computer Sciences. 1999. 39], and this Reader applies the method described in [Willighagen, E.L.. Internet Journal of Chemistry. 2001. 4].
Author:
Egon L. Willighagen
This class is affected by these bug(s):
1544406
Source code:
main
Belongs to CDK module:
io
Keywords:
file format, CML
Created on:
2001-02-01
  • Constructor Details

    • CMLReader

      public CMLReader(InputStream input)
      Reads CML from an java.io.InputStream, for example the FileInputStream.
      Parameters:
      input - InputStream type input
    • CMLReader

      public CMLReader()
    • CMLReader

      public CMLReader(String url)
      Define this CMLReader to take the input from a java.io.Reader class. Possible readers are (among others) StringReader and FileReader.
      Parameters:
      url - String url which points to the file to be read
  • Method Details

    • registerConvention

      public void registerConvention(String convention, ICMLModule conv)
    • getFormat

      public IResourceFormat getFormat()
      Description copied from interface: IChemObjectIO
      Returns the IResourceFormat class for this IO class.
    • setReader

      public void setReader(Reader reader) throws CDKException
      This method must not be used; XML reading requires the use of an InputStream. Use setReader(InputStream) instead.
      Throws:
      CDKException
    • setReader

      public void setReader(InputStream input) throws CDKException
      Description copied from interface: IChemObjectReader
      Sets the InputStream from which this ChemObjectReader should read the contents.
      Throws:
      CDKException
    • accepts

      public boolean accepts(Class<? extends IChemObject> classObject)
      Description copied from interface: IChemObjectIO
      Returns whether the given IChemObject 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.
    • read

      public <T extends IChemObject> T read(T object) throws CDKException
      Read a IChemObject from input.
      Parameters:
      object - the type of object to return
      Returns:
      the content in a ChemFile object
      Throws:
      CDKException - it is thrown if the type of information is not available from the input
    • close

      public void close() throws IOException
      Description copied from interface: IChemObjectIO
      Closes this IChemObjectIO's resources.
      Throws:
      IOException - when the wrapper IO class cannot be closed.