chemaxon.marvin.io
Class ArrayMDocSource

java.lang.Object
  extended by chemaxon.marvin.io.MDocSource
      extended by chemaxon.marvin.io.ArrayMDocSource
All Implemented Interfaces:
java.lang.Iterable<Molecule>

public class ArrayMDocSource
extends MDocSource

MDocSource implementation for an array of documents or molecules.

Since:
Marvin 5.2, 02/27/2009
Version:
5.2, 02/27/2009
Author:
Nora Mate, Peter Csizmadia

Constructor Summary
ArrayMDocSource(java.util.List<?> list)
          Creates a document source for a list of documents or molecules.
ArrayMDocSource(MDocument[] docs)
          Creates a document source for an array of documents.
ArrayMDocSource(Molecule[] mols)
          Creates a document source for an array of molecules.
 
Method Summary
 int estimateNumRecords()
          Estimates the total number of records.
 int getRecordCount()
          Gets the current record number.
 int getRecordCountMax()
          Gets the total number of records.
 boolean isEndReached()
          Tests whether the end of input is already reached.
 boolean isRewindable()
          Tests whether rewinding (seeking backwards) is possible.
 MDocument nextDoc()
          Produces the next document.
 void seekRecord(int k, chemaxon.common.util.MProgressMonitor pmon)
          Seeks the specified record.
protected  void seekVisitedRecord(int k)
          Seeks an already visited position in case of rewindable input.
 boolean skipRecord()
          Skips the next document.
 
Methods inherited from class chemaxon.marvin.io.MDocSource
close, getDocLabel, getMoleculeIterator, iterator, seekForward, seekRecordAtFraction, skipRecords
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayMDocSource

public ArrayMDocSource(java.util.List<?> list)
Creates a document source for a list of documents or molecules.

Parameters:
list - the list of documents or molecules

ArrayMDocSource

public ArrayMDocSource(MDocument[] docs)
Creates a document source for an array of documents.

Parameters:
docs - the array of documents

ArrayMDocSource

public ArrayMDocSource(Molecule[] mols)
Creates a document source for an array of molecules.

Parameters:
mols - the array of molecules
Method Detail

nextDoc

public MDocument nextDoc()
Produces the next document.

Specified by:
nextDoc in class MDocSource
Returns:
the document or null at end of file

skipRecord

public boolean skipRecord()
Skips the next document.

Specified by:
skipRecord in class MDocSource
Returns:
true if the end of the next document is found, false if there is no chance to continue

isRewindable

public boolean isRewindable()
Tests whether rewinding (seeking backwards) is possible.

Specified by:
isRewindable in class MDocSource
Returns:
true if rewinding is possible, false otherwise
See Also:
seekRecord(int, MProgressMonitor), MDocSource.seekRecordAtFraction(double, int, int, int, MProgressMonitor)

seekRecord

public void seekRecord(int k,
                       chemaxon.common.util.MProgressMonitor pmon)
Seeks the specified record.

Specified by:
seekRecord in class MDocSource
Parameters:
k - position
pmon - progress monitor (unused in this implementation) or null
See Also:
isRewindable(), MDocSource.seekRecordAtFraction(double, int, int, int, MProgressMonitor)

seekVisitedRecord

protected void seekVisitedRecord(int k)
Seeks an already visited position in case of rewindable input.

Specified by:
seekVisitedRecord in class MDocSource
Parameters:
k - the record index

isEndReached

public boolean isEndReached()
Tests whether the end of input is already reached.

Specified by:
isEndReached in class MDocSource
Returns:
true if the end was reached, false otherwise

getRecordCount

public int getRecordCount()
Gets the current record number.

Specified by:
getRecordCount in class MDocSource
Returns:
the record number

getRecordCountMax

public int getRecordCountMax()
Gets the total number of records.

Specified by:
getRecordCountMax in class MDocSource
Returns:
the number of records

estimateNumRecords

public int estimateNumRecords()
Estimates the total number of records.

Specified by:
estimateNumRecords in class MDocSource
Returns:
estimated number of records or -1 (at the beginning)