Package org.openscience.cdk.io
Interface IChemObjectIO
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Subinterfaces:
IChemObjectReader,IChemObjectWriter,IEventChemObjectReader,IIteratingChemObjectReader<T>,ISimpleChemObjectReader
- All Known Implementing Classes:
CDKOWLReader,CDKOWLWriter,CDKSourceCodeWriter,ChemObjectIO,CIFReader,CMLReader,CMLWriter,CrystClustReader,CrystClustWriter,CTXReader,DefaultChemObjectReader,DefaultChemObjectWriter,DefaultEventChemObjectReader,DefaultIteratingChemObjectReader,EventCMLReader,GamessReader,Gaussian03Reader,Gaussian98Reader,GaussianInputWriter,GhemicalMMReader,HINReader,HINWriter,INChIPlainTextReader,INChIReader,IteratingPCCompoundASNReader,IteratingPCCompoundXMLReader,IteratingPCSubstancesXMLReader,IteratingSDFReader,IteratingSMILESReader,MDLReader,MDLRXNReader,MDLRXNV2000Reader,MDLRXNV3000Reader,MDLRXNWriter,MDLV2000Reader,MDLV2000Writer,MDLV3000Reader,MDLV3000Writer,Mol2Reader,Mol2Writer,Mopac7Reader,Mopac7Writer,MoSSOutputReader,PCCompoundASNReader,PCCompoundXMLReader,PCSubstanceXMLReader,PDBReader,PDBWriter,PMPReader,RGroupQueryReader,RGroupQueryWriter,RssWriter,SDFWriter,ShelXReader,ShelXWriter,SMILESReader,SMILESWriter,VASPReader,XYZReader,XYZWriter,ZMatrixReader
This class is the interface that all IO readers should implement.
Programs need only care about this interface for any kind of IO.
Currently, database IO and file IO is supported.
The easiest way to implement a new IChemObjectReader is to
subclass the DefaultChemObjectReader.
- Author:
- Egon Willighagen <egonw@sci.kun.nl>
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaccepts(Class<? extends IChemObject> classObject) Returns whether the givenIChemObjectcan be read or written.voidaddChemObjectIOListener(IChemObjectIOListener listener) Adds aIChemObjectIOListenerto this IChemObjectIO.<S extends IOSetting>
SaddSetting(IOSetting setting) Add an IOSetting to the reader/writer.voidaddSettings(Collection<IOSetting> settings) Adds a collection ofIOSettings to the reader/writer.voidclose()Closes this IChemObjectIO's resources.Returns theIResourceFormatclass for this IO class.Returns an array ofIOSettings defined by this IChemObjectIO class.Access all the listeners for this ChemObject Reader or Writer.<S extends IOSetting>
SgetSetting(String name) Access a named setting managed by this reader/writer.<S extends IOSetting>
SgetSetting(String name, Class<S> c) Access a named setting managed by this reader/writer.Access a collection ofIOSettings for this reader/writer.booleanhasSetting(String name) Determine whether this reader/writer has a setting of the provided name.voidRemoves aIChemObjectIOListenerfrom this IChemObjectIO.
-
Method Details
-
getFormat
IResourceFormat getFormat()Returns theIResourceFormatclass for this IO class. -
accepts
Returns whether the givenIChemObjectcan be read or written.- Parameters:
classObject-IChemObjectof which is tested if it can be handled.- Returns:
- true, if the
IChemObjectcan be handled.
-
close
Closes this IChemObjectIO's resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- when the wrapper IO class cannot be closed.
-
getIOSettings
IOSetting[] getIOSettings()Returns an array ofIOSettings defined by this IChemObjectIO class.- Returns:
- the
IOSettings for this class.
-
addChemObjectIOListener
Adds aIChemObjectIOListenerto this IChemObjectIO.- Parameters:
listener- the reader listener to add.
-
removeChemObjectIOListener
Removes aIChemObjectIOListenerfrom this IChemObjectIO.- Parameters:
listener- the listener to be removed.
-
getListeners
Collection<IChemObjectIOListener> getListeners()Access all the listeners for this ChemObject Reader or Writer. This will returned an unmodifiable list of listeners. Listeners should be added to and removed from the reader/writer usingaddChemObjectIOListener(org.openscience.cdk.io.listener.IChemObjectIOListener)andremoveChemObjectIOListener(org.openscience.cdk.io.listener.IChemObjectIOListener)- Returns:
- all listeners managed by this IO object
-
addSetting
Add an IOSetting to the reader/writer. If the name clashes with another setting the original setting will be returned. This method should be called when assigning field settings:private BooleanIOSetting setting; // field ... setting = addSetting(new BooleanIOSetting("setting", ...)); // if setting was already added we are now using the correct instance- Parameters:
setting- setting to add- Returns:
- usable setting
- See Also:
-
addSettings
Adds a collection ofIOSettings to the reader/writer. This is useful for transferring/propagating settings between different reader/writer. When the new settings are added if there is a setting with the same name already stored the value for the new setting is set on the managed setting (See. IteratingSDFReader/SDFWriter for propagation examples). Note that if the setting is invalid (a CDKException thrown) then the setting will not be set.// two different readers (of same or different type) IChemObjectReader reader1 = ...; IChemObjectReader reader2 = ...; // settings transferred from reader2 to reader1 reader1.addSettings(reader2.getSettings());- Parameters:
settings- collection of settings to add- See Also:
-
hasSetting
Determine whether this reader/writer has a setting of the provided name.- Parameters:
name- name of a setting- Returns:
- whether the setting is available
- See Also:
-
getSetting
Access a named setting managed by this reader/writer.- Type Parameters:
S- type to cast to- Parameters:
name- name of the setting- Returns:
- instance of the setting for the name (InvalidParameterException is thrown if no setting for the provided name is found)
- See Also:
-
getSetting
Access a named setting managed by this reader/writer.- Type Parameters:
S- type to cast to- Parameters:
name- name of the settingc- the class of the setting (matching generic return type). This is need as due to type erasure we don't know the class of 'S' at runtime.- Returns:
- instance of the setting for the name (InvalidParameterException is thrown if no setting for the provided name is found)
- See Also:
-
getSettings
Collection<IOSetting> getSettings()Access a collection ofIOSettings for this reader/writer.- Returns:
- collection of IOSetting's
- See Also:
-