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
ConstructorsModifierConstructorDescriptionprotectedAbstractMRecordReader(InputStream istr, String opts) Constructs an abstract record reader.protectedAbstractMRecordReader(InputStream istr, String opts, String path) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendLine(StringBuffer sb, String line) Appends line to string buffer with closing '\n' character.protected voidappendLines(StringBuffer sb, String l) Appends lines to string buffer with closing '\n' character if it is not yet present.voidclose()Interrupts parsing.chemaxon.common.util.LongVectordetectRecordPositions(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.longGet the file pointer.Gets the footer of the file as a string.Gets the header of the file as a string.intGet the current line number.Gets the molecule input stream.Gets the import options.protected MRecordReader.PositionGets the current position.Gets the recognized file format.booleanbooleanTests whether the record reader is seekable.protected voidPuts back the previous line to the input stream.protected StringreadLine()Reads the next line.voidseek(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.voidSets the progress monitor.protected booleanskipLine()Skips the next line.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
setProgressMonitorin interfaceMRecordReader- Parameters:
pmon- the progress monitor
-
getRecognizedFormat
Gets the recognized file format.- Specified by:
getRecognizedFormatin interfaceMRecordReader- Returns:
- the input file format
-
getHeaderAsString
Gets the header of the file as a string.- Specified by:
getHeaderAsStringin interfaceMRecordReader- Returns:
- empty string in the default implementation
- Since:
- Marvin 5.0.2, 03/11/2008
-
getOptions
Gets the import options.- Specified by:
getOptionsin 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:
trueif a line was skipped successfully,falseat 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:
closein interfaceMRecordReader
-
getEncapsulatedReader
Gets the encapsulated record reader if it exists.- Specified by:
getEncapsulatedReaderin interfaceMRecordReader- Returns:
- the encapsulated record reader or
null
-
getMolInputStream
Gets the molecule input stream.- Specified by:
getMolInputStreamin interfaceMRecordReader- Returns:
- the molecule input stream
-
getFilePointer
public long getFilePointer()Get the file pointer.- Specified by:
getFilePointerin interfaceMRecordReader- Returns:
- the file pointer
-
getLineCount
public int getLineCount()Get the current line number.- Specified by:
getLineCountin interfaceMRecordReader- Returns:
- the line number
-
isSeekable
public boolean isSeekable()Tests whether the record reader is seekable.- Specified by:
isSeekablein interfaceMRecordReader- Returns:
trueif it is seekable,falseotherwise
-
seek
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.- Specified by:
seekin interfaceMRecordReader- Parameters:
p- the file pointerlcount- the line count at the specified positionk- the record count at the specified position- Throws:
IOException- ifposis less than0or 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:
isPropertyRecordin 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:MRecordReaderDetects positions of records in the input stream. Optionally returns also with the line number of records.- Specified by:
detectRecordPositionsin 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
-