MCPcopy Index your code
hub / github.com/apache/groovy / LineColumnReader

Class LineColumnReader

src/main/java/groovy/io/LineColumnReader.java:32–291  ·  view source on GitHub ↗

The LineColumnReader is an extension to BufferedReader that keeps track of the line and column information of where the cursor is. @since 1.8.0

Source from the content-addressed store, hash-verified

30 * @since 1.8.0
31 */
32public class LineColumnReader extends BufferedReader {
33
34 /**
35 * The current line position
36 */
37 private long line = 1;
38
39 /**
40 * The current column position
41 */
42 private long column = 1;
43
44 /**
45 * The latest marked line position
46 */
47 private long lineMark = 1;
48
49 /**
50 * The latest marked line position
51 */
52 private long columnMark = 1;
53
54 private boolean newLineWasRead = false;
55
56 /**
57 * Constructor wrapping a <code>Reader</code>
58 * (<code>FileReader</code>, <code>FileReader</code>, <code>InputStreamReader</code>, etc.)
59 *
60 * @param reader the reader to wrap
61 */
62 public LineColumnReader(Reader reader) {
63 super(reader);
64 }
65
66 /**
67 * Marks the present position in the stream. Subsequent calls to reset() will attempt to reposition the stream to this point.
68 *
69 * @param readAheadLimit Limit on the number of characters that may be read while still preserving the mark.
70 * An attempt to reset the stream after reading characters up to this limit or beyond may fail.
71 * A limit value larger than the size of the input buffer will cause a new buffer to be allocated whose size is no smaller than limit.
72 * Therefore large values should be used with care.
73 */
74 @Override
75 public void mark(int readAheadLimit) throws IOException {
76 lineMark = line;
77 columnMark = column;
78 super.mark(readAheadLimit);
79 }
80
81 /**
82 * Resets the stream to the most recent mark.
83 */
84 @Override
85 public void reset() throws IOException {
86 line = lineMark;
87 column = columnMark;
88 super.reset();
89 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…