@Test public void testSexySelect() { assertEquals("<span class='myClass myClass-select'>SELECT </span>* \n <span class='myClass myClass-from'>FROM </span>users ", formatter.toHtml("select * from users", "myClass")); }
public String toHtml(String query, String keywordClass) { String sql = formatter.prettyPrint(query); sql = HtmlUtils.htmlEscape(sql); for (int i = 0; i < KEYWORDS.length; i++) { String keyword = KEYWORDS[i][0]; String selectorSuffix = KEYWORDS[i][1]; if (sql.contains(keyword)) { String spanTag = makeSpanTag(keywordClass, selectorSuffix); String replace = new StringBuilder(spanTag).append(keyword).append("</span>").toString(); sql = sql.replace(keyword, replace); } } return sql; }
CQLToHtml { public String toHtml(String query, String keywordClass) { String sql = formatter.prettyPrint(query); sql = HtmlUtils.htmlEscape(sql); for (int i = 0; i < KEYWORDS.length; i++) { String keyword = KEYWORDS[i][0]; String selectorSuffix = KEYWORDS[i][1]; if (sql.contains(keyword)) { String spanTag = makeSpanTag(keywordClass, selectorSuffix); String replace = new StringBuilder(spanTag).append(keyword).append("</span>").toString(); sql = sql.replace(keyword, replace); } } return sql; } }
CQLToHtml { public String toHtml(String query, String keywordClass) { String sql = formatter.prettyPrint(query); sql = HtmlUtils.htmlEscape(sql); for (int i = 0; i < KEYWORDS.length; i++) { String keyword = KEYWORDS[i][0]; String selectorSuffix = KEYWORDS[i][1]; if (sql.contains(keyword)) { String spanTag = makeSpanTag(keywordClass, selectorSuffix); String replace = new StringBuilder(spanTag).append(keyword).append("</span>").toString(); sql = sql.replace(keyword, replace); } } return sql; } CQLToHtml(); }
CQLToHtml { public String toHtml(String query, String keywordClass) { String sql = formatter.prettyPrint(query); sql = HtmlUtils.htmlEscape(sql); for (int i = 0; i < KEYWORDS.length; i++) { String keyword = KEYWORDS[i][0]; String selectorSuffix = KEYWORDS[i][1]; if (sql.contains(keyword)) { String spanTag = makeSpanTag(keywordClass, selectorSuffix); String replace = new StringBuilder(spanTag).append(keyword).append("</span>").toString(); sql = sql.replace(keyword, replace); } } return sql; } CQLToHtml(); String toHtml(String query, String keywordClass); }
CQLToHtml { public String toHtml(String query, String keywordClass) { String sql = formatter.prettyPrint(query); sql = HtmlUtils.htmlEscape(sql); for (int i = 0; i < KEYWORDS.length; i++) { String keyword = KEYWORDS[i][0]; String selectorSuffix = KEYWORDS[i][1]; if (sql.contains(keyword)) { String spanTag = makeSpanTag(keywordClass, selectorSuffix); String replace = new StringBuilder(spanTag).append(keyword).append("</span>").toString(); sql = sql.replace(keyword, replace); } } return sql; } CQLToHtml(); String toHtml(String query, String keywordClass);  }