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
public interface IChemObjectIO extends Closeable
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 theDefaultChemObjectReader
.- Author:
- Egon Willighagen <egonw@sci.kun.nl>
- See Also:
DefaultChemObjectReader
- Source code:
- main
- Belongs to CDK module:
- io
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
accepts(Class<? extends IChemObject> classObject)
Returns whether the givenIChemObject
can be read or written.void
addChemObjectIOListener(IChemObjectIOListener listener)
Adds aIChemObjectIOListener
to this IChemObjectIO.<S extends IOSetting>
SaddSetting(IOSetting setting)
Add an IOSetting to the reader/writer.void
addSettings(Collection<IOSetting> settings)
Adds a collection ofIOSetting
s to the reader/writer.void
close()
Closes this IChemObjectIO's resources.IResourceFormat
getFormat()
Returns theIResourceFormat
class for this IO class.IOSetting[]
getIOSettings()
Returns an array ofIOSetting
s defined by this IChemObjectIO class.Collection<IChemObjectIOListener>
getListeners()
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.Collection<IOSetting>
getSettings()
Access a collection ofIOSetting
s for this reader/writer.boolean
hasSetting(String name)
Determine whether this reader/writer has a setting of the provided name.void
removeChemObjectIOListener(IChemObjectIOListener listener)
Removes aIChemObjectIOListener
from this IChemObjectIO.
-
-
-
Method Detail
-
getFormat
IResourceFormat getFormat()
Returns theIResourceFormat
class for this IO class.
-
accepts
boolean accepts(Class<? extends IChemObject> classObject)
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.
-
close
void close() throws IOException
Closes this IChemObjectIO's resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- when the wrapper IO class cannot be closed.
-
getIOSettings
IOSetting[] getIOSettings()
Returns an array ofIOSetting
s defined by this IChemObjectIO class.- Returns:
- the
IOSetting
s for this class.
-
addChemObjectIOListener
void addChemObjectIOListener(IChemObjectIOListener listener)
Adds aIChemObjectIOListener
to this IChemObjectIO.- Parameters:
listener
- the reader listener to add.
-
removeChemObjectIOListener
void removeChemObjectIOListener(IChemObjectIOListener listener)
Removes aIChemObjectIOListener
from 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
<S extends IOSetting> S addSetting(IOSetting setting)
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:
SettingManager.add(org.openscience.cdk.interfaces.ISetting)
-
addSettings
void addSettings(Collection<IOSetting> settings)
Adds a collection ofIOSetting
s 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:
getSettings()
-
hasSetting
boolean hasSetting(String name)
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:
SettingManager.has(String)
-
getSetting
<S extends IOSetting> S getSetting(String name)
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(String, Class)
,SettingManager.get(String)
-
getSetting
<S extends IOSetting> S getSetting(String name, Class<S> c)
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:
getSetting(String)
,SettingManager.get(String, Class)
-
getSettings
Collection<IOSetting> getSettings()
Access a collection ofIOSetting
s for this reader/writer.- Returns:
- collection of IOSetting's
- See Also:
addSettings(java.util.Collection)
-
-