Package chemaxon.marvin.io.formats
Class AbstractMRecordReader
java.lang.Object
chemaxon.marvin.io.formats.AbstractMRecordReader
- All Implemented Interfaces:
MRecordReader
Abstract record reader class.
It is able to read lines and to create line number mappings
for the records.
- Since:
- Marvin 5.0, 04/26/2007
-
Nested Class Summary
Nested classes/interfaces inherited from interface chemaxon.marvin.io.MRecordReader
MRecordReader.Position
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractMRecordReader
(InputStream istr, String opts) Constructs an abstract record reader.protected
AbstractMRecordReader
(InputStream istr, String opts, String path) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
appendLine
(StringBuffer sb, String line) Appends line to string buffer with closing '\n' character.protected void
appendLines
(StringBuffer sb, String l) Appends lines to string buffer with closing '\n' character if it is not yet present.void
close()
Interrupts parsing.chemaxon.common.util.LongVector
detectRecordPositions
(chemaxon.common.util.IntVector linenums) Deprecated.protected int[]
endRecord
(boolean skip) It must be called at the end of record.Gets the encapsulated record reader if it exists.long
Get the file pointer.Gets the footer of the file as a string.Gets the header of the file as a string.int
Get the current line number.Gets the molecule input stream.Gets the import options.protected MRecordReader.Position
Gets the current position.Gets the recognized file format.boolean
boolean
Tests whether the record reader is seekable.protected void
Puts back the previous line to the input stream.protected String
readLine()
Reads the next line.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
Sets the progress monitor.protected boolean
skipLine()
Skips the next line.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface chemaxon.marvin.io.MRecordReader
nextRecord, skipRecord
-
Constructor Details
-
AbstractMRecordReader
Constructs an abstract record reader.- Parameters:
istr
- the input streamopts
- format and options- Throws:
IOException
-
AbstractMRecordReader
- Throws:
IOException
-
-
Method Details
-
setProgressMonitor
Sets the progress monitor. The default implementation does nothing.- Specified by:
setProgressMonitor
in interfaceMRecordReader
- Parameters:
pmon
- the progress monitor
-
getRecognizedFormat
Gets the recognized file format.- Specified by:
getRecognizedFormat
in interfaceMRecordReader
- Returns:
- the input file format
-
getHeaderAsString
Gets the header of the file as a string.- Specified by:
getHeaderAsString
in interfaceMRecordReader
- Returns:
- empty string in the default implementation
- Since:
- Marvin 5.0.2, 03/11/2008
-
getOptions
Gets the import options.- Specified by:
getOptions
in interfaceMRecordReader
- Returns:
- the import options
-
readLine
Reads the next line.- Returns:
- the next line
- Throws:
IOException
-
skipLine
Skips the next line. The skipped line is not stored and cannot put be back into the stream.- Returns:
true
if a line was skipped successfully,false
at end of file- Throws:
IOException
- If an I/O error has occurred.- Since:
- Marvin 5.1.3, 10/18/2008
-
putBackLine
Puts back the previous line to the input stream.- Throws:
IOException
-
endRecord
protected int[] endRecord(boolean skip) It must be called at the end of record.- Parameters:
skip
- whether to skip the record- Returns:
- the line number mapping
-
close
public void close()Interrupts parsing.- Specified by:
close
in interfaceMRecordReader
-
getEncapsulatedReader
Gets the encapsulated record reader if it exists.- Specified by:
getEncapsulatedReader
in interfaceMRecordReader
- Returns:
- the encapsulated record reader or
null
-
getMolInputStream
Gets the molecule input stream.- Specified by:
getMolInputStream
in interfaceMRecordReader
- Returns:
- the molecule input stream
-
getFilePointer
public long getFilePointer()Get the file pointer.- Specified by:
getFilePointer
in interfaceMRecordReader
- Returns:
- the file pointer
-
getLineCount
public int getLineCount()Get the current line number.- Specified by:
getLineCount
in interfaceMRecordReader
- Returns:
- the line number
-
isSeekable
public boolean isSeekable()Tests whether the record reader is seekable.- Specified by:
isSeekable
in interfaceMRecordReader
- Returns:
true
if it is seekable,false
otherwise
-
seek
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.- Specified by:
seek
in interfaceMRecordReader
- Parameters:
p
- the file pointerlcount
- the line count at the specified positionk
- the record count at the specified position- Throws:
IOException
- ifpos
is less than0
or if an I/O error occurs.
-
getPosition
Gets the current position.- Returns:
- the position
-
appendLines
Appends lines to string buffer with closing '\n' character if it is not yet present.- Parameters:
sb
- the string bufferl
- the lines
-
appendLine
Appends line to string buffer with closing '\n' character.- Parameters:
sb
- the string bufferline
- the line
-
isPropertyRecord
public boolean isPropertyRecord()- Specified by:
isPropertyRecord
in interfaceMRecordReader
-
detectRecordPositions
@Deprecated @SubjectToRemoval(date=JUL_01_2025) public chemaxon.common.util.LongVector detectRecordPositions(chemaxon.common.util.IntVector linenums) throws MolFormatException Deprecated.Description copied from interface:MRecordReader
Detects positions of records in the input stream. Optionally returns also with the line number of records.- Specified by:
detectRecordPositions
in interfaceMRecordReader
- 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
-