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.pedra.storefront.controllers.misc.StoreSessionController.java

protected String getReturnRedirectUrlForUrlEncoding(final HttpServletRequest request, final String old,
        final String current) {
    final String referer = request.getHeader("Referer");
    if (referer != null && !referer.isEmpty()) {
        return REDIRECT_PREFIX + StringUtils.replace(referer, "/" + old, "/" + current);
    }//from  ww  w. ja  v  a  2 s  .  c  o  m
    final String encodingAttributes = (String) request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
    return REDIRECT_PREFIX + StringUtils.defaultString(encodingAttributes) + '/';
}

From source file:com.flexive.faces.URIRoute.java

/**
 * Replace the given parameter in the URI format string.
 *
 * @param format        the format string
 * @param parameterName the parameter name
 * @param value         the value to be set for the parameter
 * @return the replaced format string//w  w w . j  ava  2 s  .c  o m
 */
protected String replaceUriParameter(String format, String parameterName, String value) {
    // TODO create a more efficient version with string buffers
    return StringUtils.replace(format, "${" + parameterName + "}", value);
}

From source file:com.jgeppert.struts2.jquery.components.Head.java

public void evaluateParams() {
    super.evaluateParams();

    if (this.jqueryui != null)
        addParameter("jqueryui", findValue(this.jqueryui, Boolean.class));
    if (this.compressed != null)
        addParameter("compressed", findValue(this.compressed, Boolean.class));
    if (this.jquerytheme != null)
        addParameter("jquerytheme", findString(this.jquerytheme));
    if (this.customBasepath != null)
        addParameter("customBasepath", findString(this.customBasepath));
    if (this.loadFromGoogle != null)
        addParameter("loadFromGoogle", findValue(this.loadFromGoogle, Boolean.class));
    if (this.ajaxcache != null)
        addParameter("ajaxcache", findValue(this.ajaxcache, Boolean.class));
    if (this.ajaxhistory != null)
        addParameter("ajaxhistory", findValue(this.ajaxhistory, Boolean.class));
    if (this.defaultIndicator != null)
        addParameter("defaultIndicator", findString(this.defaultIndicator));
    if (this.defaultLoadingText != null)
        addParameter("defaultLoadingText", findString(this.defaultLoadingText));
    if (this.defaultErrorText != null)
        addParameter("defaultErrorText", findString(this.defaultErrorText));
    if (this.loadAtOnce != null)
        addParameter("loadAtOnce", findValue(this.loadAtOnce, Boolean.class));
    if (this.debug != null)
        addParameter("debug", findValue(this.debug, Boolean.class));
    if (this.scriptPath != null)
        addParameter("scriptPath", findString(this.scriptPath));

    String loc = null;//www . jav  a  2 s . c  o  m
    if (this.locale != null)
        loc = StringUtils.replace(findString(this.locale), "_", "-");
    else if (defaultLocale != null)
        loc = StringUtils.replace(defaultLocale, "_", "-");

    if (loc != null) {
        addParameter("gridLocale", validateLocal(gridLocals, loc));
        addParameter("timeLocale", validateLocal(timeLocals, loc));
        addParameter("jqueryLocale", validateLocal(jqueryLocals, loc));
    }
}

From source file:net.sf.click.jquery.examples.page.SourceViewer.java

private String renderHtmlKeywords(String line, String token) {

    String markupToken = "<" + token + ">";
    String renderedToken = "<" + renderHtmlToken(token) + ">";
    line = StringUtils.replace(line, markupToken, renderedToken);

    markupToken = "<" + token + "/>";
    renderedToken = "<" + renderHtmlToken(token) + "/>";
    line = StringUtils.replace(line, markupToken, renderedToken);

    markupToken = "</" + token + ">";
    renderedToken = "</" + renderHtmlToken(token) + ">";
    line = StringUtils.replace(line, markupToken, renderedToken);

    markupToken = "<" + token + " ";
    renderedToken = "<" + renderHtmlToken(token) + " ";
    line = StringUtils.replace(line, markupToken, renderedToken);

    return line;//from   ww  w  .ja v a 2s.c o  m
}

From source file:info.magnolia.importexport.DataTransporter.java

/**
 * @param xmlFile/*  w  w  w. j a  va  2  s. co m*/
 * @param repositoryName
 * @throws IOException
 */
public static void executeBootstrapImport(File xmlFile, String repositoryName) throws IOException {
    String filenameWithoutExt = StringUtils.substringBeforeLast(xmlFile.getName(), DOT);
    if (filenameWithoutExt.endsWith(XML)) {
        // if file ends in .xml.gz or .xml.zip
        // need to keep the .xml to be able to view it after decompression
        filenameWithoutExt = StringUtils.substringBeforeLast(xmlFile.getName(), DOT);
    }
    String pathName = StringUtils.substringAfter(StringUtils.substringBeforeLast(filenameWithoutExt, DOT), DOT);

    pathName = decodePath(pathName, UTF8);

    String basepath = SLASH + StringUtils.replace(pathName, DOT, SLASH);

    if (xmlFile.getName().endsWith(PROPERTIES)) {
        Properties properties = new Properties();
        FileInputStream stream = new FileInputStream(xmlFile);
        properties.load(stream);
        stream.close();
        importProperties(properties, repositoryName);
    } else {
        DataTransporter.importFile(xmlFile, repositoryName, basepath, false, BOOTSTRAP_IMPORT_MODE, true, true);
    }
}