Java Code Examples for org.apache.commons.lang3.StringUtils#stripAccents()

The following examples show how to use org.apache.commons.lang3.StringUtils#stripAccents() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From account-provisioning-for-google-apps with Apache License 2.0 6 votes vote down vote up
/**
 * Replaces special characters to e-mail valid characters.
 *
 * @param username User name to be formatted.
 * @return Formatted text
 */
public static String replaceSpecialChars(String username) {
  if (username == null) {
    return null;
  }
  username = username.toLowerCase();
  // Replaces characters with accents for the same characters without accents.
  username = StringUtils.stripAccents(username);
  // Filters e-mail valid characters
  username = username.replaceAll(REGEXP_SPECIAL_CHARS, "");
  // The maximum Google Apps username length is 60 characters
  if (username.length() > USERNAME_MAX_LENGTH) {
    username = username.substring(0, USERNAME_MAX_LENGTH);
  }
  return username;
}
 
Example 2
Source File: FTPSTransport.java    From pikatimer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void save(String filename, String contents) {
    System.out.println("FTPSTransport.save() called for " + filename);
    if (stripAccents) contents = StringUtils.stripAccents(contents);
    transferMap.put(filename,contents);
    if (! transferQueue.contains(filename)) transferQueue.add(filename);
    
    //if (transferThread == null || ftpClient == null || !ftpClient.isConnected() ) transferFile(); // kicks off the thread
}
 
Example 3
Source File: LocalTransport.java    From pikatimer with GNU General Public License v3.0 5 votes vote down vote up
@Override
    public void save(String filename, String contents) {
        System.out.println("LocalTransport.save called for " + filename);
        
        //String Accented chars if needed
        if (stripAccents) contents = StringUtils.stripAccents(contents);
        
        //Fix the newlines
        contents = contents.replaceAll("\\R", System.lineSeparator()); 
        
        
        if (goodToGo && ! basePath.isEmpty()) {
            
            try {
                Platform.runLater(() -> {transferStatus.set("Saving: " + filename);});
//                try {
//                    Thread.sleep(3000);
//                } catch (InterruptedException ex) {
//                    Logger.getLogger(LocalTransport.class.getName()).log(Level.SEVERE, null, ex);
//                }
                FileUtils.writeStringToFile(new File(FilenameUtils.concat(basePath, filename)), '\ufeff' + contents, StandardCharsets.UTF_8);
                Platform.runLater(() -> {transferStatus.set("Idle");});
            } catch (IOException ex) {
                Platform.runLater(() -> {transferStatus.set("ERROR! " + filename);});
                Logger.getLogger(LocalTransport.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
 
Example 4
Source File: SFTPTransport.java    From pikatimer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void save(String filename, String contents) {
    System.out.println("SFTPTransport.save() called for " + filename);
    if (stripAccents) contents = StringUtils.stripAccents(contents);
    transferMap.put(filename,contents);
    if (! transferQueue.contains(filename)) transferQueue.add(filename);
}
 
Example 5
Source File: NewsSourceComparator.java    From ETSMobile-Android2 with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(NewsSource newsSource1, NewsSource newsSource2) {

    String sourceName1 = StringUtils.stripAccents(newsSource1.getName());
    String sourceName2 = StringUtils.stripAccents(newsSource2.getName());

    return sourceName1.toLowerCase().compareTo(sourceName2.toLowerCase());
}
 
Example 6
Source File: Utils.java    From metadata-qa-marc with GNU General Public License v3.0 4 votes vote down vote up
public static String solarize(String abbreviation) {
  abbreviation = StringUtils.stripAccents(abbreviation);
  abbreviation = abbreviation.replaceAll("\\W", "_").toLowerCase();
  return abbreviation;
}
 
Example 7
Source File: ConvertSpecialCharacterNormalizer.java    From EDDI with Apache License 2.0 4 votes vote down vote up
@Override
public String normalize(String input) {
    return StringUtils.stripAccents(CharacterUtilities.convertSpecialCharacter(input));
}