Package org.openscience.cdk.io.iterator
Class DefaultIteratingChemObjectReader<T extends IChemObject>
- java.lang.Object
-
- org.openscience.cdk.io.ChemObjectIO
-
- org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader<T>
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterator<T>
,IChemObjectIO
,IChemObjectReader
,IIteratingChemObjectReader<T>
- Direct Known Subclasses:
IteratingPCCompoundASNReader
,IteratingPCCompoundXMLReader
,IteratingPCSubstancesXMLReader
,IteratingSDFReader
,IteratingSMILESReader
public abstract class DefaultIteratingChemObjectReader<T extends IChemObject> extends ChemObjectIO implements IIteratingChemObjectReader<T>
Abstract class that IteratingChemObjectReader's can implement to have it take care of basic stuff, like managing the ReaderListeners.- Source code:
- main
- Belongs to CDK module:
- io
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openscience.cdk.io.IChemObjectReader
IChemObjectReader.Mode
-
-
Field Summary
Fields Modifier and Type Field Description protected IChemObjectReaderErrorHandler
errorHandler
protected IChemObjectReader.Mode
mode
-
Constructor Summary
Constructors Constructor Description DefaultIteratingChemObjectReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accepts(Class<? extends IChemObject> objectClass)
Returns whether the givenIChemObject
can be read or written.void
handleError(String message)
Redirects an error message to theIChemObjectReaderErrorHandler
.void
handleError(String message, int row, int colStart, int colEnd)
Redirects an error message to theIChemObjectReaderErrorHandler
.void
handleError(String message, int row, int colStart, int colEnd, Exception exception)
Redirects an error message to theIChemObjectReaderErrorHandler
.void
handleError(String message, Exception exception)
Redirects an error message to theIChemObjectReaderErrorHandler
.void
remove()
File IO generally does not support removing of entries.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 org.openscience.cdk.io.ChemObjectIO
addChemObjectIOListener, addSetting, addSettings, fireIOSettingQuestion, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListener
-
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
addChemObjectIOListener, addSetting, addSettings, close, getFormat, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListener
-
Methods inherited from interface org.openscience.cdk.io.IChemObjectReader
setReader, setReader
-
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next
-
-
-
-
Field Detail
-
mode
protected IChemObjectReader.Mode mode
-
errorHandler
protected IChemObjectReaderErrorHandler errorHandler
-
-
Method Detail
-
accepts
public boolean accepts(Class<? extends IChemObject> objectClass)
Description copied from interface:IChemObjectIO
Returns whether the givenIChemObject
can be read or written.- Specified by:
accepts
in interfaceIChemObjectIO
- 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 interfaceIterator<T extends IChemObject>
-
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 interfaceIChemObjectReader
-
setErrorHandler
public void setErrorHandler(IChemObjectReaderErrorHandler handler)
Sets an error handler that is sent events when file format issues occur.- Specified by:
setErrorHandler
in interfaceIChemObjectReader
- Parameters:
handler
-IChemObjectReaderErrorHandler
to send error messages to.
-
handleError
public void handleError(String message) throws CDKException
Redirects an error message to theIChemObjectReaderErrorHandler
. Throws anCDKException
when in STRICTIChemObjectReader.Mode
.- Specified by:
handleError
in interfaceIChemObjectReader
- Parameters:
message
- the error message.- Throws:
CDKException
-
handleError
public void handleError(String message, Exception exception) throws CDKException
Redirects an error message to theIChemObjectReaderErrorHandler
. Throws anCDKException
when in STRICTIChemObjectReader.Mode
.- Specified by:
handleError
in interfaceIChemObjectReader
- Parameters:
message
- the error message.exception
- the correspondingException
.- Throws:
CDKException
-
handleError
public void handleError(String message, int row, int colStart, int colEnd) throws CDKException
Redirects an error message to theIChemObjectReaderErrorHandler
. Throws anCDKException
when in STRICTIChemObjectReader.Mode
.- Specified by:
handleError
in interfaceIChemObjectReader
- 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 theIChemObjectReaderErrorHandler
. Throws anCDKException
when in STRICTIChemObjectReader.Mode
.- Specified by:
handleError
in interfaceIChemObjectReader
- 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 correspondingException
.- Throws:
CDKException
-
-