/** * Like {@link #isTrimmableToEmpty(char[])}, but acts on a sub-array that starts at {@code start} (inclusive index). * * @since 2.3.23 */ public static boolean isTrimmableToEmpty(char[] text, int start) { return isTrimmableToEmpty(text, start, text.length); }
/** * Tells if {@link String#trim()} will return a 0-length string for the {@link String} equivalent of the argument. * * @since 2.3.22 */ public static boolean isTrimmableToEmpty(char[] text) { return isTrimmableToEmpty(text, 0, text.length); }
/** * figures out how many trailing whitespace characters to strip * in the post-parse cleanup phase. */ private int trailingCharsToStrip() { int lastNewlineIndex = lastNewLineIndex(); if (lastNewlineIndex == -1 && beginColumn != 1) { return 0; } if (!StringUtil.isTrimmableToEmpty(text, lastNewlineIndex + 1)) { return 0; } // We look at the elements afterward on the same line to see if we should // strip any whitespace after the last newline for (TemplateElement elem = this.nextTerminalNode(); elem != null && elem.beginLine == this.endLine; elem = elem.nextTerminalNode()) { if (elem.heedsTrailingWhitespace()) { return 0; } } return text.length - (lastNewlineIndex + 1); }
/** * figures out how many opening whitespace characters to strip * in the post-parse cleanup phase. */ private int openingCharsToStrip() { int newlineIndex = firstNewLineIndex(); if (newlineIndex == -1 && beginColumn != 1) { return 0; } ++newlineIndex; if (text.length > newlineIndex) { if (newlineIndex > 0 && text[newlineIndex - 1] == '\r' && text[newlineIndex] == '\n') { ++newlineIndex; } } if (!StringUtil.isTrimmableToEmpty(text, 0, newlineIndex)) { return 0; } // We look at the preceding elements on the line to see if we should // strip the opening newline and any whitespace preceding it. for (TemplateElement elem = this.prevTerminalNode(); elem != null && elem.endLine == this.beginLine; elem = elem.prevTerminalNode()) { if (elem.heedsOpeningWhitespace()) { return 0; } } return newlineIndex; }
@Override boolean isIgnorable(boolean stripWhitespace) { if (text == null || text.length == 0) { return true; } if (stripWhitespace) { if (!StringUtil.isTrimmableToEmpty(text)) { return false; } TemplateElement parentElement = getParentElement(); boolean atTopLevel = isTopLevelTextIfParentIs(parentElement); TemplateElement prevSibling = previousSibling(); TemplateElement nextSibling = nextSibling(); return ((prevSibling == null && atTopLevel) || nonOutputtingType(prevSibling)) && ((nextSibling == null && atTopLevel) || nonOutputtingType(nextSibling)); } else { return false; } }
if (StringUtil.isTrimmableToEmpty(openingPart)) { this.text = trailingPart; this.beginLine++; if (StringUtil.isTrimmableToEmpty(trailingPart)) {
char[] firstPart = substring(text, 0, lastNewLineIndex + 1); char[] lastLine = substring(text, 1 + lastNewLineIndex); if (StringUtil.isTrimmableToEmpty(lastLine)) { this.text = firstPart; this.endColumn = 0;
/** * Like {@link #isTrimmableToEmpty(char[])}, but acts on a sub-array that starts at {@code start} (inclusive index). * * @since 2.3.23 */ public static boolean isTrimmableToEmpty(char[] text, int start) { return isTrimmableToEmpty(text, start, text.length); }
/** * Tells if {@link String#trim()} will return a 0-length string for the {@link String} equivalent of the argument. * * @since 2.3.22 */ public static boolean isTrimmableToEmpty(char[] text) { return isTrimmableToEmpty(text, 0, text.length); }
/** * Tells if {@link String#trim()} will return a 0-length string for the {@link String} equivalent of the argument. * * @since 2.3.22 */ public static boolean isTrimmableToEmpty(char[] text) { return isTrimmableToEmpty(text, 0, text.length); }
/** * Like {@link #isTrimmableToEmpty(char[])}, but acts on a sub-array that starts at {@code start} (inclusive index). * * @since 2.3.23 */ public static boolean isTrimmableToEmpty(char[] text, int start) { return isTrimmableToEmpty(text, start, text.length); }
/** * figures out how many trailing whitespace characters to strip * in the post-parse cleanup phase. */ private int trailingCharsToStrip() { int lastNewlineIndex = lastNewLineIndex(); if (lastNewlineIndex == -1 && beginColumn != 1) { return 0; } if (!StringUtil.isTrimmableToEmpty(text, lastNewlineIndex + 1)) { return 0; } // We look at the elements afterward on the same line to see if we should // strip any whitespace after the last newline for (TemplateElement elem = this.nextTerminalNode(); elem != null && elem.beginLine == this.endLine; elem = elem.nextTerminalNode()) { if (elem.heedsTrailingWhitespace()) { return 0; } } return text.length - (lastNewlineIndex + 1); }
/** * figures out how many trailing whitespace characters to strip * in the post-parse cleanup phase. */ private int trailingCharsToStrip() { int lastNewlineIndex = lastNewLineIndex(); if (lastNewlineIndex == -1 && beginColumn != 1) { return 0; } if (!StringUtil.isTrimmableToEmpty(text, lastNewlineIndex + 1)) { return 0; } // We look at the elements afterward on the same line to see if we should // strip any whitespace after the last newline for (TemplateElement elem = this.nextTerminalNode(); elem != null && elem.beginLine == this.endLine; elem = elem.nextTerminalNode()) { if (elem.heedsTrailingWhitespace()) { return 0; } } return text.length - (lastNewlineIndex + 1); }
/** * figures out how many opening whitespace characters to strip * in the post-parse cleanup phase. */ private int openingCharsToStrip() { int newlineIndex = firstNewLineIndex(); if (newlineIndex == -1 && beginColumn != 1) { return 0; } ++newlineIndex; if (text.length > newlineIndex) { if (newlineIndex > 0 && text[newlineIndex - 1] == '\r' && text[newlineIndex] == '\n') { ++newlineIndex; } } if (!StringUtil.isTrimmableToEmpty(text, 0, newlineIndex)) { return 0; } // We look at the preceding elements on the line to see if we should // strip the opening newline and any whitespace preceding it. for (TemplateElement elem = this.prevTerminalNode(); elem != null && elem.endLine == this.beginLine; elem = elem.prevTerminalNode()) { if (elem.heedsOpeningWhitespace()) { return 0; } } return newlineIndex; }
/** * figures out how many opening whitespace characters to strip * in the post-parse cleanup phase. */ private int openingCharsToStrip() { int newlineIndex = firstNewLineIndex(); if (newlineIndex == -1 && beginColumn != 1) { return 0; } ++newlineIndex; if (text.length > newlineIndex) { if (newlineIndex > 0 && text[newlineIndex - 1] == '\r' && text[newlineIndex] == '\n') { ++newlineIndex; } } if (!StringUtil.isTrimmableToEmpty(text, 0, newlineIndex)) { return 0; } // We look at the preceding elements on the line to see if we should // strip the opening newline and any whitespace preceding it. for (TemplateElement elem = this.prevTerminalNode(); elem != null && elem.endLine == this.beginLine; elem = elem.prevTerminalNode()) { if (elem.heedsOpeningWhitespace()) { return 0; } } return newlineIndex; }
@Override boolean isIgnorable(boolean stripWhitespace) { if (text == null || text.length == 0) { return true; } if (stripWhitespace) { if (!StringUtil.isTrimmableToEmpty(text)) { return false; } TemplateElement parentElement = getParentElement(); boolean atTopLevel = isTopLevelTextIfParentIs(parentElement); TemplateElement prevSibling = previousSibling(); TemplateElement nextSibling = nextSibling(); return ((prevSibling == null && atTopLevel) || nonOutputtingType(prevSibling)) && ((nextSibling == null && atTopLevel) || nonOutputtingType(nextSibling)); } else { return false; } }
@Override boolean isIgnorable(boolean stripWhitespace) { if (text == null || text.length == 0) { return true; } if (stripWhitespace) { if (!StringUtil.isTrimmableToEmpty(text)) { return false; } TemplateElement parentElement = getParentElement(); boolean atTopLevel = isTopLevelTextIfParentIs(parentElement); TemplateElement prevSibling = previousSibling(); TemplateElement nextSibling = nextSibling(); return ((prevSibling == null && atTopLevel) || nonOutputtingType(prevSibling)) && ((nextSibling == null && atTopLevel) || nonOutputtingType(nextSibling)); } else { return false; } }
char[] firstPart = substring(text, 0, lastNewLineIndex + 1); char[] lastLine = substring(text, 1 + lastNewLineIndex); if (StringUtil.isTrimmableToEmpty(lastLine)) { this.text = firstPart; this.endColumn = 0;
char[] firstPart = substring(text, 0, lastNewLineIndex + 1); char[] lastLine = substring(text, 1 + lastNewLineIndex); if (StringUtil.isTrimmableToEmpty(lastLine)) { this.text = firstPart; this.endColumn = 0;
if (StringUtil.isTrimmableToEmpty(openingPart)) { this.text = trailingPart; this.beginLine++; if (StringUtil.isTrimmableToEmpty(trailingPart)) {