Search in sources :

Example 1 with SplitResult

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();
}
Also used : SplitResult(com.google.gwt.regexp.shared.SplitResult) RegExp(com.google.gwt.regexp.shared.RegExp)

Example 2 with SplitResult

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());
}
Also used : SplitResult(com.google.gwt.regexp.shared.SplitResult) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement)

Aggregations

SplitResult (com.google.gwt.regexp.shared.SplitResult)2 RegExp (com.google.gwt.regexp.shared.RegExp)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 TextReportElement (org.activityinfo.legacy.shared.reports.model.TextReportElement)1