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:eionet.cr.web.action.admin.harvestscripts.HarvestScriptParser.java

/**
 *
 * @param script/*from ww w  .  j a v  a  2 s  . c  om*/
 * @param harvestedSource
 * @param associatedType
 * @return
 */
public static String parseForExecution(String script, String harvestedSource, String associatedType) {

    if (StringUtils.isBlank(script)) {
        return script;
    }

    if (!StringUtils.isBlank(harvestedSource)) {
        script = StringUtils.replace(script, "?" + HARVESTED_SOURCE_VARIABLE, "<" + harvestedSource + ">");
    }

    if (!StringUtils.isBlank(associatedType)) {
        script = StringUtils.replace(script, "?" + ASSOCIATED_TYPE_VARIABLE, "<" + associatedType + ">");
    }

    return script;
}

From source file:net.sf.spindle.core.util.eclipse.JarEntryFileUtil.java

public static String getPackageName(JarEntryFile entry) {
    String content = entry.toString();
    int start = content.indexOf("::");
    content = content.substring(start + 2, content.length() - 1);
    int nameLength = entry.getName().length();
    if (content.length() == nameLength)
        return "";
    int stop = content.lastIndexOf('/');
    return StringUtils.replace(content.substring(0, stop), "/", ".");
}

From source file:com.sfs.whichdoctor.beans.IsbPayloadBeanTest.java

/**
 * Test of getFormattedXmlPayload method, of class IsbMessageBean.
 *//*from   www .jav  a  2  s . co  m*/
@Test
public void testGetFormattedXmlPayload() {
    System.out.println("getFormattedXmlPayload");

    String expResult = DataFilter.getHtml(IsbMessageBeanTest.getXmlPayload());
    expResult = StringUtils.replace(expResult, "  ", "&nbsp;&nbsp;&nbsp;");
    expResult = StringUtils.replace(expResult, "\n", "<br/>");

    IsbPayloadBean instance = new IsbPayloadBean();
    instance.setXmlPayload(IsbMessageBeanTest.getXmlPayload());

    final String result = instance.getFormattedXmlPayload();

    assertEquals(expResult, result);
}

From source file:eionet.cr.dao.helpers.QueryHelper.java

private static String formatSparqlQuery(String query) {
    query = StringUtils.replace(query, PREFIX.toLowerCase(), PREFIX);
    query = StringUtils.replace(query, SELECT.toLowerCase(), SELECT);
    query = StringUtils.replace(query, WHERE.toLowerCase(), WHERE);
    query = StringUtils.replace(query, FROM.toLowerCase(), FROM);

    query = StringUtils.replace(query, PREFIX, "\n" + PREFIX);
    query = StringUtils.replace(query, SELECT, "\n" + SELECT);
    query = StringUtils.replace(query, WHERE, "\n" + WHERE);
    query = StringUtils.replace(query, FROM, "\n" + FROM);

    query = StringUtils.replace(query, "{", "{\n ");
    query = StringUtils.replace(query, "}", "\n}");
    query = StringUtils.replace(query, " .", ".\n");

    String[] lines = query.split("\n");
    StringBuilder result = new StringBuilder();
    int spaces = 0;
    for (String line : lines) {
        line = line.trim();/*from w w  w. j  a v a 2s .c o m*/
        if (StringUtils.isNotEmpty(line)) {
            result.append(StringUtils.leftPad(line, spaces + line.length()));
            result.append("\n");
            spaces = countSpaces(spaces, line);
        }
    }
    return result.toString();
}

From source file:me.eccentric_nz.TARDIS.commands.admin.TARDISDefaultWorldNameCommand.java

public boolean setName(CommandSender sender, String[] args) {
    // get world name
    int count = args.length;
    StringBuilder buf = new StringBuilder();
    for (int i = 1; i < count; i++) {
        buf.append(args[i]).append(" ");
    }/* w ww .  jav a  2  s  . co m*/
    String tmp = buf.toString();
    String t = tmp.substring(0, tmp.length() - 1);
    // need to make there are no periods(.) in the text
    String nodots = StringUtils.replace(t, ".", "_");
    plugin.getConfig().set("creation.default_world_name", nodots);
    plugin.saveConfig();
    TARDISMessage.send(sender, "CONFIG_UPDATED");
    return true;
}

From source file:gool.executor.ExecutorHelper.java

public static File getClassDefFile(ClassDef classDef) {
    return new File(classDef.getPlatform().getCodePrinter().getOutputDir().getAbsolutePath(),
            StringUtils.replace(classDef.getPackageName(), ".", File.separator));
}

From source file:gov.nih.nci.caIMAGE.util.SafeHTMLUtil.java

public static String clean(String s) {
    String clean = Translate.decode(s).replace("<", "").replace(">", "");
    clean = StringUtils.replace(clean, "script", "");
    clean = StringUtils.replace(clean, "%27", "");
    clean = StringUtils.replace(clean, "%", "");
    clean = StringUtils.replace(clean, "#", "");
    clean = StringUtils.replace(clean, ";", "");
    clean = StringUtils.replace(clean, "'", "");
    clean = StringUtils.replace(clean, "\"", "");
    clean = StringUtils.replace(clean, "$", "");
    clean = StringUtils.replace(clean, "&", "");
    clean = StringUtils.replace(clean, "(", "");
    clean = StringUtils.replace(clean, ")", "");
    clean = StringUtils.replace(clean, "/", "");
    clean = StringUtils.replace(clean, "\\", "");
    clean = StringUtils.replace(clean, "&", "");
    clean = StringUtils.replace(clean, "=", "");
    clean = StringUtils.replace(clean, "quot", "");
    clean = StringUtils.replace(clean, "javascript", "");
    clean = StringUtils.replace(clean, "alert", "cleaned");
    clean = StringUtils.replace(clean, "CR", "");
    clean = StringUtils.replace(clean, "LF", "");
    clean = StringUtils.replace(clean, "<", "");
    clean = StringUtils.replace(clean, ">", "");
    if (clean.length() == 0) {
        clean = "empty";
    }/*w ww .  ja v a 2 s .c om*/
    return clean;
}

From source file:me.eccentric_nz.TARDIS.commands.admin.TARDISSetWorldInclusionCommand.java

public boolean setWorldStatus(CommandSender sender, String[] args) {
    String first = args[0];/*from   w  ww.jav  a2s  . c  om*/
    // get world name
    int count = args.length;
    StringBuilder buf = new StringBuilder();
    for (int i = 1; i < count; i++) {
        buf.append(args[i]).append(" ");
    }
    String tmp = buf.toString();
    String t = tmp.substring(0, tmp.length() - 1);
    // need to make there are no periods(.) in the text
    String nodots = StringUtils.replace(t, ".", "_");
    // check the world actually exists!
    if (plugin.getServer().getWorld(nodots) == null) {
        TARDISMessage.send(sender, "WORLD_NOT_FOUND");
        return false;
    }
    if (first.equals("include")) {
        plugin.getConfig().set("worlds." + nodots, true);
    } else {
        plugin.getConfig().set("worlds." + nodots, false);
    }
    plugin.saveConfig();
    TARDISMessage.send(sender, "CONFIG_UPDATED");
    return true;
}

From source file:com.github.dbourdette.glass.tools.FormatTool.java

public String dataMap(Object object) {
    if (object == null) {
        return null;
    }/* www.j a  v a  2  s .c  om*/

    String html = html(object);

    html = StringUtils.replace(html, "\n", "<br/>");

    return html;
}

From source file:com.senacor.wbs.web.core.EnumConverter.java

public String convertToString(Object value, Locale locale) {
    Enum enumValue = (Enum) value;
    String enumName = enumValue.name();
    String words = StringUtils.replace(enumName, "_", " ");
    return WordUtils.capitalizeFully(words);
}