chemaxon.marvin.io
Interface MRecordReader

All Known Implementing Classes:
AbstractMRecordReader

public interface MRecordReader

Marvin record reader.

Since:
Marvin 5.0, 04/06/2006
Version:
5.0.2, 03/13/2008
Author:
Peter Csizmadia

Nested Class Summary
static class MRecordReader.Position
          Position in the input file.
 
Method Summary
 void close()
          Closes the input stream.
 chemaxon.common.util.LongVector detectRecordPositions(chemaxon.common.util.IntVector linenums)
          Detects positions of records in the input stream.
 MRecordReader getEncapsulatedReader()
          Gets the encapsulated record reader if it exists.
 long getFilePointer()
          Gets the current position in the input file.
 java.lang.String getFooterAsString()
          Gets the footer of the file as a string.
 java.lang.String getHeaderAsString()
          Gets the header of the file as a string.
 int getLineCount()
          Get the current line number.
 MolInputStream getMolInputStream()
          Gets the molecule input stream.
 java.lang.String getOptions()
          Gets the import options.
 java.lang.String getRecognizedFormat()
          Gets the recognized file format.
 boolean isPropertyRecord()
           
 boolean isSeekable()
          Tests whether the record reader is seekable.
 MRecord nextRecord()
          Reads the next record.
 void seek(long p, int lcount, int k)
          Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
 void setProgressMonitor(chemaxon.common.util.MProgressMonitor pmon)
          Sets the progress monitor.
 MRecord skipRecord()
          Skips the next record.
 

Method Detail

setProgressMonitor

void setProgressMonitor(chemaxon.common.util.MProgressMonitor pmon)
Sets the progress monitor.

Parameters:
pmon - the progress monitor

nextRecord

MRecord nextRecord()
                   throws MRecordParseException,
                          java.io.IOException
Reads the next record.

Returns:
the record or null at end of file
Throws:
MRecordParseException - If the record could not be parsed
java.io.IOException - If I/O error occured

skipRecord

MRecord skipRecord()
                   throws MRecordParseException,
                          java.io.IOException
Skips the next record.

Returns:
incomplete record information, only the record start and end positions are guaranteed to be set
Throws:
MRecordParseException - If the record could not be parsed
java.io.IOException - If I/O error occured

getRecognizedFormat

java.lang.String getRecognizedFormat()
Gets the recognized file format.

Returns:
the input file format

getHeaderAsString

java.lang.String getHeaderAsString()
Gets the header of the file as a string.

Returns:
the header or empty string if there is no header
Since:
Marvin 5.0.2, 03/11/2008

getFooterAsString

java.lang.String getFooterAsString()
Gets the footer of the file as a string.

Returns:
the footer or empty string if there is no footer or not yet read
Since:
Marvin 5.0.2, 03/11/2008

getOptions

java.lang.String getOptions()
Gets the import options.

Returns:
the import options

close

void close()
           throws java.io.IOException
Closes the input stream.

Throws:
java.io.IOException - If I/O error occured

getEncapsulatedReader

MRecordReader getEncapsulatedReader()
Gets the encapsulated record reader if it exists. For example, in case of a GZIPped, BASE64 encoded molfile, the GzipRecordReader has an encapsulated Base64RecordReader instance.

Returns:
the encapsulated record reader or null

getMolInputStream

MolInputStream getMolInputStream()
Gets the molecule input stream.

Returns:
the molecule input stream

getFilePointer

long getFilePointer()
Gets the current position in the input file.

Returns:
the position

getLineCount

int getLineCount()
Get the current line number.

Returns:
the line number

isSeekable

boolean isSeekable()
Tests whether the record reader is seekable.

Returns:
true if it is seekable, false otherwise

seek

void seek(long p,
          int lcount,
          int k)
          throws java.io.IOException
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.

Parameters:
p - the file pointer
lcount - the line count at the specified position
k - the record count at the specified position
Throws:
java.io.IOException - if pos is less than 0 or if an I/O error occurs.

isPropertyRecord

boolean isPropertyRecord()

detectRecordPositions

chemaxon.common.util.LongVector detectRecordPositions(chemaxon.common.util.IntVector linenums)
                                                      throws MolFormatException
Detects positions of records in the input stream. Optionally returns also with the line number of records.

Parameters:
linenums - If not null, stores start line numbers of records in this container.
Returns:
container with start and end positions of records (inpair elements describe starting, pairs the ending positions).
Throws:
MolFormatException