@Test public void shouldAcceptCandidateKey() { String[] listKeyValid = {"test.dot", "test.double.dot", "test.test_underscore", "test.test_double_underscore", "test.test_double_underscore.dot", "test.dot_double_underscore", "test.test2"}; String[] listKeyInvalid = {"test", "space not accepted", "double..dot"}; for (String key : listKeyValid) { assertTrue("The key '" + key + "' should be accepted as a valid key", I18Next.isI18NextKeyCandidate(key)); } for (String key : listKeyInvalid) { assertFalse("The key '" + key + "' should not be accepted as a valid key", I18Next.isI18NextKeyCandidate(key)); } }
public static boolean isI18NextKeyCandidate(CharSequence key) { if (key != null && key.length() > 0) { return key.toString().matches("([a-z0-9]+((\\_)([a-z0-9]+))*)+((\\.)[a-z0-9]+((\\_)([a-z0-9]+))*)+"); } else { return false; } }
I18Next { public static boolean isI18NextKeyCandidate(CharSequence key) { if (key != null && key.length() > 0) { return key.toString().matches("([a-z0-9]+((\\_)([a-z0-9]+))*)+((\\.)[a-z0-9]+((\\_)([a-z0-9]+))*)+"); } else { return false; } } }
I18Next { public static boolean isI18NextKeyCandidate(CharSequence key) { if (key != null && key.length() > 0) { return key.toString().matches("([a-z0-9]+((\\_)([a-z0-9]+))*)+((\\.)[a-z0-9]+((\\_)([a-z0-9]+))*)+"); } else { return false; } } I18Next(); }
I18Next { public static boolean isI18NextKeyCandidate(CharSequence key) { if (key != null && key.length() > 0) { return key.toString().matches("([a-z0-9]+((\\_)([a-z0-9]+))*)+((\\.)[a-z0-9]+((\\_)([a-z0-9]+))*)+"); } else { return false; } } I18Next(); static I18Next getInstance(); Loader loader(); void saveInPreference(SharedPreferences sharedPreference); void loadFromPreference(SharedPreferences sharedPreference); static boolean isI18NextKeyCandidate(CharSequence key); boolean isEmpty(); Options getOptions(); String t(String key); String t(String... keys); String t(String key, Operation operation); String t(String[] keys, Operation operation); boolean existValue(String key); }
I18Next { public static boolean isI18NextKeyCandidate(CharSequence key) { if (key != null && key.length() > 0) { return key.toString().matches("([a-z0-9]+((\\_)([a-z0-9]+))*)+((\\.)[a-z0-9]+((\\_)([a-z0-9]+))*)+"); } else { return false; } } I18Next(); static I18Next getInstance(); Loader loader(); void saveInPreference(SharedPreferences sharedPreference); void loadFromPreference(SharedPreferences sharedPreference); static boolean isI18NextKeyCandidate(CharSequence key); boolean isEmpty(); Options getOptions(); String t(String key); String t(String... keys); String t(String key, Operation operation); String t(String[] keys, Operation operation); boolean existValue(String key);  }