use of java.util.MissingResourceException in project Openfire by igniterealtime.
the class WorkgroupBeanInfo method getPropertyDescriptors.
public PropertyDescriptor[] getPropertyDescriptors() {
Class beanClass = getBeanClass();
String[] properties = getPropertyNames();
PropertyDescriptor[] descriptors = new PropertyDescriptor[properties.length];
try {
// name and description using the localized data.
for (int i = 0; i < descriptors.length; i++) {
PropertyDescriptor newDescriptor = new PropertyDescriptor(properties[i], beanClass);
if (bundle != null) {
try {
newDescriptor.setDisplayName(bundle.getString(properties[i] + ".displayName"));
} catch (MissingResourceException ignored) {
}
try {
newDescriptor.setShortDescription(bundle.getString(properties[i] + ".shortDescription"));
} catch (MissingResourceException ignored) {
}
// used to set this value.
try {
String largeText = bundle.getString(properties[i] + ".useLargeTextField");
if ("true".equals(largeText)) {
newDescriptor.setValue("useLargeTextField", "true");
}
} catch (MissingResourceException ignored) {
}
}
descriptors[i] = newDescriptor;
}
return descriptors;
} catch (IntrospectionException ie) {
Log.error(ie.getMessage(), ie);
throw new Error(ie.toString());
}
}
use of java.util.MissingResourceException in project groovy-core by groovy.
the class MessageSource method getMessage.
/**
* Get a raw message from the resource bundles using the given code.
*/
public String getMessage(final String code) {
assert code != null;
MissingResourceException error = null;
ResourceBundle[] bundles = getBundles();
for (int i = 0; i < bundles.length; i++) {
try {
return bundles[i].getString(code);
} catch (MissingResourceException e) {
if (error != null) {
error = e;
}
}
}
assert error != null;
throw error;
}
use of java.util.MissingResourceException in project j2objc by google.
the class ResourceBundleTest method test_getBundle_getClassName.
public void test_getBundle_getClassName() {
// Regression test for Harmony-1759
Locale locale = Locale.GERMAN;
String nonExistentBundle = "Non-ExistentBundle";
try {
ResourceBundle.getBundle(nonExistentBundle, locale, this.getClass().getClassLoader());
fail("MissingResourceException expected!");
} catch (MissingResourceException e) {
assertEquals(nonExistentBundle + "_" + locale, e.getClassName());
}
try {
ResourceBundle.getBundle(nonExistentBundle, locale);
fail("MissingResourceException expected!");
} catch (MissingResourceException e) {
assertEquals(nonExistentBundle + "_" + locale, e.getClassName());
}
locale = Locale.getDefault();
try {
ResourceBundle.getBundle(nonExistentBundle);
fail("MissingResourceException expected!");
} catch (MissingResourceException e) {
assertEquals(nonExistentBundle + "_" + locale, e.getClassName());
}
}
use of java.util.MissingResourceException in project j2objc by google.
the class ResourceBundleTest method test_getObjectLjava_lang_String.
public void test_getObjectLjava_lang_String() {
ResourceBundle bundle;
String name = "tests.support.Support_TestResource";
Locale.setDefault(new Locale("en", "US"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "VAR"));
assertEquals("Wrong value parent4", "frFRVARValue4", (String) bundle.getObject("parent4"));
assertEquals("Wrong value parent3", "frFRValue3", (String) bundle.getObject("parent3"));
assertEquals("Wrong value parent2", "frValue2", (String) bundle.getObject("parent2"));
assertEquals("Wrong value parent1", "parentValue1", (String) bundle.getObject("parent1"));
assertEquals("Wrong value child3", "frFRVARChildValue3", (String) bundle.getObject("child3"));
assertEquals("Wrong value child2", "frFRVARChildValue2", (String) bundle.getObject("child2"));
assertEquals("Wrong value child1", "frFRVARChildValue1", (String) bundle.getObject("child1"));
assertEquals("Wrong value IntegerVal", 1, bundle.getObject("IntegerVal"));
try {
bundle.getObject(null);
fail("NullPointerException expected");
} catch (NullPointerException ee) {
//expected
}
try {
bundle.getObject("");
fail("MissingResourceException expected");
} catch (MissingResourceException ee) {
//expected
}
}
use of java.util.MissingResourceException in project j2objc by google.
the class ResourceBundleTest method test_getBundleLjava_lang_StringLjava_util_Locale.
/**
* java.util.ResourceBundle#getBundle(java.lang.String,
* java.util.Locale)
*/
public void test_getBundleLjava_lang_StringLjava_util_Locale() {
ResourceBundle bundle;
String name = "tests.support.Support_TestResource";
Locale defLocale = Locale.getDefault();
Locale.setDefault(new Locale("en", "US"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "VAR"));
assertEquals("Wrong bundle fr_FR_VAR", "frFRVARValue4", bundle.getString("parent4"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "v1"));
assertEquals("Wrong bundle fr_FR_v1", "frFRValue4", bundle.getString("parent4"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "US", "VAR"));
assertEquals("Wrong bundle fr_US_var", "frValue4", bundle.getString("parent4"));
bundle = ResourceBundle.getBundle(name, new Locale("de", "FR", "VAR"));
assertEquals("Wrong bundle de_FR_var", "enUSValue4", bundle.getString("parent4"));
Locale.setDefault(new Locale("fr", "FR", "VAR"));
bundle = ResourceBundle.getBundle(name, new Locale("de", "FR", "v1"));
assertEquals("Wrong bundle de_FR_var 2", "frFRVARValue4", bundle.getString("parent4"));
Locale.setDefault(new Locale("de", "US"));
bundle = ResourceBundle.getBundle(name, new Locale("de", "FR", "var"));
assertEquals("Wrong bundle de_FR_var 2", "parentValue4", bundle.getString("parent4"));
try {
ResourceBundle.getBundle(null, Locale.US);
fail("NullPointerException expected");
} catch (NullPointerException ee) {
//expected
}
try {
ResourceBundle.getBundle("blah", (Locale) null);
fail("NullPointerException expected");
} catch (NullPointerException ee) {
//expected
}
try {
ResourceBundle.getBundle("", new Locale("xx", "yy"));
fail("MissingResourceException expected");
} catch (MissingResourceException ee) {
//expected
}
}
Aggregations