/** * read the next length characters and move the pointer. * * @param length */ public void forward(int length) { if (this.pointer + length + 1 >= this.buffer.length()) { update(); } char ch = 0; for (int i = 0; i < length; i++) { ch = this.buffer.charAt(this.pointer); this.pointer++; this.index++; if (Constant.LINEBR.has(ch) || (ch == '\r' && buffer.charAt(pointer) != '\n')) { this.line++; this.column = 0; } else if (ch != '\uFEFF') { this.column++; } } }
/** * 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) { int c; for (int i = 0; i < length; i++) { if (this.pointer == this.buffer.length()) { update(); } if (this.pointer == this.buffer.length()) { break; } c = this.buffer.codePointAt(this.pointer); this.pointer += Character.charCount(c); this.index += Character.charCount(c); if (Constant.LINEBR.has(c) || (c == '\r' && buffer.charAt(pointer) != '\n')) { this.line++; this.column = 0; } else if (c != 0xFEFF) { this.column++; } } if (this.pointer == this.buffer.length()) { update(); } }
private String determineBlockHints(String text) { StringBuilder hints = new StringBuilder(); // if (Constant.LINEBR.has(text.charAt(0), " ")) disabled, always add indent marker to prevent formatting problems. { hints.append(this.bestIndent); } char ch1 = text.charAt(text.length() - 1); if (Constant.LINEBR.hasNo(ch1)) { hints.append("-"); } else if ((text.length() == 1) || Constant.LINEBR.has(text.charAt(text.length() - 2))) { hints.append("+"); } return hints.toString(); }
/** * read the next length characters and move the pointer. * */ public void forward(final int length) { if (this.pointer + length + 1 >= this.buffer.length()) { update(); } char ch = 0; for (int i = 0; i < length; i++) { ch = this.buffer.charAt(this.pointer); this.pointer++; this.index++; if (Constant.LINEBR.has(ch) || (ch == '\r' && buffer.charAt(pointer) != '\n')) { this.line++; this.column = 0; } else if (ch != '\uFEFF') { this.column++; } } }
private String determineBlockHints(String text) { StringBuilder hints = new StringBuilder(); if (Constant.LINEBR.has(text.charAt(0), " ")) { hints.append(bestIndent); } char ch1 = text.charAt(text.length() - 1); if (Constant.LINEBR.hasNo(ch1)) { hints.append("-"); } else if (text.length() == 1 || Constant.LINEBR.has(text.charAt(text.length() - 2))) { hints.append("+"); } return hints.toString(); }
private boolean isLineBreak(char ch) { return Constant.NULL_OR_LINEBR.has(ch); }
void writeLiteral(String text) throws IOException { String hints = determineBlockHints(text); writeIndicator("|" + hints, true, false, false); if (hints.length() > 0 && (hints.charAt(hints.length() - 1)) == '+') { openEnded = true; } writeLineBreak(null); boolean breaks = true; int start = 0, end = 0; while (end <= text.length()) { char ch = 0; if (end < text.length()) { ch = text.charAt(end); } if (breaks) { if (ch == 0 || Constant.LINEBR.hasNo(ch)) { String data = text.substring(start, end); for (char br : data.toCharArray()) { if (br == '\n') { writeLineBreak(null); } else { writeLineBreak(String.valueOf(br)); } } if (ch != 0) { writeIndent(); } start = end; } } else { if (ch == 0 || Constant.LINEBR.has(ch)) { stream.write(text, start, end - start); if (ch == 0) { writeLineBreak(null); } start = end; } } if (ch != 0) { breaks = Constant.LINEBR.has(ch); } end++; } }
private boolean isLineBreak(int c) { return Constant.NULL_OR_LINEBR.has(c); }
void writeLiteral(String text) throws IOException { String hints = this.determineBlockHints(text); this.writeIndicator("|" + hints, true, false, false); if (! hints.isEmpty() && ((hints.charAt(hints.length() - 1)) == '+')) { this.openEnded = true; } this.writeLineBreak(null); boolean breaks = true; int start = 0, end = 0; while (end <= text.length()) { char ch = 0; if (end < text.length()) { ch = text.charAt(end); } if (breaks) { if ((ch == 0) || Constant.LINEBR.hasNo(ch)) { String data = text.substring(start, end); for (char br : data.toCharArray()) { if (br == '\n') { this.writeLineBreak(null); } else { this.writeLineBreak(String.valueOf(br)); } } if (ch != 0) { this.writeIndent(); } start = end; } } else { if ((ch == 0) || Constant.LINEBR.has(ch)) { this.stream.write(text, start, end - start); if (ch == 0) { this.writeLineBreak(null); } start = end; } } if (ch != 0) { breaks = Constant.LINEBR.has(ch); } end++; } }
void writeLiteral(String text) throws IOException { String hints = determineBlockHints(text); writeIndicator("|" + hints, true, false, false); if (hints.length() > 0 && (hints.charAt(hints.length() - 1)) == '+') { openEnded = true; } writeLineBreak(null); boolean breaks = true; int start = 0, end = 0; while (end <= text.length()) { char ch = 0; if (end < text.length()) { ch = text.charAt(end); } if (breaks) { if (ch == 0 || Constant.LINEBR.hasNo(ch)) { String data = text.substring(start, end); for (char br : data.toCharArray()) { if (br == '\n') { writeLineBreak(null); } else { writeLineBreak(String.valueOf(br)); } } if (ch != 0) { writeIndent(); } start = end; } } else { if (ch == 0 || Constant.LINEBR.has(ch)) { stream.write(text, start, end - start); if (ch == 0) { writeLineBreak(null); } start = end; } } if (ch != 0) { breaks = (Constant.LINEBR.has(ch)); } end++; } }