Class ReaderFactory
java.lang.Object
org.openscience.cdk.io.ReaderFactory
A factory for creating ChemObjectReaders. The type of reader
created is determined from the content of the input. Formats
of GZiped files can be detected too.
A typical example is:
StringReader stringReader = "<molecule/>";
ISimpleChemObjectReader reader = new ReaderFactory().createReader(stringReader);
- Author:
- Egon Willighagen <egonw@sci.kun.nl>, Bradley A. Smith <bradley@baysmith.com>
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a ReaderFactory which tries to detect the format in the first 65536 chars.ReaderFactory(int headerLength) Constructs a ReaderFactory which tries to detect the format in the first given number of chars. -
Method Summary
Modifier and TypeMethodDescriptioncreateReader(InputStream input) Detects the format of the Reader input, and if known, it will return a CDK Reader to read the format, or null when the reader is not implemented.createReader(Reader input) Detects the format of the Reader input, and if known, it will return a CDK Reader to read the format.createReader(IChemFormat format) Creates a new IChemObjectReader based on the given IChemFormat.voidregisterFormat(IChemFormatMatcher format) Registers a format for detection.
-
Constructor Details
-
ReaderFactory
public ReaderFactory()Constructs a ReaderFactory which tries to detect the format in the first 65536 chars. -
ReaderFactory
public ReaderFactory(int headerLength) Constructs a ReaderFactory which tries to detect the format in the first given number of chars.- Parameters:
headerLength- length of the header in number of chars
-
-
Method Details
-
registerFormat
Registers a format for detection. -
getFormats
-
createReader
Detects the format of the Reader input, and if known, it will return a CDK Reader to read the format, or null when the reader is not implemented.- Returns:
- null if CDK does not contain a reader for the detected format.
- Throws:
IOException- See Also:
-
createReader
Creates a new IChemObjectReader based on the given IChemFormat.- See Also:
-
createReader
Detects the format of the Reader input, and if known, it will return a CDK Reader to read the format. This method is not able to detect the format of gziped files. Use createReader(InputStream) instead for such files.- Throws:
IOException- See Also:
-