@Test public void testSimpleSqlWithCapitalization() { assertEquals("SELECT * \n FROM users ", fmt.prettyPrint("select * from users")); }
public String prettyPrint(String sqlObject) { if (!multiLine) { return prettyPrintLine(sqlObject); } else { StringBuilder sql = new StringBuilder(sqlObject.toString()); StringBuilder buf = new StringBuilder(sql.length()); while (sql.length() > 0) { String line = null; int index = Math.max(sql.toString().indexOf(";\n"), sql.toString().indexOf(";\r")); if (index == -1) line = sql.toString(); else line = sql.substring(0, index + 2); sql.delete(0, line.length()); buf.append(prettyPrintLine(line)); for (int i = 0; i < 1 + (isDoubleSpace() ? 1 : 0); i++) buf.append(newline); } return buf.toString(); } }
SQLFormatter { public String prettyPrint(String sqlObject) { if (!multiLine) { return prettyPrintLine(sqlObject); } else { StringBuilder sql = new StringBuilder(sqlObject.toString()); StringBuilder buf = new StringBuilder(sql.length()); while (sql.length() > 0) { String line = null; int index = Math.max(sql.toString().indexOf(";\n"), sql.toString().indexOf(";\r")); if (index == -1) line = sql.toString(); else line = sql.substring(0, index + 2); sql.delete(0, line.length()); buf.append(prettyPrintLine(line)); for (int i = 0; i < 1 + (isDoubleSpace() ? 1 : 0); i++) buf.append(newline); } return buf.toString(); } } }
SQLFormatter { public String prettyPrint(String sqlObject) { if (!multiLine) { return prettyPrintLine(sqlObject); } else { StringBuilder sql = new StringBuilder(sqlObject.toString()); StringBuilder buf = new StringBuilder(sql.length()); while (sql.length() > 0) { String line = null; int index = Math.max(sql.toString().indexOf(";\n"), sql.toString().indexOf(";\r")); if (index == -1) line = sql.toString(); else line = sql.substring(0, index + 2); sql.delete(0, line.length()); buf.append(prettyPrintLine(line)); for (int i = 0; i < 1 + (isDoubleSpace() ? 1 : 0); i++) buf.append(newline); } return buf.toString(); } } SQLFormatter(); }
SQLFormatter { public String prettyPrint(String sqlObject) { if (!multiLine) { return prettyPrintLine(sqlObject); } else { StringBuilder sql = new StringBuilder(sqlObject.toString()); StringBuilder buf = new StringBuilder(sql.length()); while (sql.length() > 0) { String line = null; int index = Math.max(sql.toString().indexOf(";\n"), sql.toString().indexOf(";\r")); if (index == -1) line = sql.toString(); else line = sql.substring(0, index + 2); sql.delete(0, line.length()); buf.append(prettyPrintLine(line)); for (int i = 0; i < 1 + (isDoubleSpace() ? 1 : 0); i++) buf.append(newline); } return buf.toString(); } } SQLFormatter(); void setNewline(String val); String getNewline(); void setLineLength(int val); int getLineLength(); void setWrapIndent(String val); String getWrapIndent(); void setClauseIndent(String val); String getClauseIndent(); void setMultiLine(boolean asMultiLine); boolean isMultiLine(); void setDoubleSpace(boolean useDoubleSpace); boolean isDoubleSpace(); String prettyPrint(String sqlObject); static void main(String[] args); }
SQLFormatter { public String prettyPrint(String sqlObject) { if (!multiLine) { return prettyPrintLine(sqlObject); } else { StringBuilder sql = new StringBuilder(sqlObject.toString()); StringBuilder buf = new StringBuilder(sql.length()); while (sql.length() > 0) { String line = null; int index = Math.max(sql.toString().indexOf(";\n"), sql.toString().indexOf(";\r")); if (index == -1) line = sql.toString(); else line = sql.substring(0, index + 2); sql.delete(0, line.length()); buf.append(prettyPrintLine(line)); for (int i = 0; i < 1 + (isDoubleSpace() ? 1 : 0); i++) buf.append(newline); } return buf.toString(); } } SQLFormatter(); void setNewline(String val); String getNewline(); void setLineLength(int val); int getLineLength(); void setWrapIndent(String val); String getWrapIndent(); void setClauseIndent(String val); String getClauseIndent(); void setMultiLine(boolean asMultiLine); boolean isMultiLine(); void setDoubleSpace(boolean useDoubleSpace); boolean isDoubleSpace(); String prettyPrint(String sqlObject); static void main(String[] args);  }