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

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

Introduction

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

Prototype

public static String htmlEscape(String input) 

Source Link

Document

Turn special characters into HTML character references.

Usage

From source file:cn.guoyukun.spring.web.form.ValueFormatter.java

public static String getDisplayString(Object value, boolean htmlEscape) {
    String displayValue = ObjectUtils.getDisplayString(value);
    return (htmlEscape ? HtmlUtils.htmlEscape(displayValue) : displayValue);
}

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

/**
 * Replace all occurrences of special characters in HTML entity references.
 * /*w w  w.j  a va2  s. c  o m*/
 * @param target - string to encode
 * @return encoded version of string.
 */
static public String htmlEncode(String target) {
    return HtmlUtils.htmlEscape(target);
}

From source file:io.kaif.kmark.KmarkProcessor.java

public static String escapeHtml(String input) {
    return HtmlUtils.htmlEscape(input);
}

From source file:org.terasoluna.gfw.web.util.HtmlEscapeUtils.java

/**
 * escape html tags in the given string.
 * <p>/*from   w  ww.  j a v  a  2 s  . c o  m*/
 * target characters to escape are following <br>
 * &lt; ====&gt; &amp;lt;<br>
 * &gt; ====&gt; &amp;gt;<br>
 * &amp; ====&gt; &amp;amp;<br>
 * " ====&gt; &amp;quot;<br>
 * ' ====&gt; &amp;#39;<br>
 * </p>
 * @param input string to escape
 * @return escaped string. returns empty string if <code>value</code> is <code>null</code> or empty string.
 * @see HtmlUtils#htmlEscape(String)
 */
public static String htmlEscape(Object input) {
    if (input == null) {
        return "";
    }
    String str;
    if (input.getClass().isArray()) {
        str = convertArraysToString(input);
    } else {
        str = input.toString();
    }

    return HtmlUtils.htmlEscape(str);
}

From source file:org.hdiv.web.servlet.tags.form.ValueFormatterHDIV.java

/**
 * Build the display value of the supplied <code>Object</code>, HTML escaped
 * as required. This version is <strong>not</strong> {@link PropertyEditor}-aware.
 * @see #getDisplayString(Object, java.beans.PropertyEditor, boolean)
 *//*from   ww  w  .  jav a2  s . co m*/
public static String getDisplayString(Object value, boolean htmlEscape) {
    String displayValue = ObjectUtils.getDisplayString(value);
    return (htmlEscape ? HtmlUtils.htmlEscape(displayValue) : displayValue);
}

From source file:org.iwethey.filter.html.HtmlEscapeHandler.java

public String internalProcess(String text) {
    return HtmlUtils.htmlEscape(text);
}

From source file:info.jtrac.util.ItemUtils.java

/** 
 * does HTML escaping, converts tabs to spaces and converts leading 
 * spaces (for each multi-line) to as many '&nbsp;' sequences as required
 *//* w w  w  .  j  ava 2  s .c  om*/
public static String fixWhiteSpace(String text) {
    if (text == null) {
        return "";
    }
    String temp = HtmlUtils.htmlEscape(text);
    BufferedReader reader = new BufferedReader(new StringReader(temp));
    StringBuilder sb = new StringBuilder();
    String s;
    boolean first = true;
    try {
        while ((s = reader.readLine()) != null) {
            if (first) {
                first = false;
            } else {
                sb.append("<br/>");
            }
            if (s.startsWith(" ")) {
                int i;
                for (i = 0; i < s.length(); i++) {
                    if (s.charAt(i) == ' ') {
                        sb.append("&nbsp;");
                    } else {
                        break;
                    }
                }
                s = s.substring(i);
            }
            sb.append(s);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return sb.toString().replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
}

From source file:org.iwethey.filter.html.PassthroughEscapeHandler.java

public void process(FilterContext ctx, String text) {
    ctx.addResults(HtmlUtils.htmlEscape(text));
}

From source file:com.fengduo.bee.commons.util.StringEscapeEditor.java

@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (text == null) {
        setValue(null);//from   w ww .ja  v a  2s.  c  o m
    } else {
        String value = text;
        if (escapeHTML) {
            value = HtmlUtils.htmlEscape(value);
        }
        if (escapeJavaScript) {
            value = JavaScriptUtils.javaScriptEscape(value);
        }
        setValue(value);
    }
}

From source file:permafrost.tundra.html.HTMLHelper.java

/**
 * HTML encodes the given string./*from w w w  . j a v  a2  s .  c  o m*/
 *
 * @param input The string to be encoded.
 * @return The encoded string.
 */
public static String encode(String input) {
    if (input == null)
        return null;
    return HtmlUtils.htmlEscape(input);
}