本文整理汇总了Java中java.util.MissingResourceException类的典型用法代码示例。如果您正苦于以下问题:Java MissingResourceException类的具体用法?Java MissingResourceException怎么用?Java MissingResourceException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MissingResourceException类属于java.util包,在下文中一共展示了MissingResourceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRef
import java.util.MissingResourceException; //导入依赖的package包/类
/**
* Return a ref to a new or existing RefCapablePropertyResourceBundle,
* or throw a MissingResourceException.
*/
static private RefCapablePropertyResourceBundle getRef(String baseName,
ResourceBundle rb, ClassLoader loader) {
if (!(rb instanceof PropertyResourceBundle))
throw new MissingResourceException(
"Found a Resource Bundle, but it is a "
+ rb.getClass().getName(),
PropertyResourceBundle.class.getName(), null);
if (allBundles.containsKey(rb))
return (RefCapablePropertyResourceBundle) allBundles.get(rb);
RefCapablePropertyResourceBundle newPRAFP =
new RefCapablePropertyResourceBundle(baseName,
(PropertyResourceBundle) rb, loader);
allBundles.put(rb, newPRAFP);
return newPRAFP;
}
示例2: getResource
import java.util.MissingResourceException; //导入依赖的package包/类
private String getResource(String key, Locale locale) {
if (locale == null) {
locale = Locale.getDefault();
}
/**
* Per the class documentation, resource bundles, including localized ones
* are intended to be delivered by the subclasser - ie supplier of the
* metadataformat. For the standard format and all standard plugins that
* is the JDK. For 3rd party plugins that they will supply their own.
* This includes plugins bundled with applets/applications.
* In all cases this means it is sufficient to search for those resource
* in the module that is providing the MetadataFormatImpl subclass.
*/
try {
ResourceBundle bundle = ResourceBundle.getBundle(resourceBaseName, locale,
this.getClass().getModule());
return bundle.getString(key);
} catch (MissingResourceException e) {
return null;
}
}
示例3: configureMenuItem
import java.util.MissingResourceException; //导入依赖的package包/类
private void configureMenuItem(JMenuItem item, String resource, ActionListener listener) {
configureAbstractButton(item, resource);
item.addActionListener(listener);
try {
String accel = resources.getString(resource + ".accel");
String metaPrefix = "@";
if (accel.startsWith(metaPrefix)) {
int menuMask = getToolkit().getMenuShortcutKeyMask();
KeyStroke key = KeyStroke.getKeyStroke(
KeyStroke.getKeyStroke(accel.substring(metaPrefix.length())).getKeyCode(), menuMask);
item.setAccelerator(key);
} else {
item.setAccelerator(KeyStroke.getKeyStroke(accel));
}
} catch (MissingResourceException ex) {
// no accelerator
}
}
示例4: getInstance
import java.util.MissingResourceException; //导入依赖的package包/类
/**
* Method to create the ResourceBundle object if not exists.
*
* @return The ResourceBundle object if not exist.
*/
public static ResourceBundle getInstance()
{
if (messages == null)
{
log.debug("Internationalization settings...");
try
{
// user default Locale :
locale = Locale.getDefault();
log.info("Default user Locale : " + locale.getLanguage() + "_" + locale.getCountry());
messages = ResourceBundle.getBundle("messages", locale);
} catch (MissingResourceException e)
{
log.error("Cannot configure Locale, missing resources file => " + e);
System.exit(0);
}
}
return messages;
}
示例5: init
import java.util.MissingResourceException; //导入依赖的package包/类
public void init() {
DummyImageReaderImpl reader;
MyReadWarningListener listener = new MyReadWarningListener();
Locale[] locales = {new Locale("ru"),
new Locale("fr"),
new Locale("uk")};
reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());
reader.setAvailableLocales(locales);
reader.setLocale(new Locale("fr"));
reader.addIIOReadWarningListener(listener);
String baseName = "AppletResourceTest$BugStats";
try {
reader.processWarningOccurred("WarningMessage");
reader.processWarningOccurred(baseName, "water");
} catch (MissingResourceException mre) {
throw new RuntimeException("Test failed: couldn't load resource");
}
}
示例6: getRootType
import java.util.MissingResourceException; //导入依赖的package包/类
private static RootType getRootType(String baseName, ClassLoader root) {
RootType rootType = ROOT_CACHE.get(baseName);
if (rootType == null) {
String rootLocale = (baseName.indexOf('.')==-1) ? "root" : "";
try{
ICUResourceBundle.getBundleInstance(baseName, rootLocale, root, true);
rootType = RootType.ICU;
}catch(MissingResourceException ex){
try{
ResourceBundleWrapper.getBundleInstance(baseName, rootLocale, root, true);
rootType = RootType.JAVA;
}catch(MissingResourceException e){
//throw away the exception
rootType = RootType.MISSING;
}
}
ROOT_CACHE.put(baseName, rootType);
}
return rootType;
}
示例7: getString
import java.util.MissingResourceException; //导入依赖的package包/类
/**
* Returns the localized message for the given message key
*
* @param key
* the message key
* @return The localized message for the key
*/
public static String getString(String key)
{
if (RESOURCE_BUNDLE == null)
throw new RuntimeException("Localized messages from resource bundle '" + BUNDLE_NAME + "' not loaded during initialization of driver.");
try
{
if (key == null)
throw new IllegalArgumentException("Message key can not be null");
String message = RESOURCE_BUNDLE.getString(key);
if (message == null)
message = "Missing error message for key '" + key + "'";
return message;
}
catch (MissingResourceException e)
{
return '!' + key + '!';
}
}
示例8: lookupBundle
import java.util.MissingResourceException; //导入依赖的package包/类
private boolean lookupBundle(String rbName) {
// See if Logger.getLogger can find the resource in this directory
try {
Logger aLogger = Logger.getLogger("NestedLogger2", rbName);
} catch (MissingResourceException re) {
if (DEBUG) {
System.out.println(
"As expected, LoadItUp2.lookupBundle() did not find the bundle "
+ rbName);
}
return false;
}
System.out.println("FAILED: LoadItUp2.lookupBundle() found the bundle "
+ rbName + " using a stack search.");
return true;
}
示例9: lookupInstanceByName
import java.util.MissingResourceException; //导入依赖的package包/类
private static NumberingSystem lookupInstanceByName(String name) {
int radix;
boolean isAlgorithmic;
String description;
try {
UResourceBundle numberingSystemsInfo = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, "numberingSystems");
UResourceBundle nsCurrent = numberingSystemsInfo.get("numberingSystems");
UResourceBundle nsTop = nsCurrent.get(name);
description = nsTop.getString("desc");
UResourceBundle nsRadixBundle = nsTop.get("radix");
UResourceBundle nsAlgBundle = nsTop.get("algorithmic");
radix = nsRadixBundle.getInt();
int algorithmic = nsAlgBundle.getInt();
isAlgorithmic = ( algorithmic == 1 );
} catch (MissingResourceException ex) {
return null;
}
return getInstance(name, radix, isAlgorithmic, description);
}
示例10: getMessage
import java.util.MissingResourceException; //导入依赖的package包/类
/**
* Overrides this method to get the formatted&localized error message.
*
* REVISIT: the system locale is used to load the property file.
* do we want to allow the appilcation to specify a
* different locale?
*/
public String getMessage() {
ResourceBundle resourceBundle = null;
resourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
if (resourceBundle == null)
throw new MissingResourceException("Property file not found!", "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);
String msg = resourceBundle.getString(key);
if (msg == null) {
msg = resourceBundle.getString("BadMessageKey");
throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);
}
if (args != null) {
try {
msg = java.text.MessageFormat.format(msg, args);
} catch (Exception e) {
msg = resourceBundle.getString("FormatFailed");
msg += " " + resourceBundle.getString(key);
}
}
return msg;
}
示例11: getSimpleTabsPlacement
import java.util.MissingResourceException; //导入依赖的package包/类
/**
* Defines the tab placement. The possible bundle values are <code>top</code>, <code>bottom</code>, <code>left</code>, <code>right</code>.
* @return Tab placement when JTabbedPane implementation of Tab Control is
* being used. The return value is one of <code>JTabbedPane.TOP</code> (default), <code>JTabbedPane.BOTTOM</code>,
* <code>JTabbedPane.LEFT</code>, <code>JTabbedPane.RIGHT</code>.
*
* @see JTabbedPane#getTabPlacement()
*
* @since 2.44
*/
public static int getSimpleTabsPlacement() {
int result = JTabbedPane.TOP;
try {
String resValue = NbBundle.getMessage(Switches.class, "WinSys.TabControl.SimpleTabs.Placement" ); //NOI18N
if( "bottom".equals( resValue ) )
result = JTabbedPane.BOTTOM;
else if( "right".equals( resValue ) )
result = JTabbedPane.RIGHT;
else if( "left".equals( resValue ) )
result = JTabbedPane.LEFT;
} catch( MissingResourceException mrE ) {
//ignore
}
return result;
}
示例12: getLocalizedString
import java.util.MissingResourceException; //导入依赖的package包/类
private static String getLocalizedString(List<ResourceBundle> bundles,
String key,
Object... args) {
String msg = null;
for (List<ResourceBundle> l = bundles; l.nonEmpty() && msg == null; l = l.tail) {
ResourceBundle rb = l.head;
try {
msg = rb.getString(key);
}
catch (MissingResourceException e) {
// ignore, try other bundles in list
}
}
if (msg == null) {
msg = "compiler message file broken: key=" + key +
" arguments={0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}";
}
return MessageFormat.format(msg, args);
}
示例13: queryPreferPublic
import java.util.MissingResourceException; //导入依赖的package包/类
/**
* Obtain the preferPublic setting from the properties.
*
* <p>In the properties, a value of 'public' is true,
* anything else is false.</p>
*
* @return True if prefer is public or the
* defaultPreferSetting.
*/
private boolean queryPreferPublic () {
String prefer = SecuritySupport.getSystemProperty(pPrefer);
if (prefer == null) {
if (resources==null) readProperties();
if (resources==null) return defaultPreferPublic;
try {
prefer = resources.getString("prefer");
} catch (MissingResourceException e) {
return defaultPreferPublic;
}
}
if (prefer == null) {
return defaultPreferPublic;
}
return (prefer.equalsIgnoreCase("public"));
}
示例14: getResourceBundleObject
import java.util.MissingResourceException; //导入依赖的package包/类
private static Object getResourceBundleObject(String messageKey, Locale locale) {
// slow resource checking
// need to loop thru all registered resource bundles
for (Iterator<String> it = bundles.keySet().iterator(); it.hasNext();) {
Class<? extends NLS> clazz = bundles.get(it.next());
ResourceBundle resourceBundle = ResourceBundle.getBundle(clazz.getName(),
locale);
if (resourceBundle != null) {
try {
Object obj = resourceBundle.getObject(messageKey);
if (obj != null)
return obj;
} catch (MissingResourceException e) {
// just continue it might be on the next resource bundle
}
}
}
// if resource is not found
return null;
}
示例15: get
import java.util.MissingResourceException; //导入依赖的package包/类
ICUResourceBundle get(String aKey, HashMap<String, String> aliasesVisited, UResourceBundle requested) {
ICUResourceBundle obj = (ICUResourceBundle)handleGet(aKey, aliasesVisited, requested);
if (obj == null) {
obj = getParent();
if (obj != null) {
//call the get method to recursively fetch the resource
obj = obj.get(aKey, aliasesVisited, requested);
}
if (obj == null) {
String fullName = ICUResourceBundleReader.getFullName(getBaseName(), getLocaleID());
throw new MissingResourceException(
"Can't find resource for bundle " + fullName + ", key "
+ aKey, this.getClass().getName(), aKey);
}
}
return obj;
}