Interface ContextualFileReader

All Known Implementing Classes:
ImportProcessingContext, ImportValidationContext

public interface ContextualFileReader
A corrolary to FileReader but keeps track of an internal context itself. Generally, implementations will delegate to an internal FileReader for all of its operations.
Author:
Phillip Verheyden (phillipuniverse)
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Counts all of the data records within the file.
    long
    The current line that the context is pointing to, 1-indexed
    Obtains the headers for the current file
    boolean
    Whether or not there are more data records to read.
    Returns the next row of data.
  • Method Details

    • countTotalItems

      long countTotalItems(InputStream file)
      Counts all of the data records within the file. This should not include all of the physical lines within the file. For instance this should not include the header line or any lines that are denoted as comments
      Parameters:
      file - file to count records for
      Returns:
      the total number of data records in the file
    • getHeaders

      String[] getHeaders()
      Obtains the headers for the current file
      Returns:
      the headers from the file
    • currentLineNumber

      long currentLineNumber()
      The current line that the context is pointing to, 1-indexed
      Returns:
      the current line number that this reader is pointing to
    • hasNext

      boolean hasNext()
      Whether or not there are more data records to read. Should be used as a guard against readNextLine() to protect against an attempt at reading too far
      Returns:
      whether or not there are more data records to read
    • readNextLine

      Map<String,String> readNextLine()
      Returns the next row of data. Keys correspond to the headers and values are the specific values for those headers
      Returns:
      a row of data from the file