I was using IOSetting's class for the recent patch to IteratingMDLReader when I spotted lots of redundant code in the base reader/writer classes. The settings implementation was also quite constrained requiring access to a fixed size array via 'getIOSettings()'. I thought it would be nice to try and simplify the API by removing redundant code (mainly listener handling) and also added some management of IOSettings. The main bonus is that you can now inherit settings and from super class readers/writer and also add/get specific settings easier (for example force read of 3D coordinates pops up more then once). The existing usage is still valid and so all test cases still pass. It turned out to be a little bit of a bigger patch then I would like and in fact there's a little bit more work to convert classes over but i'd thought I should post this first.
Summary of changes:
ISetting: interface for which IOSetting now implements (IOSetting is in package 'io' and we needed a way of using it in 'interfaces') SettingManager: simple wrapper around a map which handles adding/getting ISetting objects ChemObjectIO: abstract base class for all reader's and writers. Looking through the reader and writer code there was a lot of repeat code for adding and remove listeners. There was actually already a IChemObjectIO interface which provided the listener management but there was no implementation. Centralising the listener management to a single class means we only need to maintain it in one place, I also needed a place to add the setting manager to ChemObjectIO was created.
new test in IChemObjectTest for adding dynamic settings (check for non-null entries)
Removed listener management code from DefaultChemObjectReader, DefaultChemObjectWriter, IteratingChemObjectReader and DefaultEventChemObjectReader. These are all now sub-classes of the new abstract ChemObjectIO which is doing the listener and setting management. There were also some minor changes to the methods that access listeners due them now being encapsulated.
IChemObjectIO - Added methods for setting management and provided a 'getListeners()' method to allow subclasses to access the managed
listeners. In addition I deprecated addChemObjectIOListener(...)/removeChemObjectIOListener(...) and added addListener(...)/removeListener(...) which is far less verbose and
simplifies the API.
IteratingMDLReader - now uses the new setting management.
IOSetting - implements ISetting interface
CustomWriter - extends ChemObjectIO
Readers/writers that use IOSettings (Currently all working but I will convert these):