Example usage for org.apache.commons.lang3 StringUtils stripAccents

List of usage examples for org.apache.commons.lang3 StringUtils stripAccents

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils stripAccents.

Prototype


public static String stripAccents(final String input) 

Source Link

Document

Removes diacritics (~= accents) from a string.

Usage

From source file:org.yamj.core.tools.MetadataTools.java

/**
 * Set the sort title./*ww  w .j  a v  a  2 s .c o m*/
 *
 * @param metadata the scanned metadata
 * @param prefixes a list with prefixed to strip
 */
public static void setSortTitle(AbstractMetadata metadata, List<String> prefixes) {
    String sortTitle;
    if (StringUtils.isBlank(metadata.getTitleSort())) {
        sortTitle = StringUtils.stripAccents(metadata.getTitle());

        // strip prefix
        for (String prefix : prefixes) {
            String check = prefix.trim() + " ";
            if (StringUtils.startsWithIgnoreCase(sortTitle, check)) {
                sortTitle = sortTitle.substring(check.length());
                break;
            }
        }
    } else {
        sortTitle = StringUtils.stripAccents(metadata.getTitleSort());
    }

    // first char must be a letter or digit
    int idx = 0;
    while (idx < sortTitle.length() && !Character.isLetterOrDigit(sortTitle.charAt(idx))) {
        idx++;
    }

    // replace all non-standard characters in the title sort
    sortTitle = MetadataTools.stringMapReplacement(sortTitle.substring(idx));
    metadata.setTitleSort(sortTitle);
}

From source file:pl.com.softproject.diabetyk.web.util.TextUtil.java

public static String stripAccentsAndNonASCII(String string) {
    String convertedString = StringUtils.stripAccents(string);

    return removeNonAscii(stripNonDiacritics(convertedString)).toLowerCase();
}

From source file:scan.Scan.java

/**
 * cleanString method. This method is passed a string of text, the 'dirty string' and returns a 
 * 'cleaned string'. The cleaning process involves removing white spaces, accents and making all
 * characters lowercase. This process could be extend to remove punctuation as well.  
 * /*from w w  w .j a  va  2 s  .  c  om*/
 * The purpose of this process is simplify matching between two strings.
 * 
 * @param dirtySrString a string that is unprocessed and is to be cleaned
 * @return returns a string that has been cleaned
 */
protected String cleanString(String dirtySrString) {
    String cleanString;
    cleanString = StringUtils.lowerCase(dirtySrString);
    cleanString = StringUtils.deleteWhitespace(cleanString);
    cleanString = StringUtils.stripAccents(cleanString);
    return cleanString;
}

From source file:vn.com.ecopharma.emp.service.impl.EmpLocalServiceImpl.java

public String generateOriginalUsername(String fullname) {
    if (StringUtils.trimToNull(fullname) == null)
        return StringUtils.EMPTY;
    fullname = StringUtils.stripAccents(fullname); // NOSONAR
    LOGGER.info("FULL NAME AFTER STRIPPING ACCENTS: " + fullname);

    StringBuilder resultBuilder = new StringBuilder();
    char firstChar = getLastName(fullname).toCharArray()[0];

    String[] middleNameArr = getMiddleName(fullname).split(" ");
    char[] middleNameChars;
    if (middleNameArr.length > 0 && middleNameArr[0] != StringUtils.EMPTY) {
        middleNameChars = new char[middleNameArr.length];
        for (int i = 0; i < middleNameChars.length; i++) {
            middleNameChars[i] = middleNameArr[i].charAt(0);
        }// w w  w  . j a  va  2 s .com
    } else {
        middleNameChars = null;
    }

    resultBuilder.append(firstChar);
    if (middleNameChars != null) {
        resultBuilder.append(middleNameChars);
    }
    resultBuilder.append(getFirstName(fullname));
    String resultString = resultBuilder.toString().toLowerCase();
    resultString = resultString.replaceAll("", "d");
    LOGGER.info("USERNAME AFTER STRIPPING ACCENTS: " + fullname);
    return resultString;
}