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.sfs.jbtimporter.JBTIssue.java

/**
 * Gets the full file name.//from w  ww . ja  v a2s. c  o  m
 *
 * @return the full file name
 */
public final String getFullFileName() {

    return StringUtils.replace(this.exportBase + this.getBase(), "\\", "/") + "/" + this.getFileName();
}

From source file:co.marcin.novaguilds.impl.util.guiinventory.guild.player.GUIInventoryGuildPlayerSettings.java

@Override
public void generateContent() {
    inventory.clear();//  ww  w  .  j  a  v a2  s  .  c o  m

    Map<VarKey, String> vars = new HashMap<>();
    vars.put(VarKey.RANKNAME, nPlayer.getGuildRank() == null ? "Invalid_rank"
            : StringUtils.replace(nPlayer.getGuildRank().getName(), " ", "_"));

    kickItem = Message.INVENTORY_GUI_PLAYERSETTINGS_ITEM_KICK.getItemStack();
    rankItem = Message.INVENTORY_GUI_PLAYERSETTINGS_ITEM_RANK.vars(vars).getItemStack();

    if (!nPlayer.equals(getViewer()) || Config.DEBUG.getBoolean()) {
        add(kickItem);
    }

    if (!nPlayer.equals(getViewer()) || Config.DEBUG.getBoolean()) {
        add(rankItem);
    }
}

From source file:mitm.common.fetchmail.FetchmailConfigBuilder.java

private static String escape(String input) {
    if (input == null) {
        return null;
    }/*from w w w .  j  av  a 2 s. co m*/

    input = MiscStringUtils.removeControlChars(input);

    return "\"" + StringUtils.replace(input, "\"", "\\x22") + "\"";
}

From source file:com.qualogy.qafe.core.script.Script.java

public void addAll(ApplicationContext context, ApplicationStoreIdentifier storeId, DataIdentifier dataId,
        List placeHolders, String localStoreId) {

    for (Iterator iter = placeHolders.iterator(); iter.hasNext();) {
        PlaceHolder placeHolder = (PlaceHolder) iter.next();
        if (placeHolder != null) {
            Object placeHolderValue = ParameterValueHandler.get(context, storeId, dataId, placeHolder,
                    localStoreId);//  w ww.j  a va 2s. co m

            if (placeHolderValue instanceof String && NumberUtils.isNumber((String) placeHolderValue)) {
                placeHolderValue = NumberUtils.createNumber((String) placeHolderValue);
            }
            if (placeHolderValue instanceof BigDecimal) {
                placeHolderValue = new Double(((BigDecimal) placeHolderValue).doubleValue());
            }

            String scriptKey = placeHolder.getName();
            scriptKey = IDENTIFIER_PREFIX + parameters.keySet().size();

            expression = StringUtils.replace(expression, placeHolder.getPlaceHolderKey(), scriptKey);
            parameters.put(scriptKey, placeHolderValue);
        }
    }
}

From source file:co.marcin.novaguilds.impl.util.guiinventory.guild.rank.GUIInventoryGuildRankList.java

@Override
public void generateContent() {
    inventory.clear();/*from  w  ww  .j a v  a 2  s.com*/
    slotRanksMap.clear();

    int slot = 0;
    List<NovaRank> ranks = new ArrayList<>();
    ranks.addAll(NovaGuilds.getInstance().getRankManager().getGenericRanks());
    ranks.addAll(guild.getRanks());

    for (NovaRank rank : ranks) {
        NovaRank cloneOfGeneric = guild.getCloneOfGenericRank(rank);

        if (cloneOfGeneric != null) {
            continue;
        }

        ItemStack itemStack = Message.INVENTORY_GUI_RANKS_ROWITEM
                .setVar(VarKey.RANKNAME, StringUtils.replace(rank.getName(), " ", "_")).getItemStack();

        inventory.setItem(slot, itemStack);
        slotRanksMap.put(slot, rank);
        slot++;
    }

    addRankItem = Message.INVENTORY_GUI_RANKS_ADDITEM.getItemStack();
    add(addRankItem);
}

From source file:com.fengduo.bee.service.impl.file.FileServiceImpl.java

public File getFile(String path) {
    if (StringUtils.isEmpty(path)) {
        return null;
    }/*from   w  w  w.  jav  a2 s .c o  m*/
    if (StringUtils.contains(path, STATIC_TMP_IMG)) {
        path = StringUtils.replace(path, STATIC_TMP_IMG, StringUtils.EMPTY);
    }
    File file = new File(UPLOAD_TMP_PATH + path);
    if (file == null || !file.isFile()) {
        return null;
    }
    if (file.getParentFile() == null || !file.getParentFile().exists()) {
        return null;
    }
    return file;
}

From source file:com.mmounirou.spotirss.spotify.tracks.XTracks.java

private String cleanTrackName(String trackName) {
    String[] spotifyExtensions = new String[] { " - Explicit Version", " - Live", " - Radio Edit" };
    String strSong = trackName;//from w w  w  .j ava  2  s . c o  m

    for (String extensions : spotifyExtensions) {
        if (StringUtils.contains(strSong, extensions)) {
            strSong = "X " + StringUtils.remove(trackName, extensions);
        }
    }

    String[] braces = { "[]", "()" };

    for (String brace : braces) {

        String extendedinfo = null;
        do {
            extendedinfo = StringUtils.defaultString(
                    StringUtils.substringBetween(strSong, brace.charAt(0) + "", brace.charAt(1) + ""));
            if (StringUtils.isNotBlank(extendedinfo)) {
                if (StringUtils.startsWith(extendedinfo, "feat.")) {
                    String strArtist = StringUtils.removeStart("feat.", extendedinfo);
                    strSong = StringUtils.replace(strSong,
                            String.format("%c%s%c", brace.charAt(0), extendedinfo, brace.charAt(1)), "");
                    m_artistsInTrackName.addAll(cleanArtist(strArtist));
                }

                else {
                    strSong = StringUtils.replace(strSong,
                            String.format("%c%s%c", brace.charAt(0), extendedinfo, brace.charAt(1)), "");
                    strSong = "X " + strSong;
                }
            }

        } while (StringUtils.isNotBlank(extendedinfo));

    }

    String[] strSongSplitted = strSong.split("featuring");
    if (strSongSplitted.length > 1) {
        strSong = strSongSplitted[0];
        m_artistsInTrackName.add(strSongSplitted[1]);
    }

    String[] strSongWithFeaturing = strSong.split("-");
    if (strSongWithFeaturing.length > 1 && strSongWithFeaturing[1].contains("feat.")) {
        strSong = strSongWithFeaturing[0];
        m_artistsInTrackName.addAll(cleanArtist(StringUtils.remove(strSongWithFeaturing[1], "feat.")));
    } else {
        strSongWithFeaturing = strSong.split("feat.");
        if (strSongWithFeaturing.length > 1) {
            strSong = strSongWithFeaturing[0];
            m_artistsInTrackName.addAll(cleanArtist(strSongWithFeaturing[1]));
        }
    }

    return strSong.trim().toLowerCase();
}

From source file:com.controlj.addon.weather.wbug.service.WeatherBugDataUtils.java

/**
 * Fix the degrees representation, replacing the HTML entity <code>&amp;deg;</code> with the unicode character.
 * /*from w ww .jav a 2  s . com*/
 * @param s
 *            the string to be fixed.
 * @return the input string with all the degree representation (if any) fixed.
 */
public static String fixDegrees(String s) {
    return StringUtils.replace(s, "&deg;", "\u00B0");
}

From source file:com.google.gdt.eclipse.designer.wizards.model.common.AbstractCreateOperation.java

/**
 * Creates file with name 'targetName' in 'targetFolder' using given template name and variables
 * map./*from  w  ww  .  j ava  2  s.  c  om*/
 */
protected static IFile createFileFromTemplate(IFolder targetFolder, String targetName, String templateName,
        Map<String, String> variables) throws Exception {
    IProject project = targetFolder.getProject();
    // prepare template
    String template = getTemplateContent(project, templateName);
    template = toSystemEOL(template);
    // replace %variable% with variable values
    for (Map.Entry<String, String> entry : variables.entrySet()) {
        String name = entry.getKey();
        String value = entry.getValue();
        template = StringUtils.replace(template, "%" + name + "%", value);
    }
    // create file
    return createFile(targetFolder, targetName, template.getBytes());
}

From source file:edu.mayo.cts2.framework.plugin.service.lexevs.naming.VersionNameConverter.java

public String escapeVersion(String version) {
    return StringUtils.replace(version, SEPARATOR, SEPARATOR_ENCODE);
}