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

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

Introduction

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

Prototype

public static String replaceChars(String str, String searchChars, String replaceChars) 

Source Link

Document

Replaces multiple characters in a String in one go.

Usage

From source file:ubic.gemma.datastructure.matrix.ExpressionDataWriterUtils.java

/**
 * @param colName/* ww w  . j  ava2s  . co m*/
 * @return
 */
private static String constructRCompatibleBioAssayName(String colName) {
    String colNameMod = colName;
    colNameMod = StringUtils.replaceChars(colNameMod, ':', '.');
    colNameMod = StringUtils.replaceChars(colNameMod, '|', '.');
    colNameMod = StringUtils.replaceChars(colNameMod, '-', '.');
    return colNameMod;
}

From source file:uk.ac.ebi.bioinvindex.utils.datasourceload.DataLocationManager.java

/**
 * Converts an accession to something suitable for being used as file name. Which means replacing some bad characters,
 * such as ":" and other stuff.//w w  w  .ja  v  a2  s.  c o m
 * <p/>
 * <b>Please note</b>: this <b>is not</b> the inverse of {@link #filePath2Id(String)}.
 *
 * @param accession
 * @return
 */
public static String accession2FileName(String accession) {
    if (accession == null || accession.length() == 0)
        return accession;

    accession = accession.trim();
    if (accession.length() == 0)
        return accession;

    // Deal with the protocol in the URL
    int i = accession.indexOf(':');
    if (i != -1) {
        accession = StringUtils.substring(accession, i + 1);
        if (accession.startsWith("//"))
            accession = StringUtils.substring(accession, 2);
    }

    String replacedChars = ":/.? ()[]{}";
    accession = StringUtils.replaceChars(accession, replacedChars,
            StringUtils.repeat("_", replacedChars.length()));

    return accession;
}