public abstract class MDocSource extends Object implements Iterable<Molecule>, Closeable
Constructor and Description |
---|
MDocSource() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying input stream(s).
|
abstract int |
estimateNumRecords()
Estimates the total number of records.
|
String |
getDocLabel(int k,
MDocument doc)
Returns the display label for the given document and document index.
|
MoleculeIterator |
getMoleculeIterator()
Gets a molecule iterator for this document source.
|
abstract int |
getRecordCount()
Gets the current record number.
|
abstract int |
getRecordCountMax()
Gets the total number of records.
|
abstract boolean |
isEndReached()
Tests whether the end of input is already reached.
|
abstract boolean |
isRewindable()
Tests whether rewinding (seeking backwards) is possible.
|
Iterator<Molecule> |
iterator()
Gets a molecule iterator for this document source.
|
abstract MDocument |
nextDoc()
Produces the next document.
|
int |
seekForward(int k,
MProgressMonitor pmon,
int dt,
Runnable sizeupdater)
Seeks in forward direction.
|
abstract void |
seekRecord(int k,
MProgressMonitor pmon)
Seeks the specified record.
|
void |
seekRecordAtFraction(double q,
int start,
int n,
int ncols,
MProgressMonitor pmon)
Seeks an approximate file position.
|
protected abstract void |
seekVisitedRecord(int k)
Seeks an already visited position in case of rewindable input.
|
abstract boolean |
skipRecord()
Skips the next document.
|
protected int |
skipRecords(int start,
int end,
MProgressMonitor pmon,
int dt,
Runnable sizeupdater) |
public abstract MDocument nextDoc() throws IOException
IOException
- If I/O error occurredpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- If an I/O error has occurred.public String getDocLabel(int k, MDocument doc)
k+1
as String,
where k
is the document index.k
- the document indexdoc
- the documentpublic abstract boolean skipRecord() throws IOException
true
if the end of the next document is found,
false
if there is no chance to continueIOException
- If I/O error occurredpublic abstract boolean isRewindable()
true
if rewinding is possible,
false
otherwiseseekRecord(int, MProgressMonitor)
,
seekRecordAtFraction(double, int, int, int, MProgressMonitor)
public abstract void seekRecord(int k, MProgressMonitor pmon) throws EOFException, IOException
cancels
the progress dialog.k
- positionpmon
- progress monitor or null
EOFException
- if end of file reached while trying to seekIOException
- if read error occurredisRewindable()
,
seekRecordAtFraction(double, int, int, int, MProgressMonitor)
public final void seekRecordAtFraction(double q, int start, int n, int ncols, MProgressMonitor pmon) throws IOException
x
= 0 or 1, respectively.
If records correspond to rows and columns of a table and the
ncols
argument differs from 1, then seeking is
restricted to the first column.
Backward seeking (rewinding) in the stream is only possible if the
underlying input stream is seekable. Forward seeking is always
possible.
Seeking terminates before reaching the specified position if the
user cancels
the progress dialog.q
- the position divided by the file size,
0 is the start, 1 is the end of filestart
- the minimum record index (offset)n
- the total number of available records
or 0 if all records are availablencols
- the number of columns (1 if there are no more columns)pmon
- progress monitor or null
IOException
- if read error occurredisRewindable()
,
seekRecord(int, MProgressMonitor)
protected abstract void seekVisitedRecord(int k) throws IOException
k
- the record indexIOException
- if read error occurredpublic final int seekForward(int k, MProgressMonitor pmon, int dt, Runnable sizeupdater) throws IOException
k
- the record to seekpmon
- the progress monitordt
- time interval in milliseconds for calling size
updatesizeupdater
- optional runnable to be called if the total number
of records changed or null
IOException
- if read error occurredseekRecordAtFraction(double, int, int, int, MProgressMonitor)
,
seekVisitedRecord(int)
protected final int skipRecords(int start, int end, MProgressMonitor pmon, int dt, Runnable sizeupdater) throws IOException
IOException
public abstract boolean isEndReached()
true
if the end was reached,
false
otherwisepublic abstract int getRecordCount()
public abstract int getRecordCountMax()
public abstract int estimateNumRecords()
public Iterator<Molecule> iterator()
iterator
in interface Iterable<Molecule>
UnsupportedOperationException
- if an iterator was created beforepublic final MoleculeIterator getMoleculeIterator()
UnsupportedOperationException
- if an iterator was created before