use of org.h2.build.doc.BnfSyntax in project h2database by h2database.
the class Railroads method map.
private void map(String key, ResultSet rs, boolean railroads) throws Exception {
ArrayList<HashMap<String, String>> list;
list = new ArrayList<>();
while (rs.next()) {
HashMap<String, String> map = new HashMap<>();
ResultSetMetaData meta = rs.getMetaData();
for (int i = 0; i < meta.getColumnCount(); i++) {
String k = StringUtils.toLowerEnglish(meta.getColumnLabel(i + 1));
String value = rs.getString(i + 1);
value = value.trim();
map.put(k, PageParser.escapeHtml(value));
}
String topic = rs.getString("TOPIC");
String syntax = rs.getString("SYNTAX").trim();
if (railroads) {
BnfRailroad r = new BnfRailroad();
String railroad = r.getHtml(bnf, syntax);
map.put("railroad", railroad);
}
BnfSyntax visitor = new BnfSyntax();
String syntaxHtml = visitor.getHtml(bnf, syntax);
map.put("syntax", syntaxHtml);
// remove newlines in the regular text
String text = map.get("text");
if (text != null) {
// text is enclosed in <p> .. </p> so this works.
text = StringUtils.replaceAll(text, "<br /><br />", "</p><p>");
text = StringUtils.replaceAll(text, "<br />", " ");
map.put("text", text);
}
String link = topic.toLowerCase();
link = link.replace(' ', '_');
// link = StringUtils.replaceAll(link, "_", "");
link = link.replace('@', '_');
map.put("link", StringUtils.urlEncode(link));
list.add(map);
}
session.put(key, list);
int div = 3;
int part = (list.size() + div - 1) / div;
for (int i = 0, start = 0; i < div; i++, start += part) {
List<HashMap<String, String>> listThird = list.subList(start, Math.min(start + part, list.size()));
session.put(key + "-" + i, listThird);
}
rs.close();
}
Aggregations