public abstract class RandomAccessReader extends DefaultRandomAccessChemObjectReader implements IRandomAccessChemObjectReader<IChemObject>
Modifier and Type | Field and Description |
---|---|
protected byte[] |
b |
protected IChemObjectBuilder |
builder |
protected ISimpleChemObjectReader |
chemObjectReader |
protected int |
currentRecord |
protected IOSetting[] |
headerOptions |
protected long[][] |
index |
protected boolean |
indexCreated |
protected int |
indexVersion |
protected static ILoggingTool |
logger |
protected RandomAccessFile |
raFile |
protected int |
records |
mode
Constructor and Description |
---|
RandomAccessReader(File file,
IChemObjectBuilder builder)
Reads the file and builds an index file, if the index file doesn't already exist.
|
RandomAccessReader(File file,
IChemObjectBuilder builder,
IReaderListener listener)
Reads the file and builds an index file, if the index file doesn't already exist.
|
Modifier and Type | Method and Description |
---|---|
void |
add(IChemObject arg0) |
void |
addChemObjectIOListener(IChemObjectIOListener listener) |
void |
close() |
abstract ISimpleChemObjectReader |
createChemObjectReader() |
protected void |
finalize() |
IChemObject |
first() |
IChemObjectReader |
getChemObjectReader() |
int |
getCurrentRecord() |
static File |
getIndexFile(String filename)
Opens the file index file
_cdk.index in a temporary folder, as specified by "java.io.tmpdir" property. |
boolean |
hasNext() |
boolean |
hasPrevious() |
boolean |
isIndexCreated() |
protected abstract boolean |
isRecordEnd(String line) |
IChemObject |
last() |
protected void |
loadIndex(File file) |
protected void |
makeIndex()
The index file
getIndexFile(String) is loaded, if already exists, or created a new. |
IChemObject |
next() |
int |
nextIndex() |
IChemObject |
previous() |
int |
previousIndex() |
protected IChemObject |
processContent()
The reader is already set to read the record buffer.
|
protected String |
readContent(int record)
Reads the record text content into a String.
|
IChemObject |
readRecord(int record)
Returns the object at given record No.
|
void |
removeChemObjectIOListener(IChemObjectIOListener listener) |
protected long[][] |
resize(long[][] index,
int newLength) |
protected void |
saveIndex(File file) |
void |
set(IChemObject arg0) |
void |
setChemObjectReader(ISimpleChemObjectReader chemObjectReader) |
void |
setIndexCreated(boolean indexCreated) |
int |
size() |
String |
toString() |
fireIOSettingQuestion, getIOSettings, setReaderMode
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
remove
forEachRemaining
protected static ILoggingTool logger
protected RandomAccessFile raFile
protected IOSetting[] headerOptions
protected ISimpleChemObjectReader chemObjectReader
protected int indexVersion
protected long[][] index
protected int records
protected int currentRecord
protected byte[] b
protected IChemObjectBuilder builder
protected boolean indexCreated
public RandomAccessReader(File file, IChemObjectBuilder builder) throws IOException
file
- the file object containing the molecules to be indexedbuilder
- a chem object builderIOException
- if there is an error during readingpublic RandomAccessReader(File file, IChemObjectBuilder builder, IReaderListener listener) throws IOException
file
- file the file object containg the molecules to be indexedbuilder
- builder a chem object builderlistener
- listen for read eventIOException
- if there is an error during readingprotected void finalize() throws Throwable
public IChemObject readRecord(int record) throws Exception
readRecord
in interface IRandomAccessChemObjectReader<IChemObject>
Exception
protected String readContent(int record) throws IOException, CDKException
record
- The record numberIOException
- if error occurs during readingCDKException
- if the record number is invalidprotected IChemObject processContent() throws CDKException
CDKException
- an error occurred whilst reading the fileprotected long[][] resize(long[][] index, int newLength)
protected abstract boolean isRecordEnd(String line)
protected void makeIndex() throws Exception
getIndexFile(String)
is loaded, if already exists, or created a new.Exception
public static File getIndexFile(String filename)
_cdk.index
in a temporary folder, as specified by "java.io.tmpdir" property.filename
- the name of the file for which the index was generatedpublic void close() throws IOException
IOException
public IChemObjectReader getChemObjectReader()
public abstract ISimpleChemObjectReader createChemObjectReader()
public void setChemObjectReader(ISimpleChemObjectReader chemObjectReader)
public boolean hasNext()
hasNext
in interface Iterator<IChemObject>
hasNext
in interface ListIterator<IChemObject>
public boolean hasPrevious()
hasPrevious
in interface ListIterator<IChemObject>
public IChemObject first()
first
in interface IRandomAccessChemObjectReader<IChemObject>
public IChemObject last()
last
in interface IRandomAccessChemObjectReader<IChemObject>
public IChemObject next()
next
in interface Iterator<IChemObject>
next
in interface ListIterator<IChemObject>
public IChemObject previous()
previous
in interface ListIterator<IChemObject>
public void set(IChemObject arg0)
set
in interface ListIterator<IChemObject>
public void add(IChemObject arg0)
add
in interface ListIterator<IChemObject>
public int previousIndex()
previousIndex
in interface ListIterator<IChemObject>
public int nextIndex()
nextIndex
in interface ListIterator<IChemObject>
public int size()
size
in interface IRandomAccessChemObjectReader<IChemObject>
public void addChemObjectIOListener(IChemObjectIOListener listener)
addChemObjectIOListener
in class DefaultRandomAccessChemObjectReader
public void removeChemObjectIOListener(IChemObjectIOListener listener)
removeChemObjectIOListener
in class DefaultRandomAccessChemObjectReader
public int getCurrentRecord()
public boolean isIndexCreated()
public void setIndexCreated(boolean indexCreated)
Copyright © 2018. All Rights Reserved.