use of com.google.gwt.regexp.shared.SplitResult in project perun by CESNET.
the class JsonUtils method stringFormat.
/**
* Replacement for String.format in Java
* @param format Source format
*/
public static String stringFormat(final String format, final Object... args) {
final RegExp regex = RegExp.compile("%[a-z]");
final SplitResult split = regex.split(format);
final StringBuffer msg = new StringBuffer();
for (int pos = 0; pos < split.length() - 1; pos += 1) {
msg.append(split.get(pos));
msg.append(args[pos].toString());
}
msg.append(split.get(split.length() - 1));
return msg.toString();
}
use of com.google.gwt.regexp.shared.SplitResult in project activityinfo by bedatadriven.
the class ElementWidget method renderStaticHtml.
private void renderStaticHtml() {
String text = ((TextReportElement) model).getText();
SplitResult lines = RegExp.compile("\r?\n").split(Strings.nullToEmpty(text));
SafeHtmlBuilder html = new SafeHtmlBuilder();
for (int i = 0; i < lines.length(); i++) {
if (i > 0) {
html.appendHtmlConstant("<br>");
}
html.appendEscaped(lines.get(i));
}
updateHtml(html.toSafeHtml().asString());
}
Aggregations