Package graphql.parser
Class MultiSourceReader
java.lang.Object
java.io.Reader
graphql.parser.MultiSourceReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
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 ClassesModifier and TypeClassDescriptionstatic classstatic classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate final StringBuilderprivate intprivate final LockKit.ReentrantLockprivate final List<MultiSourceReader.SourcePart> private final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate intvoidclose()getData()intintgetSourceAndLineFromOverallLine(int overallLineNumber) This returns the source name and line number given an overall line number This is zeroes based likeLineNumberReader.getLineNumber()static MultiSourceReader.Builderintread(char[] cbuf, int off, int len) private voidtrackData(char[] cbuf, int off, int len)
-
Field Details
-
sourceParts
-
data
-
currentIndex
private int currentIndex -
overallLineNumber
private int overallLineNumber -
trackData
private final boolean trackData -
readerLock
-
-
Constructor Details
-
MultiSourceReader
-
-
Method Details
-
read
- Specified by:
readin classReader- Throws:
IOException
-
trackData
private void trackData(char[] cbuf, int off, int len) -
calcLineNumber
private int calcLineNumber() -
getSourceAndLineFromOverallLine
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
- 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
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-
newMultiSourceReader
-