Java 类java.util.MissingResourceException 实例源码

项目:sstore-soft    文件:RefCapablePropertyResourceBundle.java   
/**
 * 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;
}
项目:openjdk-jdk10    文件:IIOMetadataFormatImpl.java   
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;
    }
}
项目:AWGW    文件:WorldFrame.java   
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
    }
}
项目:swing-desktop-starter    文件:I18N.java   
/**
 * 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;
}
项目:openjdk-jdk10    文件:AppletResourceTest.java   
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");
    }


}
项目:fitnotifications    文件:UResourceBundle.java   
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;
}
项目:s-store    文件:Resources.java   
/**
 * 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 + '!';
    }
}
项目:jdk8u-jdk    文件:LoadItUp2.java   
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;
}
项目:fitnotifications    文件:NumberingSystem.java   
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);
}
项目:OpenJSharp    文件:DatatypeException.java   
/**
 * 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;
}
项目:parabuild-ci    文件:RefCapablePropertyResourceBundle.java   
/**
 * 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;
}
项目:incubator-netbeans    文件:Switches.java   
/**
 * 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;
}
项目:openjdk-jdk10    文件:JavacMessages.java   
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);
}
项目:OpenJSharp    文件:CatalogManager.java   
/**
 * 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"));
}
项目:sstore-soft    文件:Resources.java   
/**
 * 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 + '!';
    }
}
项目:lams    文件:NLS.java   
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;
  }
项目:fitnotifications    文件:ICUResourceBundle.java   
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;
}
项目:incubator-netbeans    文件:TestBundleKeys.java   
/**
 * Performs the test itself.
 *
 * @throws java.lang.Throwable
 */
protected void runTest() throws Throwable {

    String keys = getProperties(getDescendantClassLoader(), getPropertiesName()).getProperty(getName());

    ResourceBundle lrBundle=NbBundle.getBundle(getName());

    String[] lrTokens = keys.split(",");        
    int lnNumMissing = 0;
    StringBuffer lrBufMissing = new StringBuffer();
    for (String lsKey : lrTokens)
    try {
        lrBundle.getObject(lsKey);
    } catch (MissingResourceException mre) {
        lrBufMissing.append(lsKey).append(" ");
        lnNumMissing++;
    }
    if (lnNumMissing > 0)
        throw new AssertionFailedError("Missing "+String.valueOf(lnNumMissing)+" key(s): "+ lrBufMissing.toString());

}
项目:jdk8u-jdk    文件:AccessibleBundle.java   
private void loadResourceBundle(String resourceBundleName,
                                Locale locale) {
    if (! table.contains(locale)) {

        try {
            Hashtable resourceTable = new Hashtable();

            ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleName, locale);

            Enumeration iter = bundle.getKeys();
            while(iter.hasMoreElements()) {
                String key = (String)iter.nextElement();
                resourceTable.put(key, bundle.getObject(key));
            }

            table.put(locale, resourceTable);
        }
        catch (MissingResourceException e) {
            System.err.println("loadResourceBundle: " + e);
            // Just return so toDisplayString() returns the
            // non-localized key.
            return;
        }
    }
}
项目:OpenJSharp    文件:JavacMessages.java   
public List<ResourceBundle> getBundles(Locale locale) {
    if (locale == currentLocale && currentBundles != null)
        return currentBundles;
    SoftReference<List<ResourceBundle>> bundles = bundleCache.get(locale);
    List<ResourceBundle> bundleList = bundles == null ? null : bundles.get();
    if (bundleList == null) {
        bundleList = List.nil();
        for (String bundleName : bundleNames) {
            try {
                ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale);
                bundleList = bundleList.prepend(rb);
            } catch (MissingResourceException e) {
                throw new InternalError("Cannot find javac resource bundle for locale " + locale);
            }
        }
        bundleCache.put(locale, new SoftReference<List<ResourceBundle>>(bundleList));
    }
    return bundleList;
}
项目:lazycat    文件:ResourceBundleELResolver.java   
@Override
public Object getValue(ELContext context, Object base, Object property)
        throws NullPointerException, PropertyNotFoundException, ELException {

    if (context == null) {
        throw new NullPointerException();
    }

    if (base instanceof ResourceBundle) {
        context.setPropertyResolved(true);

        if (property != null) {
            try {
                return ((ResourceBundle) base).getObject(property.toString());
            } catch (MissingResourceException mre) {
                return "???" + property.toString() + "???";
            }
        }
    }

    return null;
}
项目:incubator-netbeans    文件:MakeDefaultCatalogAction.java   
/**
 * If DDL exception was caused by a closed connection, log info and display
 * a simple error dialog. Otherwise let users report the exception.
 */
private void handleDLLException(DatabaseConnection dbConn,
        DDLException e) throws SQLException, MissingResourceException {
    Connection conn = dbConn == null ? null : dbConn.getJDBCConnection();
    if (conn != null && !conn.isValid(1000)) {
        LOGGER.log(Level.INFO, e.getMessage(), e);
        NotifyDescriptor nd = new NotifyDescriptor.Message(
                NbBundle.getMessage(
                MakeDefaultCatalogAction.class,
                "ERR_ConnectionToServerClosed"), //NOI18N
                NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notifyLater(nd);
    } else {
        Exceptions.printStackTrace(e);
    }
}
项目:logistimo-web-service    文件:Resources.java   
public ResourceBundle getBundle(String baseName, Locale locale) throws MissingResourceException {
  if (baseName == null || locale == null) {
    return null;
  }
  // Get the resource bundle, if not already present
  String key = baseName + "_" + locale.toString();
  xLogger.fine("Resources.getBundle(): trying first key = {0}", key);
  ResourceBundle bundle = rmap.get(key);
  if (bundle == null) {
    key = baseName + "_" + locale.getLanguage();
    bundle = rmap.get(key);
    xLogger.fine("Resources.getBundle(): tried second key = {0}, bundle = {1}", key, bundle);
    if (bundle == null) {
      bundle = getUTF8Bundle(baseName, locale);
      key =
          baseName + "_" + bundle.getLocale()
              .toString(); // actual (fallback) locale used to get the file
      xLogger.fine(
          "Resource.getBundle(): getting it first time using locale = {0}, actual key = {0}",
          locale.toString(), key);
      rmap.put(key, bundle);
    }
  }
  return bundle;
}
项目:myfaces-trinidad    文件:CompositeRenderingContext.java   
/**
 * Returns a translated value from the skin's resource bundle.
 * Logs a severe message if there is a MissingResourceException.
 */
public Object getTranslatedValue(String key)
{
  String mappedKey = getSkinResourceMappedKey(key);

  if (mappedKey != null)
  {
    try{
      return getParentContext().getTranslatedValue(mappedKey);
    }
    catch (MissingResourceException e)
    {
      // log the error and return
      _LOG.severe(e);

      return null;
    }
  }
  else
    return null;

}
项目:openjdk-jdk10    文件:DatatypeException.java   
/**
 * 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;
}
项目:parabuild-ci    文件:RefCapablePropertyResourceBundle.java   
/**
 * 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;
}
项目:fitnotifications    文件:Calendar.java   
private static WeekData getWeekDataForRegionInternal(String region) {
    if (region == null) {
        region = "001";
    }

    UResourceBundle rb = UResourceBundle.getBundleInstance(
            ICUData.ICU_BASE_NAME,
            "supplementalData",
            ICUResourceBundle.ICU_DATA_CLASS_LOADER);
    UResourceBundle weekDataInfo = rb.get("weekData");
    UResourceBundle weekDataBundle = null;

    try {
        weekDataBundle = weekDataInfo.get(region);
    } catch (MissingResourceException mre) {
        if (!region.equals("001")) {
            // use "001" as fallback
            weekDataBundle = weekDataInfo.get("001");
        } else {
            throw mre;
        }
    }

    int[] wdi = weekDataBundle.getIntVector();
    return new WeekData(wdi[0],wdi[1],wdi[2],wdi[3],wdi[4],wdi[5]);
}
项目:tomcat7    文件:StringManager.java   
/**
 * Creates a new StringManager for a given package. This is a
 * private method and all access to it is arbitrated by the
 * static getManager method call so that only one StringManager
 * per package will be created.
 *
 * @param packageName Name of package to create StringManager for.
 */
private StringManager(String packageName) {
    String bundleName = packageName + ".LocalStrings";
    try {
        bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
    } catch( MissingResourceException ex ) {
        // Try from the current loader (that's the case for trusted apps)
        // Should only be required if using a TC5 style classloader structure
        // where common != shared != server
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        if( cl != null ) {
            try {
                bundle = ResourceBundle.getBundle(
                        bundleName, Locale.getDefault(), cl);
            } catch(MissingResourceException ex2) {
                // Ignore
            }
        }
    }
    // Get the actual locale, which may be different from the requested one
    if (bundle != null) {
        locale = bundle.getLocale();
    }
}
项目:openjdk-jdk10    文件:XSMessageFormatter.java   
/**
 * Formats a message with the specified arguments using the given
 * locale information.
 *
 * @param locale    The locale of the message.
 * @param key       The message key.
 * @param arguments The message replacement text arguments. The order
 *                  of the arguments must match that of the placeholders
 *                  in the actual message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException Thrown if the message with the
 *                                  specified key cannot be found.
 */
 public String formatMessage(Locale locale, String key, Object[] arguments)
    throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.SchemaMessages", key);
    }

    return msg;
}
项目:SimQRI    文件:MetamodelModelWizard.java   
/**
 * Returns the label for the specified type name.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected String getLabel(String typeName) {
    try {
        return MetamodelEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
    }
    catch(MissingResourceException mre) {
        MetamodelEditorPlugin.INSTANCE.log(mre);
    }
    return typeName;
}
项目:apache-tomcat-7.0.73-with-comment    文件:StringManager.java   
/**
 * Get a string from the underlying resource bundle or return null if the
 * String is not found.
 *
 * @param key to desired resource String
 *
 * @return resource String matching <i>key</i> from underlying bundle or
 *         null if not found.
 *
 * @throws IllegalArgumentException if <i>key</i> is null
 */
public String getString(String key) {
    if (key == null){
        String msg = "key may not have a null value";
        throw new IllegalArgumentException(msg);
    }

    String str = null;

    try {
        // Avoid NPE if bundle is null and treat it like an MRE
        if (bundle != null) {
            str = bundle.getString(key);
        }
    } catch (MissingResourceException mre) {
        //bad: shouldn't mask an exception the following way:
        //   str = "[cannot find message associated with key '" + key +
        //         "' due to " + mre + "]";
        //     because it hides the fact that the String was missing
        //     from the calling code.
        //good: could just throw the exception (or wrap it in another)
        //      but that would probably cause much havoc on existing
        //      code.
        //better: consistent with container pattern to
        //      simply return null.  Calling code can then do
        //      a null check.
        str = null;
    }

    return str;
}
项目:jdk8u-jdk    文件:Resources.java   
/**
 * Returns the message corresponding to the key in the bundle or a text
 * describing it's missing.
 *
 * @param rb the resource bundle
 * @param key the key
 *
 * @return the message
 */
private static String getMessage(ResourceBundle rb, String key) {
    if (rb == null) {
        return "missing resource bundle";
    }
    try {
        return rb.getString(key);
    } catch (MissingResourceException mre) {
        return "missing message for key = \"" + key
                + "\" in resource bundle ";
    }
}
项目:oscm    文件:Messages.java   
public static String get(String locale, String key) {

        try {
            if (bundleList.containsKey(locale))
                return bundleList.get(locale).getString(key);
            else
                return bundleList.get(DEFAULT_LOCALE).getString(key);
        } catch (MissingResourceException e) {
            return '!' + key + '!';
        }
    }
项目:OpenJSharp    文件:RegexParser.java   
public void setLocale(Locale locale) {
    try {
        if (locale != null) {
            this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message", locale);
        }
        else {
            this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message");
        }
    }
    catch (MissingResourceException mre) {
        throw new RuntimeException("Installation Problem???  Couldn't load messages: "
                                   + mre.getMessage());
    }
}
项目:lams    文件:Localizer.java   
public static String getMessage(String errCode) {
String errMsg = errCode;
try {
    errMsg = bundle.getString(errCode);
} catch (MissingResourceException e) {
}
return errMsg;
   }
项目:myfaces-trinidad    文件:TranslationsResourceLoader.java   
private ResourceBundle _getResourceBundle(Locale locale)
  throws MissingResourceException
{
  ClassLoader loader = Thread.currentThread().getContextClassLoader();
  return ResourceBundle.getBundle(getBundleName(),
                                  locale,
                                  loader);
}
项目:org.mybatis.generator.core-1.3.5    文件:Messages.java   
public static String getString(String key, String parm1, String parm2) {
    try {
        return MessageFormat.format(RESOURCE_BUNDLE.getString(key),
                new Object[] { parm1, parm2 });
    } catch (MissingResourceException e) {
        return '!' + key + '!';
    }
}
项目:jdk8u-jdk    文件:Agent.java   
private static void initResource() {
    try {
        messageRB =
                ResourceBundle.getBundle("sun.management.resources.agent");
    } catch (MissingResourceException e) {
        throw new Error("Fatal: Resource for management agent is missing");
    }
}
项目:tomcat7    文件:MessageFactory.java   
public static String get(final String key) {
    try {
        return bundle.getString(key);
    } catch (MissingResourceException e) {
        return key;
    }
}
项目:openjdk-jdk10    文件:SecuritySupport.java   
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged((PrivilegedAction<ResourceBundle>) () -> {
        try {
            return PropertyResourceBundle.getBundle(bundle, locale);
        } catch (MissingResourceException e) {
            try {
                return PropertyResourceBundle.getBundle(bundle, new Locale("en", "US"));
            } catch (MissingResourceException e2) {
                throw new MissingResourceException(
                        "Could not load any resource bundle by " + bundle, bundle, "");
            }
        }
    });
}