1 package org.simantics.scl.compiler.completions.parsing;
3 import java.io.IOException;
7 * Based on java.io.StringReader.
10 public class SubstringReader extends Reader {
17 public SubstringReader(String str, int begin, int end) {
24 public int read() throws IOException {
27 return str.charAt(pos++);
30 public int read(char cbuf[], int off, int len) throws IOException {
31 if ((off < 0) || (off > cbuf.length) || (len < 0) ||
32 ((off + len) > cbuf.length) || ((off + len) < 0))
33 throw new IndexOutOfBoundsException();
38 int n = Math.min(end - pos, len);
39 str.getChars(pos, pos + n, cbuf, off);
44 public long skip(long ns) throws IOException {
47 // Bound skip by beginning and end of the source
48 long n = Math.min(end - pos, ns);
49 n = Math.max(-pos, n);
54 public boolean ready() throws IOException {
58 public boolean markSupported() {
62 public void mark(int readAheadLimit) throws IOException {
63 if (readAheadLimit < 0)
64 throw new IllegalArgumentException("Read-ahead limit < 0");
68 public void reset() throws IOException {