Package graphql.parser
Class MultiSourceReader
- java.lang.Object
-
- java.io.Reader
-
- graphql.parser.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MultiSourceReader.Builder
static class
MultiSourceReader.SourceAndLine
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.util.List<java.lang.String>
getData()
int
getLineNumber()
int
getOverallLineNumber()
MultiSourceReader.SourceAndLine
getSourceAndLineFromOverallLine(int overallLineNumber)
This returns the source name and line number given an overall line number This is zeroes based likeLineNumberReader.getLineNumber()
java.lang.String
getSourceName()
static MultiSourceReader.Builder
newMultiSourceReader()
int
read(char[] cbuf, int off, int len)
-
-
-
Method Detail
-
read
public int read(char[] cbuf, int off, int len) throws java.io.IOException
- Specified by:
read
in classjava.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 likeLineNumberReader.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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
newMultiSourceReader
public static MultiSourceReader.Builder newMultiSourceReader()
-
-