Example usage for org.apache.commons.lang3 StringEscapeUtils escapeXml

List of usage examples for org.apache.commons.lang3 StringEscapeUtils escapeXml

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringEscapeUtils escapeXml.

Prototype

@Deprecated
public static final String escapeXml(final String input) 

Source Link

Document

Escapes the characters in a String using XML entities.

For example: "bread" & "butter" => "bread" & "butter" .

Usage

From source file:com.lyncode.jtwig.functions.internal.string.Escape.java

@Override
public Object execute(Object... arguments) throws FunctionException {
    if (arguments.length < 1 || arguments.length > 2)
        throw new FunctionException("Invalid number of arguments");

    String strategy = "html";
    if (arguments.length == 2)
        strategy = arguments[1].toString().toLowerCase();

    switch (EscapeStrategy.strategyByName(strategy.toLowerCase())) {
    case HTML:
        return StringEscapeUtils.escapeHtml4(arguments[0].toString());
    case JAVASCRIPT:
        return StringEscapeUtils.escapeEcmaScript(arguments[0].toString());
    case XML://from ww  w. ja  v a  2 s .  c o  m
        return StringEscapeUtils.escapeXml(arguments[0].toString());
    default:
        throw new FunctionException("Unknown escaping strategy");
    }

}

From source file:apm.common.utils.Encodes.java

/**
 * Xml ?.
 */
public static String escapeXml(String xml) {
    return StringEscapeUtils.escapeXml(xml);
}

From source file:cn.springmvc.jpa.common.utils.salt.Encodes.java

/**
 * Xml ?./*w w w. j av a  2  s  .co m*/
 */
@SuppressWarnings("deprecation")
public static String escapeXml(String xml) {
    return StringEscapeUtils.escapeXml(xml);
}

From source file:com.silverpeas.util.EncodeHelper.java

public static String escapeXml(String javastring) {
      if (isDefined(javastring)) {
          return StringEscapeUtils.escapeXml(javastring);
      } else {//from w w w  . j  a v a  2s . c  om
          return "";
      }
  }

From source file:com.jaspersoft.buildomatic.JSPropertyEvaluator.java

public Object evaluate(String property, PropertyHelper propertyHelper) {
    Object o = null;//  w w  w. j av a2s  .c  om
    if (propertyHelper.getProject() != null) {
        if (property.startsWith(ESCAPE_XML_PREFIX)) {
            String oStr = propertyHelper.getProject()
                    .getProperty(property.substring(ESCAPE_XML_PREFIX.length()));
            if (oStr != null)
                o = StringEscapeUtils.escapeXml(oStr);
        } else if (property.startsWith(DECRYPT_PREFIX)) {
            String oStr = propertyHelper.getProject().getProperty(property.substring(DECRYPT_PREFIX.length()));
            if (EncryptionEngine.isEncrypted(oStr)) {
                KeystoreManager ksm = KeystoreManager.getInstance();
                o = EncryptionEngine.decrypt(ksm.getBuildKey(), oStr);
            } else
                o = oStr; //not encrypted: remove decrypt: namespace
        }
    }

    return o == null ? null : o.toString();
}

From source file:com.eryansky.common.utils.encode.EncodeUtils.java

/**
 * Xml ?.
 */
public static String xmlEscape(String xml) {
    return StringEscapeUtils.escapeXml(xml);
}

From source file:$.Encodes.java

/**
     * Xml ?.
     */
    public static String escapeXml(String xml) {
        return StringEscapeUtils.escapeXml(xml);
    }

From source file:net.mindengine.oculus.frontend.domain.document.testcase.Testcase.java

public String generateXml() {
    StringBuffer buffer = new StringBuffer();
    buffer.append("<test-case>");
    buffer.append("<steps>");
    for (TestcaseStep step : steps) {
        buffer.append("<step>");
        buffer.append("<action>");
        buffer.append(StringEscapeUtils.escapeXml(step.getAction()));
        buffer.append("</action>");
        buffer.append("<expected>");
        buffer.append(StringEscapeUtils.escapeXml(step.getExpected()));
        buffer.append("</expected>");
        buffer.append("<comment>");
        buffer.append(StringEscapeUtils.escapeXml(step.getExpected()));
        buffer.append("</comment>");
        buffer.append("</step>");
    }/*w  ww .  j ava2s.c  o  m*/
    buffer.append("</steps>");
    buffer.append("</test-case>");
    return buffer.toString();
}

From source file:de.micromata.genome.gwiki.web.tags.GWikiTagRenderUtils.java

public static void renderAttribute(Object tag, Pair<Field, ? extends Annotation> p, StringBuilder sb) {
    Object value = PrivateBeanUtils.readField(tag, p.getFirst());
    if (value == null) {
        return;//from  w w w .j a  v  a 2 s. co  m
    }

    if (sb.length() > 0) {
        sb.append(" ");
    }
    ElementProperty an = (ElementProperty) p.getSecond();
    String svalue = value.toString();
    if (an.ignoreValue().length() > 0 && an.ignoreValue().equals(svalue) == true) {
        return;
    }
    String name = an.name();
    if (StringUtils.isEmpty(name) == true) {
        name = p.getFirst().getName();
    }
    sb.append(name).append("=").append("\"").append(StringEscapeUtils.escapeXml(ObjectUtils.toString(value)))
            .append("\"");
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.parser.WeditWikiUtils.java

public static String wikiToWedit(String text) {
    String ret = StringUtils.defaultString(text);
    ret = StringEscapeUtils.escapeXml(ret);

    //    ret = StringUtils.replace(ret, "\n", "<br/>\n");
    //    ret = "<p>" + ret + "</p>";
    return ret;/*from w  w w . j a va 2s  .  c  om*/
}