Example usage for org.apache.commons.lang StringUtils replace

List of usage examples for org.apache.commons.lang StringUtils replace

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils replace.

Prototype

public static String replace(String text, String searchString, String replacement) 

Source Link

Document

Replaces all occurrences of a String within another String.

Usage

From source file:com.liferay.maven.plugins.util.StringUtil.java

public static String safePath(String path) {
    return StringUtils.replace(path, "//", "/");
}

From source file:com.enonic.cms.core.search.IndexFieldnameNormalizer.java

private static String replaceFieldTypeSeparators(final String stringValue) {
    return StringUtils.replace(stringValue, INDEX_FIELD_TYPE_SEPARATOR, INDEX_FIELDNAME_PROPERTY_SEPARATOR);
}

From source file:com.haulmont.bali.util.HtmlUtils.java

/**
 * Converts string with content to html string.
 *
 * @param text to be converted/* w  w w.  j  a  v  a 2s  . com*/
 * @return Converted string.
 */
public static String convertToHtml(String text) {
    String html = StringEscapeUtils.escapeHtml(text);
    html = StringUtils.replace(html, "\n", "<br/>");
    html = StringUtils.replace(html, " ", "&nbsp;");
    html = StringUtils.replace(html, "\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
    return html;
}

From source file:com.hangum.tadpole.commons.util.XMLUtils.java

/**
 * xml string ? ?  ? ? //from   w w w  .  j  av a2s  .co m
 * 
 * @param retVal
 * @return
 */
public static String xmlToString(String retVal) {
    for (int i = 0; i < xml.length; i++) {
        retVal = StringUtils.replace(retVal, xml[i], javaString[i]);
    }

    return retVal;
}

From source file:com.hangum.tadpole.commons.util.Utils.java

/**
 * convert line to html//from   w  w w .  ja v  a  2s  .  c o m
 * @param str
 * @return
 */
public static String convLineToHtml(String str) {
    if (str == null)
        return "";

    return StringUtils.replace(StringEscapeUtils.escapeHtml(str), PublicTadpoleDefine.LINE_SEPARATOR, "<br/>");
}

From source file:com.migo.defence.SQLFilter.java

/**
 * SQL/* w w  w  .  j a  v  a  2 s  .  c  o  m*/
 * @param str  ?
 */
public static String sqlInject(String str) {
    if (StringUtils.isBlank(str)) {
        return null;
    }
    //'|"|;|\
    str = StringUtils.replace(str, "'", "");
    str = StringUtils.replace(str, "\"", "");
    str = StringUtils.replace(str, ";", "");
    str = StringUtils.replace(str, "\\", "");

    //???
    str = str.toLowerCase();

    //?
    String[] keywords = { "master", "truncate", "insert", "select", "delete", "update", "declare", "alert",
            "create", "drop" };

    //???
    for (String keyword : keywords) {
        if (str.contains(keyword)) {
            throw new RRException("??");
        }
    }

    return str;
}

From source file:com.hangum.tadpole.commons.util.Utils.java

public static String convHtmlToLine(String str) {
    return StringUtils.replace(StringEscapeUtils.unescapeHtml(str), "<br/>",
            PublicTadpoleDefine.LINE_SEPARATOR);
}

From source file:com.vamonossoftware.core.TextUtil.java

/**
 * Replaces variables in a string with values from a properties object.
 * So, if the string is/* ww w  .  j a v  a 2  s  . c  om*/
 * "Hello ${name}."
 * And the properties contains
 * "name" -> "Mr Ed"
 * Then the result will be
 * "Hello Mr Ed."
 */
public static String replace(String input, Properties properties) {
    for (Object key : properties.keySet()) {
        input = StringUtils.replace(input, START + key + END, properties.getProperty((String) key));
    }
    return input;
}

From source file:com.bstek.dorado.console.utils.SystemUtils.java

/**
 * ??/*from ww w .  ja v  a 2 s .  co  m*/
 * 
 * @return
 */
public static Map<String, Object> getSystemProperties() {
    Map<String, Object> map = new HashMap<String, Object>();

    map.put("os_name", System.getProperty("os.name"));
    map.put("os_arch", System.getProperty("os.arch"));
    map.put("os_version", System.getProperty("os.version"));
    map.put("user_name", System.getProperty("user.name"));
    map.put("class_path", System.getProperty("java.class.path"));
    map.put("file_encoding", System.getProperty("file.encoding"));
    map.put("library_path", StringUtils.replace(System.getProperty("java.library.path"), ";", "<br>"));
    map.put("java_version", System.getProperty("java.version"));
    map.put("java_vendor", System.getProperty("java.vendor"));
    map.put("java_vm_specification_version", System.getProperty("java.vm.specification.version"));
    map.put("java_vm_specification_vendor", System.getProperty("java.vm.specification.vendor"));
    map.put("java_vm_specification_name   ", System.getProperty("java.vm.specification.name"));
    map.put("java_vm_version", System.getProperty("java.vm.version"));
    map.put("java_vm_vendor", System.getProperty("java.vm.vendor"));
    map.put("java_vm_name", System.getProperty("java.vm.name"));
    map.put("java_home", System.getProperty("java.home"));

    return map;
}

From source file:com.liferay.maven.plugins.util.GetterUtil.java

public static String getString(String value, String defaultValue) {
    if (value == null) {
        return defaultValue;
    }//  ww w  . ja  v  a 2s .  c  o  m

    value = value.trim();

    if (value.indexOf('\r') != -1) {
        value = StringUtils.replace(value, "\r\n", "\n");
    }

    return value;
}