Class MultiSourceReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable

    @PublicApi
    public class MultiSourceReader
    extends java.io.Reader
    This reader allows you to read N number readers and combine them as one logical reader however you can then map back to the underlying readers in terms of their source name and the relative lines numbers. It can also track all data in memory if you want to have all of the previous read data in place at some point in time.
    • Method Detail

      • read

        public int read​(char[] cbuf,
                        int off,
                        int len)
                 throws java.io.IOException
        Specified by:
        read in class java.io.Reader
        Throws:
        java.io.IOException
      • getSourceAndLineFromOverallLine

        public MultiSourceReader.SourceAndLine getSourceAndLineFromOverallLine​(int overallLineNumber)
        This returns the source name and line number given an overall line number This is zeroes based like LineNumberReader.getLineNumber()
        Parameters:
        overallLineNumber - the over all line number
        Returns:
        the source name and relative line number to that source
      • getLineNumber

        public int getLineNumber()
        Returns:
        the line number of the current source. This is zeroes based like LineNumberReader.getLineNumber()
      • getSourceName

        public java.lang.String getSourceName()
        Returns:
        The name of the current source
      • getOverallLineNumber

        public int getOverallLineNumber()
        Returns:
        the overall line number of the all the sources. This is zeroes based like LineNumberReader.getLineNumber()
      • getData

        public java.util.List<java.lang.String> getData()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Reader
        Throws:
        java.io.IOException