Package org.openscience.cdk.io
Class ChemObjectIO
java.lang.Object
org.openscience.cdk.io.ChemObjectIO
- All Implemented Interfaces:
Closeable
,AutoCloseable
,IChemObjectIO
- Direct Known Subclasses:
DefaultChemObjectReader
,DefaultChemObjectWriter
,DefaultEventChemObjectReader
,DefaultIteratingChemObjectReader
Provides some basic functionality for readers and writers. This includes
managing the
IChemObjectIOListener
's and managing of IOSetting
's.
The IOSettings are managed via the SettingManager
class with most
method's wrapped to more descriptive method names (e.g.
SettingManager.get(String)
is invoked by getSetting(String)
).- Author:
- johnmay
- Source code:
- main
- Belongs to CDK module:
- io
- Created on:
- 20.03.2012
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.protected void
fireIOSettingQuestion
(IOSetting setting) FiresIChemObjectIOListener.processIOSettingQuestion(org.openscience.cdk.io.setting.IOSetting)
for all managed listeners.Returns an array ofIOSetting
s 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 ofIOSetting
s for this reader/writer.boolean
hasSetting
(String name) Determine whether this reader/writer has a setting of the provided name.void
Removes aIChemObjectIOListener
from this IChemObjectIO.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.openscience.cdk.io.IChemObjectIO
accepts, close, getFormat
-
Constructor Details
-
ChemObjectIO
public ChemObjectIO()
-
-
Method Details
-
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 usingIChemObjectIO.addChemObjectIOListener(org.openscience.cdk.io.listener.IChemObjectIOListener)
andIChemObjectIO.removeChemObjectIOListener(org.openscience.cdk.io.listener.IChemObjectIOListener)
- Specified by:
getListeners
in interfaceIChemObjectIO
- Returns:
- all listeners managed by this IO object
-
addChemObjectIOListener
Adds aIChemObjectIOListener
to this IChemObjectIO.- Specified by:
addChemObjectIOListener
in interfaceIChemObjectIO
- Parameters:
listener
- the reader listener to add.
-
removeChemObjectIOListener
Removes aIChemObjectIOListener
from this IChemObjectIO.- Specified by:
removeChemObjectIOListener
in interfaceIChemObjectIO
- Parameters:
listener
- the listener to be removed.
-
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
- Specified by:
addSetting
in interfaceIChemObjectIO
- Parameters:
setting
- setting to add- Returns:
- usable setting
- See Also:
-
addSettings
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());
- Specified by:
addSettings
in interfaceIChemObjectIO
- Parameters:
settings
- collection of settings to add- See Also:
-
hasSetting
Determine whether this reader/writer has a setting of the provided name.- Specified by:
hasSetting
in interfaceIChemObjectIO
- Parameters:
name
- name of a setting- Returns:
- whether the setting is available
- See Also:
-
getSetting
Access a named setting managed by this reader/writer.- Specified by:
getSetting
in interfaceIChemObjectIO
- 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.- Specified by:
getSetting
in interfaceIChemObjectIO
- 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:
-
getIOSettings
Returns an array ofIOSetting
s defined by this IChemObjectIO class.- Specified by:
getIOSettings
in interfaceIChemObjectIO
- Returns:
- the
IOSetting
s for this class.
-
getSettings
Access a collection ofIOSetting
s for this reader/writer.- Specified by:
getSettings
in interfaceIChemObjectIO
- Returns:
- collection of IOSetting's
- See Also:
-
fireIOSettingQuestion
FiresIChemObjectIOListener.processIOSettingQuestion(org.openscience.cdk.io.setting.IOSetting)
for all managed listeners.- Parameters:
setting
- the setting to process
-