Package chemaxon.marvin.io
Class ArrayMDocSource
- java.lang.Object
-
- chemaxon.marvin.io.MDocSource
-
- chemaxon.marvin.io.ArrayMDocSource
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<Molecule>
@PublicAPI public class ArrayMDocSource extends MDocSource
MDocSource
implementation for an array of documents or molecules.- Since:
- Marvin 5.2, 02/27/2009
-
-
Constructor Summary
Constructors Constructor Description ArrayMDocSource(MDocument[] docs)
Creates a document source for an array of documents.ArrayMDocSource(Molecule[] mols)
Creates a document source for an array of molecules.ArrayMDocSource(List<?> list)
Creates a document source for a list of documents or molecules.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, 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, getMDocumentStream, getMoleculeIterator, getMolStream, iterator, seekForward, seekRecordAtFraction, skipRecords
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ArrayMDocSource
public ArrayMDocSource(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 classMDocSource
- Returns:
- the document or null at end of file
-
skipRecord
public boolean skipRecord()
Skips the next document.- Specified by:
skipRecord
in classMDocSource
- 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 classMDocSource
- 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, MProgressMonitor pmon)
Seeks the specified record.- Specified by:
seekRecord
in classMDocSource
- Parameters:
k
- positionpmon
- progress monitor (unused in this implementation) ornull
- 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 classMDocSource
- Parameters:
k
- the record index
-
isEndReached
public boolean isEndReached()
Tests whether the end of input is already reached.- Specified by:
isEndReached
in classMDocSource
- Returns:
true
if the end was reached,false
otherwise
-
getRecordCount
public int getRecordCount()
Gets the current record number.- Specified by:
getRecordCount
in classMDocSource
- Returns:
- the record number
-
getRecordCountMax
public int getRecordCountMax()
Gets the total number of records.- Specified by:
getRecordCountMax
in classMDocSource
- Returns:
- the number of records
-
estimateNumRecords
public int estimateNumRecords()
Estimates the total number of records.- Specified by:
estimateNumRecords
in classMDocSource
- Returns:
- estimated number of records or -1 (at the beginning)
-
-