Example usage for org.springframework.web.util HtmlUtils htmlEscapeDecimal

List of usage examples for org.springframework.web.util HtmlUtils htmlEscapeDecimal

Introduction

In this page you can find the example usage for org.springframework.web.util HtmlUtils htmlEscapeDecimal.

Prototype

public static String htmlEscapeDecimal(String input) 

Source Link

Document

Turn special characters into HTML character references.

Usage

From source file:org.mzd.shap.util.HtmlFormatter.java

public HtmlFormatter(String cssClass, String delim, DecimalFormat decimalFormat) {
    this.cssClass = cssClass;
    this.delim = HtmlUtils.htmlEscapeDecimal(delim);
    this.decimalFormat = decimalFormat;
}

From source file:org.mzd.shap.util.HtmlFormatter.java

protected String valueToString(Object value) {
    String ret;/* ww  w . j ava2  s  .c  o  m*/
    if (value == null) {
        ret = "";
    } else if (value instanceof Number) {
        ret = decimalFormat.format(value);
    } else {
        ret = value.toString();
    }
    return HtmlUtils.htmlEscapeDecimal(ret);
}

From source file:org.mzd.shap.util.HtmlFormatter.java

/**
 * Wrap a name/value pair by {@code <span>} tags.
 * /* w ww  . jav  a  2s . com*/
 * @param name
 * @param value
 * @return HTML string.
 */
public String propertyToHtml(String name, Object value) {
    return new StringBuffer().append("<span class=\"" + parentClass() + "\">")
            .append("<span class=\"" + childClass(PROPERTY_SUFFIX) + "\">")
            .append(HtmlUtils.htmlEscapeDecimal(name)).append("</span>")
            .append("<span class=\"" + childClass(DELIMITER_SUFFIX) + "\">").append(delim).append("</span>")
            .append("<span class=\"" + childClass(VALUE_SUFFIX) + "\">").append(valueToString(value))
            .append("</span>").append("</span>").toString();
}

From source file:org.springframework.web.util.HtmlUtilsTest.java

/**
 * Test html utils./*from ww  w .j a  v a  2s . com*/
 */
@Test
public void testHtmlUtils() {
    String specialStr = "<div id=\"testDiv\">test1;test2</div>";
    String str1 = HtmlUtils.htmlEscape(specialStr); //  HTML  HTML ?
    log.info(str1);

    String str2 = HtmlUtils.htmlEscapeDecimal(specialStr);//  HTML  # ????
    log.info(str2);

    String str3 = HtmlUtils.htmlEscapeHex(specialStr);//  HTML  # ????
    log.info(str3);

    // ??????
    log.info(HtmlUtils.htmlUnescape(str1));
    log.info(HtmlUtils.htmlUnescape(str2));
    log.info(HtmlUtils.htmlUnescape(str3));

    log.info(StringEscapeUtils.unescapeHtml4(str1));
    log.info(StringEscapeUtils.unescapeHtml4(str2));
    log.info(StringEscapeUtils.unescapeHtml4(str3));

    log.info(org.apache.commons.lang.StringEscapeUtils.unescapeHtml(str1));
    log.info(org.apache.commons.lang.StringEscapeUtils.unescapeHtml(str2));
    log.info(org.apache.commons.lang.StringEscapeUtils.unescapeHtml(str3));
}