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.flexive.tests.embedded.jsf.bean.MessageBeanTest.java

@Test
public void getMessageArgsString() {
    String message = (String) messageBean.get(KEY_1 + ",random,string");
    String expected = StringUtils.replace(MSG_1, "{0}", "random");
    Assert.assertTrue(expected.equals(message), "Expected: " + expected + ", got: " + message);
}

From source file:com.bluexml.xforms.messages.MsgPool.java

private static String replaceArgs(String msg, String[] args) {
    String result = msg;//from   w ww  .  jav a 2  s  .  co  m
    int idx = 0;
    for (String arg : args) {
        String idxStr = "{" + idx + "}";
        result = StringUtils.replace(result, idxStr, arg);
        idx++;
    }
    return result;
}

From source file:com.google.gdt.eclipse.designer.model.widgets.cell.AbstractCellTableInfo.java

public AbstractCellTableInfo(AstEditor editor, ComponentDescription description,
        CreationSupport creationSupport) throws Exception {
    super(editor, description, creationSupport);
    addClipboardSupport();//from w ww  . j a v  a2  s  . co  m
    // creation support templates
    addBroadcastListener(new JavaEventListener() {
        @Override
        public void associationTemplate(JavaInfo component, String[] source) throws Exception {
            // Column creation
            if (component instanceof ColumnInfo && component.getParent() == AbstractCellTableInfo.this) {
                String rowTypeName;
                {
                    ITypeBinding rowTypeBinding = getRowTypeBinding();
                    rowTypeName = AstNodeUtils.getFullyQualifiedName(rowTypeBinding, false);
                }
                // apply "%rowType%" into creation source
                source[0] = StringUtils.replace(source[0], "%rowType%", rowTypeName);
            }
        }
    });
}

From source file:net.servicefixture.ext.db.DbFixture.java

public String getProperty(String defaultPropName) {
    String propName = defaultPropName;
    if (dbName != null) {
        propName = StringUtils.replace(defaultPropName, DEFAULT_DB_NAME, dbName);
    }/*from www  .  j  a va 2s .c  om*/
    String propValue = Configuration.getInstance().getProperty(propName);
    if (propValue == null) {
        throw new ServiceFixtureException(
                "Please configure database:" + (dbName == null ? DEFAULT_DB_NAME : dbName) + " in "
                        + Configuration.SERVICEFIXTURE_PROPERTIES + " file.");
    }
    return propValue;
}

From source file:com.betfair.platform.shunit.TestShUnitRunnerParser.java

private void invokeParser(String fileName) {
    ShUnitRunner.OutputParser parser = new ShUnitRunner.OutputParser(getClass());
    String className = getClass().getName();
    String packageName = "";
    if (className.contains(".")) {
        packageName = className.substring(0, className.lastIndexOf("."));
    }/* w w  w.j a v  a2s  .c o m*/
    String resourcePath = "/" + StringUtils.replace(packageName, ".", "/") + "/" + fileName;
    InputStream is = getClass().getResourceAsStream(resourcePath);
    parser.parseOutput(is, notifier);
}

From source file:com.exxonmobile.ace.hybris.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() && StringUtils.contains(referer, "/" + old)) {
        return REDIRECT_PREFIX + StringUtils.replace(referer, "/" + old, "/" + current);
    }/*from w w  w  .  jav a 2s .  c  o m*/
    return REDIRECT_PREFIX + '/';
}

From source file:com.prowidesoftware.swift.model.field.Field257Test.java

@Test
public void testGetValue1() {
    Field257 f = new Field257();
    String v = EXAMPLE1_FIELD_257;
    f = new Field257(v);
    assertEquals(StringUtils.replace(v, "\n", FINWriterVisitor.SWIFT_EOL), f.getValue());
}

From source file:info.magnolia.cms.gui.dialog.DialogMultiSelect.java

/**
 * Called by the template. It renders the dynamic inner row using trimpaths templating mechanism.
 *//* www  . j  av a 2 s .c o  m*/
public String getInnerHtml() {
    String name = "/" + StringUtils.replace(DialogMultiSelect.class.getName(), ".", "/") + "Inner.html";
    Map map = new HashMap();
    map.put("this", this);
    return FreeMarkerUtil.process(name, map);
}

From source file:com.spring.utils.EncodeUtils.java

/**
 * sql .// w w w  .j  ava2  s  .c  o  m
 * <P>
 * @param sql 
 *  @return String 
 */
public static String escapeSql(String sql) {
    if (sql == null) {
        return null;
    }
    return StringUtils.replace(sql, "'", "''");
}

From source file:net.java.dev.openim.tools.XStreamStore.java

private void saveMap(Map map) {
    String xstreamData = xstream.toXML(map);
    if (substituteFrom != null && substituteTo != null) {
        xstreamData = StringUtils.replace(xstreamData, substituteFrom, substituteTo);
    }/* ww  w.j a v  a  2 s  .c  o m*/
    xstreamData = xmlProlog + "\n" + xstreamData;
    //getLogger().info("saving roster " + xstreamData);
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(file);
        fos.write(xstreamData.getBytes());
    } catch (IOException e) {
        getLogger().error(e.getMessage(), e);
    } finally {
        if (fos != null) {
            try {
                fos.close();
            } catch (IOException e) {
                getLogger().error(e.getMessage());
            }
        }
    }

}