Java tutorial
//package com.java2s; /* * Copyright 2011 Robert Theis * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.content.SharedPreferences; public class Main { public static final String KEY_CHARACTER_BLACKLIST_ARABIC = "preference_character_blacklist_arabic"; public static final String KEY_CHARACTER_BLACKLIST_BULGARIAN = "preference_character_blacklist_bulgarian"; public static final String KEY_CHARACTER_BLACKLIST_CATALAN = "preference_character_blacklist_catalan"; public static final String KEY_CHARACTER_BLACKLIST_CHINESE_SIMPLIFIED = "preference_character_blacklist_chinese_simplified"; public static final String KEY_CHARACTER_BLACKLIST_CHINESE_TRADITIONAL = "preference_character_blacklist_chinese_traditional"; public static final String KEY_CHARACTER_BLACKLIST_CZECH = "preference_character_blacklist_czech"; public static final String KEY_CHARACTER_BLACKLIST_DANISH = "preference_character_blacklist_danish"; public static final String KEY_CHARACTER_BLACKLIST_DUTCH = "preference_character_blacklist_dutch"; public static final String KEY_CHARACTER_BLACKLIST_ENGLISH = "preference_character_blacklist_english"; public static final String KEY_CHARACTER_BLACKLIST_FINNISH = "preference_character_blacklist_finnish"; public static final String KEY_CHARACTER_BLACKLIST_FRENCH = "preference_character_blacklist_french"; public static final String KEY_CHARACTER_BLACKLIST_GERMAN = "preference_character_blacklist_german"; public static final String KEY_CHARACTER_BLACKLIST_GREEK = "preference_character_blacklist_greek"; public static final String KEY_CHARACTER_BLACKLIST_HEBREW = "preference_character_blacklist_hebrew"; public static final String KEY_CHARACTER_BLACKLIST_HINDI = "preference_character_blacklist_hindi"; public static final String KEY_CHARACTER_BLACKLIST_HUNGARIAN = "preference_character_blacklist_hungarian"; public static final String KEY_CHARACTER_BLACKLIST_INDONESIAN = "preference_character_blacklist_indonesian"; public static final String KEY_CHARACTER_BLACKLIST_ITALIAN = "preference_character_blacklist_italian"; public static final String KEY_CHARACTER_BLACKLIST_JAPANESE = "preference_character_blacklist_japanese"; public static final String KEY_CHARACTER_BLACKLIST_KOREAN = "preference_character_blacklist_korean"; public static final String KEY_CHARACTER_BLACKLIST_LATVIAN = "preference_character_blacklist_latvian"; public static final String KEY_CHARACTER_BLACKLIST_LITHUANIAN = "preference_character_blacklist_lithuanian"; public static final String KEY_CHARACTER_BLACKLIST_NORWEGIAN = "preference_character_blacklist_norwegian"; public static final String KEY_CHARACTER_BLACKLIST_POLISH = "preference_character_blacklist_polish"; public static final String KEY_CHARACTER_BLACKLIST_PORTUGUESE = "preference_character_blacklist_portuguese"; public static final String KEY_CHARACTER_BLACKLIST_ROMANIAN = "preference_character_blacklist_romanian"; public static final String KEY_CHARACTER_BLACKLIST_RUSSIAN = "preference_character_blacklist_russian"; public static final String KEY_CHARACTER_BLACKLIST_SERBIAN = "preference_character_blacklist_serbian"; public static final String KEY_CHARACTER_BLACKLIST_SLOVAK = "preference_character_blacklist_slovak"; public static final String KEY_CHARACTER_BLACKLIST_SLOVENIAN = "preference_character_blacklist_slovenian"; public static final String KEY_CHARACTER_BLACKLIST_SPANISH = "preference_character_blacklist_spanish"; public static final String KEY_CHARACTER_BLACKLIST_SWEDISH = "preference_character_blacklist_swedish"; public static final String KEY_CHARACTER_BLACKLIST_TAGALOG = "preference_character_blacklist_tagalog"; public static final String KEY_CHARACTER_BLACKLIST_THAI = "preference_character_blacklist_thai"; public static final String KEY_CHARACTER_BLACKLIST_TURKISH = "preference_character_blacklist_turkish"; public static final String KEY_CHARACTER_BLACKLIST_UKRAINIAN = "preference_character_blacklist_ukrainian"; public static final String KEY_CHARACTER_BLACKLIST_VIETNAMESE = "preference_character_blacklist_vietnamese"; public static String getBlacklist(SharedPreferences prefs, String languageCode) { if (languageCode.equals("ara")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_ARABIC, getDefaultBlacklist(languageCode)); } // Arabic else if (languageCode.equals("bul")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_BULGARIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("cat")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_CATALAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("chi_sim")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_CHINESE_SIMPLIFIED, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("chi_tra")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_CHINESE_TRADITIONAL, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("ces")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_CZECH, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("dan")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_DANISH, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("nld")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_DUTCH, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("eng")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_ENGLISH, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("fin")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_FINNISH, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("fra")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_FRENCH, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("deu")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_GERMAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("ell")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_GREEK, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("heb")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_HEBREW, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("hin")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_HINDI, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("hun")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_HUNGARIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("ind")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_INDONESIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("ita")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_ITALIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("jpn")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_JAPANESE, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("kor")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_KOREAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("lav")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_LATVIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("lit")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_LITHUANIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("nor")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_NORWEGIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("pol")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_POLISH, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("por")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_PORTUGUESE, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("ron")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_ROMANIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("rus")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_RUSSIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("srp")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_SERBIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("slk")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_SLOVAK, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("slv")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_SLOVENIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("spa")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_SPANISH, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("swe")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_SWEDISH, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("tgl")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_TAGALOG, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("tha")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_THAI, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("tur")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_TURKISH, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("ukr")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_UKRAINIAN, getDefaultBlacklist(languageCode)); } else if (languageCode.equals("vie")) { return prefs.getString(KEY_CHARACTER_BLACKLIST_VIETNAMESE, getDefaultBlacklist(languageCode)); } else { throw new IllegalArgumentException(); } } public static String getDefaultBlacklist(String languageCode) { //final String DEFAULT_BLACKLIST = "`~|"; if (languageCode.equals("ara")) { return ""; } // Arabic else if (languageCode.equals("bul")) { return ""; } // Bulgarian else if (languageCode.equals("cat")) { return ""; } // Catalan else if (languageCode.equals("chi_sim")) { return ""; } // Chinese (Simplified) else if (languageCode.equals("chi_tra")) { return ""; } // Chinese (Traditional) else if (languageCode.equals("ces")) { return ""; } // Czech else if (languageCode.equals("dan")) { return ""; } // Danish else if (languageCode.equals("nld")) { return ""; } // Dutch else if (languageCode.equals("eng")) { return ""; } // English else if (languageCode.equals("fin")) { return ""; } // Finnish else if (languageCode.equals("fra")) { return ""; } // French else if (languageCode.equals("deu")) { return ""; } // German else if (languageCode.equals("ell")) { return ""; } // Greek else if (languageCode.equals("heb")) { return ""; } // Hebrew else if (languageCode.equals("hin")) { return ""; } // Hindi else if (languageCode.equals("hun")) { return ""; } // Hungarian else if (languageCode.equals("ind")) { return ""; } // Indonesian else if (languageCode.equals("ita")) { return ""; } // Italian else if (languageCode.equals("jpn")) { return ""; } // Japanese else if (languageCode.equals("kor")) { return ""; } // Korean else if (languageCode.equals("lav")) { return ""; } // Latvian else if (languageCode.equals("lit")) { return ""; } // Lithuanian else if (languageCode.equals("nor")) { return ""; } // Norwegian else if (languageCode.equals("pol")) { return ""; } // Polish else if (languageCode.equals("por")) { return ""; } // Portuguese else if (languageCode.equals("ron")) { return ""; } // Romanian else if (languageCode.equals("rus")) { return ""; } // Russian else if (languageCode.equals("srp")) { return ""; } // Serbian (Latin) else if (languageCode.equals("slk")) { return ""; } // Slovak else if (languageCode.equals("slv")) { return ""; } // Slovenian else if (languageCode.equals("spa")) { return ""; } // Spanish else if (languageCode.equals("swe")) { return ""; } // Swedish else if (languageCode.equals("tgl")) { return ""; } // Tagalog else if (languageCode.equals("tha")) { return ""; } // Thai else if (languageCode.equals("tur")) { return ""; } // Turkish else if (languageCode.equals("ukr")) { return ""; } // Ukrainian else if (languageCode.equals("vie")) { return ""; } // Vietnamese else { throw new IllegalArgumentException(); } } }