Back to project page FAST.
The source code is released under:
GNU General Public License
If you think the Android project FAST listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.ligi.fast.util; /*w w w.j a v a 2 s .c om*/ import java.util.HashMap; import java.util.Map; public class UmlautConverter { public final static Map<String, String> REPLACEMENT_MAP = new HashMap<String, String>() {{ // german put("", "ue"); put("", "oe"); put("", "ae"); put("", "ss"); // greek put("?", "?"); put("?", "?"); put("?", "?"); put("?", "?"); put("?", "?"); put("??", "?"); put("?", "w"); /* we do not need UpperCase as for searching put("?","?"); put("?", "?"); put("?", "?"); put("?", "?"); put("?", "?"); put("?", "?"); put("?", "??");groovy:000> "??".toLowerCase(); ===> ? */ // spanish - credits Rubn Gmez ruben.gomez@canselleiro.org put("", "a"); put("", "e"); put("", "i"); put("", "n"); put("", "o"); put("", "u"); }}; public static String replaceAllUmlauts(String input) { String output = input; for (Map.Entry<String, String> entry : REPLACEMENT_MAP.entrySet()) { /* * fun fact when there are 2 methods replace(..) and replaceAll(..) * and you want to replace all occurrences you would take the later * which is not totally wrong ( is doing the right thing ) * but replace(..) is also doing the right thing but way faster ;-) */ output = output.replace(entry.getKey(), entry.getValue()); } return output; } public static String replaceAllUmlautsReturnNullIfEqual(String input) { String output = replaceAllUmlauts(input); if (output.equals(input)) { return null; } return output; } }