Example usage for org.apache.commons.lang CharSetUtils delete

List of usage examples for org.apache.commons.lang CharSetUtils delete

Introduction

In this page you can find the example usage for org.apache.commons.lang CharSetUtils delete.

Prototype

public static String delete(String str, String[] set) 

Source Link

Document

Takes an argument in set-syntax, see evaluateSet, and deletes any of characters present in the specified string.

An example would be:

  • delete("hello", {"c-f", "o"}) returns "hll"

Usage

From source file:MainClass.java

public static void main(String[] args) {
    //Specified characters deleted.                
    System.out.println("Delete B and o = " + CharSetUtils.delete("BorisBecker", "Bo"));
    System.out.println(//w w w.  j  a  v  a 2 s. c  o m
            "Delete B,o,k,e and r = " + CharSetUtils.delete("BorisBecker", new String[] { "Bo", "ker" }));
}

From source file:CharSetUtilsTrial.java

public static void main(String[] args) {
    // Specified characters deleted.
    System.out.println("Delete B and o = " + CharSetUtils.delete("BorisBecker", "Bo")); // risecker
    System.out.println(//w  w w  .j  a  va 2s .c o m
            "Delete B,o,k,e and r = " + CharSetUtils.delete("BorisBecker", new String[] { "Bo", "ker" })); // isc

}

From source file:com.vmware.appfactory.file.FileHelper.java

/**
 * Remove characters that may result in invalid file names in win,
 * unix or osx systems.//from ww  w .j  a v  a  2  s .c  om
 *
 * @param fileName - file name
 * @return
 */
public static String purgeInvalidCharFromFileName(String fileName) {
    if (StringUtils.isEmpty(fileName)) {
        return fileName;
    }
    return CharSetUtils.delete(fileName, ILLEGAL_FILE_NAME_CHARS);
}

From source file:com.vmware.appfactory.file.FileHelper.java

/**
 * Remove characters that may result in invalid directory name in win,
 * unix or osx systems./*from www  .java 2 s .c o  m*/
 *
 * @param dirName - directory Name
 * @see #FileHelper.parseDirs(String, Map)
 * @return - FileName that
 */
public static String purgeInvalidCharFromDirName(String dirName) {
    if (StringUtils.isEmpty(dirName)) {
        return dirName;
    }
    return CharSetUtils.delete(dirName, ILLEGAL_FILE_NAME_CHARS + " ");
}

From source file:net.sourceforge.fenixedu.domain.reports.TeacherCreditsReportFile.java

private String getOthersDesciption(TeacherService teacherService) {
    List<String> others = new ArrayList<String>();
    for (OtherService otherService : teacherService.getOtherServices()) {
        others.add(CharSetUtils.delete(otherService.getReason(), "\r\n") + " (" + otherService.getCredits()
                + " crditos)");
    }//from  w  ww  .j  av a 2s.com
    return StringUtils.join(others, ", ");
}

From source file:com.yucheng.cmis.pub.util.NewStringUtils.java

/**
 * <p>Deletes all 'space' characters from a String as defined by
 * {@link Character#isSpace(char)}.</p>
 *
 * <p>This is the only StringUtils method that uses the
 * <code>isSpace</code> definition. You are advised to use
 * {@link #deleteWhitespace(String)} instead as whitespace is much
 * better localized.</p>// w  w w. j a va 2 s  . co  m
 *
 * <pre>
 * StringUtils.deleteSpaces(null)           = null
 * StringUtils.deleteSpaces("")             = ""
 * StringUtils.deleteSpaces("abc")          = "abc"
 * StringUtils.deleteSpaces(" \t  abc \n ") = "abc"
 * StringUtils.deleteSpaces("ab  c")        = "abc"
 * StringUtils.deleteSpaces("a\nb\tc     ") = "abc"
 * </pre>
 *
 * <p>Spaces are defined as <code>{' ', '\t', '\r', '\n', '\b'}</code>
 * in line with the deprecated <code>isSpace</code> method.</p>
 *
 * @param str  the String to delete spaces from, may be null
 * @return the String without 'spaces', <code>null</code> if null String input
 * @deprecated Use the better localized {@link #deleteWhitespace(String)}.
 *             Method will be removed in Commons Lang 3.0.
 */
public static String deleteSpaces(String str) {
    if (str == null) {
        return null;
    }
    return CharSetUtils.delete(str, " \t\r\n\b");
}

From source file:org.eclipse.gyrex.jobs.internal.manager.StorableBackedJobHistoryEntry.java

@Override
public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append(DateFormatUtils.SMTP_DATETIME_FORMAT.format(getTimeStamp())).append(" ");
    switch (getResult().getSeverity()) {
    case IStatus.OK:
        builder.append("OK");
        break;// ww w  . j a  v  a2 s .  com
    case IStatus.ERROR:
        builder.append("ERROR");
        break;
    case IStatus.WARNING:
        builder.append("WARNING");
        break;
    case IStatus.INFO:
        builder.append("INFO");
        break;
    case IStatus.CANCEL:
        builder.append("CANCEL");
        break;

    default:
        builder.append("severity=");
        builder.append(getResult().getSeverity());
        break;
    }
    if (StringUtils.isNotBlank(getResult().getMessage())) {
        builder.append(" ").append(
                StringUtils.replaceChars(CharSetUtils.delete(getResult().getMessage(), "\t\r\b"), '\n', '|'));
    }
    return builder.toString();
}

From source file:org.openvpms.web.component.im.query.AbstractArchetypeQuery.java

/**
 * Determines if a query may be performed on name.
 * A query can be performed on name if the length of the name
 * (minus wildcards) &gt;= {@link #getValueMinLength()}
 *
 * @return {@code true} if a query may be performed on name; otherwise {@code false}
 *//*from w  w w  .j  a v a 2  s  .c  o m*/
protected boolean canQueryOnName() {
    String name = getValue();
    int length = 0;
    if (name != null) {
        length = CharSetUtils.delete(name, "*").length();
    }
    return (length >= getValueMinLength());
}