List of utility methods to do String Indent Format
String | indentCode(String code, int indentLevel) Adds indentLevel spaces to every line of code. StringBuilder sb = new StringBuilder(); for (int i = 0; i < indentLevel; i++) { sb.append(' '); String indent = sb.toString(); sb = new StringBuilder(); String[] lines = code.split("\n"); for (String line : lines) { ... |
String | indented(String indenter, String s) This method doesn't honor consecutive \n's unless they're separated. String[] sArr = s.split("\n"); String result = ""; for (String currLine : sArr) { result += indenter + currLine + "\n"; return result; |
String | indentHtmlSpaces(int count) Indent with HTML no break spaces. StringBuilder builder = new StringBuilder(); for (int i = 0; i < count; i++) builder.append(" "); return builder.toString(); |
String | indention(int level, int tabSize) Create an indention string that contains level * tabSize space characters. StringBuilder indention = new StringBuilder(); for (int i = 0; i < level * tabSize; i++) { indention.append(" "); return indention.toString(); |
String | indentLinesAfterNth(final int skip, final int indent, final String str) indent Lines After Nth final StringBuilder prefix = new StringBuilder(); for (int i = 0; i < indent; i++) { prefix.append(' '); final StringBuilder out = new StringBuilder(); final String[] lines = str.split("\\n"); int count = 0; for (String line : lines) { ... |
void | indentMultilineValue(String value, StringBuilder tableInfo, int[] columnWidths, boolean printNull) comment indent processing for multi-line values values should be indented the same amount on each line if the first line comment starts indented by k, the following line comments should also be indented by k if (value == null) { if (printNull) { tableInfo.append(String.format("%-" + ALIGNMENT + "s", value)); tableInfo.append(LINE_DELIM); } else { String[] valueSegments = value.split("\n|\r|\r\n"); tableInfo.append(String.format("%-" + ALIGNMENT + "s", valueSegments[0])).append(LINE_DELIM); ... |
String | indentNextLines(String text, String indent) indent Next Lines String origText = new String(text); String ret = new String(); String[] lines = text.split("\\n"); for (int i = 0; i < lines.length; i++) { if (i == lines.length - 1 && !origText.endsWith("\n")) ret += indent + lines[i]; else ret += indent + lines[i] + "\n"; ... |
String | indentParagraph(String textBefore, String textToModify) Return a paragraph who insert spaces at the beginning of lines. int indexU = textBefore.lastIndexOf('\n'); return indentParagraph(textToModify, indexU + 1); |
String | indentRows(int level, String ss, String indentStr) indent Rows StringBuilder sb = new StringBuilder(); for (int ii = 0; ii < level; ii++) { sb.append(indentStr); ss = ss.replaceAll("(\r\n|\r|\n)", "\r\n"); ss = "\r\n" + ss; String repl = "\r\n" + sb.toString(); ss = ss.replace("\r\n", repl); ... |
String | indentStr(int level) indent Str if (level < XMLIndent.length) { return XMLIndent[level]; } else { return XMLIndent[XMLIndent.length - 1] + indentStr(level + 1 - XMLIndent.length); |