Class AbstractMRecordReader

java.lang.Object
chemaxon.marvin.io.formats.AbstractMRecordReader
All Implemented Interfaces:
MRecordReader

@PublicApi public abstract class AbstractMRecordReader extends Object implements 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
  • Constructor Details

  • Method Details

    • setProgressMonitor

      public void setProgressMonitor(MProgressMonitor pmon)
      Sets the progress monitor. The default implementation does nothing.
      Specified by:
      setProgressMonitor in interface MRecordReader
      Parameters:
      pmon - the progress monitor
    • getRecognizedFormat

      public String getRecognizedFormat()
      Gets the recognized file format.
      Specified by:
      getRecognizedFormat in interface MRecordReader
      Returns:
      the input file format
    • getHeaderAsString

      public String getHeaderAsString()
      Gets the header of the file as a string.
      Specified by:
      getHeaderAsString in interface MRecordReader
      Returns:
      empty string in the default implementation
      Since:
      Marvin 5.0.2, 03/11/2008
    • getFooterAsString

      public String getFooterAsString()
      Gets the footer of the file as a string.
      Specified by:
      getFooterAsString in interface MRecordReader
      Returns:
      empty string in the default implementation
      Since:
      Marvin 5.0.2, 03/11/2008
    • getOptions

      public String getOptions()
      Gets the import options.
      Specified by:
      getOptions in interface MRecordReader
      Returns:
      the import options
    • readLine

      protected String readLine() throws IOException
      Reads the next line.
      Returns:
      the next line
      Throws:
      IOException
    • skipLine

      protected boolean skipLine() throws IOException
      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

      protected void putBackLine() throws IOException
      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 interface MRecordReader
    • getEncapsulatedReader

      public MRecordReader getEncapsulatedReader()
      Gets the encapsulated record reader if it exists.
      Specified by:
      getEncapsulatedReader in interface MRecordReader
      Returns:
      the encapsulated record reader or null
    • getMolInputStream

      public MolInputStream getMolInputStream()
      Gets the molecule input stream.
      Specified by:
      getMolInputStream in interface MRecordReader
      Returns:
      the molecule input stream
    • getFilePointer

      public long getFilePointer()
      Get the file pointer.
      Specified by:
      getFilePointer in interface MRecordReader
      Returns:
      the file pointer
    • getLineCount

      public int getLineCount()
      Get the current line number.
      Specified by:
      getLineCount in interface MRecordReader
      Returns:
      the line number
    • isSeekable

      public boolean isSeekable()
      Tests whether the record reader is seekable.
      Specified by:
      isSeekable in interface MRecordReader
      Returns:
      true if it is seekable, false otherwise
    • seek

      public void seek(long p, int lcount, int k) throws IOException
      Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
      Specified by:
      seek in interface MRecordReader
      Parameters:
      p - the file pointer
      lcount - the line count at the specified position
      k - the record count at the specified position
      Throws:
      IOException - if pos is less than 0 or if an I/O error occurs.
    • getPosition

      protected MRecordReader.Position getPosition()
      Gets the current position.
      Returns:
      the position
    • appendLines

      protected void appendLines(StringBuffer sb, String l)
      Appends lines to string buffer with closing '\n' character if it is not yet present.
      Parameters:
      sb - the string buffer
      l - the lines
    • appendLine

      protected void appendLine(StringBuffer sb, String line)
      Appends line to string buffer with closing '\n' character.
      Parameters:
      sb - the string buffer
      line - the line
    • isPropertyRecord

      public boolean isPropertyRecord()
      Specified by:
      isPropertyRecord in interface MRecordReader
    • 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 interface MRecordReader
      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