org.openscience.cdk.io.iterator
Class DefaultIteratingChemObjectReader

java.lang.Object
  extended by org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader
All Implemented Interfaces:
Iterator, IChemObjectIO, IChemObjectReader, IIteratingChemObjectReader
Direct Known Subclasses:
IteratingMDLReader, IteratingPCCompoundASNReader, IteratingPCCompoundXMLReader, IteratingPCSubstancesXMLReader, IteratingSMILESReader

public abstract class DefaultIteratingChemObjectReader
extends Object
implements IIteratingChemObjectReader

Abstract class that IteratingChemObjectReader's can implement to have it take care of basic stuff, like managing the ReaderListeners.

Belongs to CDK module:
io
Source code:
HEAD

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openscience.cdk.io.IChemObjectReader
IChemObjectReader.Mode
 
Constructor Summary
DefaultIteratingChemObjectReader()
           
 
Method Summary
 boolean accepts(Class objectClass)
          Returns whether the given IChemObject can be read or written.
 void addChemObjectIOListener(IChemObjectIOListener listener)
          Adds a IChemObjectIOListener to this IChemObjectIO.
 IOSetting[] getIOSettings()
          Returns an array of IOSettings defined by this IChemObjectIO class.
 void handleError(String message)
          Redirects an error message to the IChemObjectReaderErrorHandler.
 void handleError(String message, Exception exception)
          Redirects an error message to the IChemObjectReaderErrorHandler.
 void handleError(String message, int row, int colStart, int colEnd)
          Redirects an error message to the IChemObjectReaderErrorHandler.
 void handleError(String message, int row, int colStart, int colEnd, Exception exception)
          Redirects an error message to the IChemObjectReaderErrorHandler.
 void remove()
          File IO generally does not support removing of entries.
 void removeChemObjectIOListener(IChemObjectIOListener listener)
          Removes a IChemObjectIOListener from this IChemObjectIO.
 void setErrorHandler(IChemObjectReaderErrorHandler handler)
          Sets an error handler that is sent events when file format issues occur.
 void setReaderMode(IChemObjectReader.Mode mode)
          Sets the reader mode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openscience.cdk.io.IChemObjectReader
setReader, setReader
 
Methods inherited from interface org.openscience.cdk.io.IChemObjectIO
close, getFormat
 
Methods inherited from interface java.util.Iterator
hasNext, next
 

Constructor Detail

DefaultIteratingChemObjectReader

public DefaultIteratingChemObjectReader()
Method Detail

addChemObjectIOListener

public void addChemObjectIOListener(IChemObjectIOListener listener)
Description copied from interface: IChemObjectIO
Adds a IChemObjectIOListener to this IChemObjectIO.

Specified by:
addChemObjectIOListener in interface IChemObjectIO
Parameters:
listener - the reader listener to add.

removeChemObjectIOListener

public void removeChemObjectIOListener(IChemObjectIOListener listener)
Description copied from interface: IChemObjectIO
Removes a IChemObjectIOListener from this IChemObjectIO.

Specified by:
removeChemObjectIOListener in interface IChemObjectIO
Parameters:
listener - the listener to be removed.

accepts

public boolean accepts(Class objectClass)
Description copied from interface: IChemObjectIO
Returns whether the given IChemObject can be read or written.

Specified by:
accepts in interface IChemObjectIO
Parameters:
objectClass - IChemObject of which is tested if it can be handled.
Returns:
true, if the IChemObject can be handled.

remove

public void remove()
File IO generally does not support removing of entries.

Specified by:
remove in interface Iterator

getIOSettings

public IOSetting[] getIOSettings()
Description copied from interface: IChemObjectIO
Returns an array of IOSettings defined by this IChemObjectIO class.

Specified by:
getIOSettings in interface IChemObjectIO
Returns:
the IOSettings for this class.

setReaderMode

public void setReaderMode(IChemObjectReader.Mode mode)
Description copied from interface: IChemObjectReader
Sets the reader mode. If Mode.STRICT, then the reader will fail on any problem in the format of the read file, instead of trying to recover from that.

Specified by:
setReaderMode in interface IChemObjectReader

setErrorHandler

public void setErrorHandler(IChemObjectReaderErrorHandler handler)
Sets an error handler that is sent events when file format issues occur.

Specified by:
setErrorHandler in interface IChemObjectReader
Parameters:
handler - IChemObjectReaderErrorHandler to send error messages to.

handleError

public void handleError(String message)
                 throws CDKException
Redirects an error message to the IChemObjectReaderErrorHandler. Throws an CDKException when in STRICT IChemObjectReader.Mode.

Specified by:
handleError in interface IChemObjectReader
Parameters:
message - the error message.
Throws:
CDKException

handleError

public void handleError(String message,
                        Exception exception)
                 throws CDKException
Redirects an error message to the IChemObjectReaderErrorHandler. Throws an CDKException when in STRICT IChemObjectReader.Mode.

Specified by:
handleError in interface IChemObjectReader
Parameters:
message - the error message.
exception - the corresponding Exception.
Throws:
CDKException

handleError

public void handleError(String message,
                        int row,
                        int colStart,
                        int colEnd)
                 throws CDKException
Redirects an error message to the IChemObjectReaderErrorHandler. Throws an CDKException when in STRICT IChemObjectReader.Mode.

Specified by:
handleError in interface IChemObjectReader
Parameters:
message - the error message.
row - Row in the file where the error is found.
colStart - Start column in the file where the error is found.
colEnd - End column in the file where the error is found.
Throws:
CDKException

handleError

public void handleError(String message,
                        int row,
                        int colStart,
                        int colEnd,
                        Exception exception)
                 throws CDKException
Redirects an error message to the IChemObjectReaderErrorHandler. Throws an CDKException when in STRICT IChemObjectReader.Mode.

Specified by:
handleError in interface IChemObjectReader
Parameters:
message - the error message.
row - Row in the file where the error is found.
colStart - Start column in the file where the error is found.
colEnd - End column in the file where the error is found.
exception - the corresponding Exception.
Throws:
CDKException