/** * Peek the next index-th code point * * @param index to peek * @return the next index-th code point */ public int peek(int index) { return (ensureEnoughData(index)) ? dataWindow[pointer + index] : '\0'; }
public int peek() { return (ensureEnoughData()) ? dataWindow[pointer] : '\0'; }
private boolean ensureEnoughData() { return ensureEnoughData(0); }
/** * peek the next length code points * * @param length amount of the characters to peek * @return the next length code points */ public String prefix(int length) { if (length == 0) { return ""; } else if (ensureEnoughData(length)) { return new String(this.dataWindow, pointer, length); } else { return new String(this.dataWindow, pointer, Math.min(length, dataLength - pointer)); } }
/** * read the next length characters and move the pointer. * if the last character is high surrogate one more character will be read * * @param length amount of characters to move forward */ public void forward(int length) { for (int i = 0; i < length && ensureEnoughData(); i++) { int c = dataWindow[pointer++]; this.index++; if (Constant.LINEBR.has(c) || (c == '\r' && (ensureEnoughData() && dataWindow[pointer] != '\n'))) { this.line++; this.column = 0; } else if (c != 0xFEFF) { this.column++; } } }
/** * Peek the next index-th code point * * @param index to peek * @return the next index-th code point */ public int peek(int index) { return (ensureEnoughData(index)) ? dataWindow[pointer + index] : '\0'; }
public int peek() { return (ensureEnoughData()) ? dataWindow[pointer] : '\0'; }
private boolean ensureEnoughData() { return ensureEnoughData(0); }
/** * read the next length characters and move the pointer. * if the last character is high surrogate one more character will be read * * @param length amount of characters to move forward */ public void forward(int length) { for (int i = 0; i < length && ensureEnoughData(); i++) { int c = dataWindow[pointer++]; this.index++; if (Constant.LINEBR.has(c) || (c == '\r' && (ensureEnoughData() && dataWindow[pointer] != '\n'))) { this.line++; this.column = 0; } else if (c != 0xFEFF) { this.column++; } } }
/** * peek the next length code points * * @param length amount of the characters to peek * @return the next length code points */ public String prefix(int length) { if (length == 0) { return ""; } else if (ensureEnoughData(length)) { return new String(this.dataWindow, pointer, length); } else { return new String(this.dataWindow, pointer, Math.min(length, dataLength - pointer)); } }