Java 8 MissingResourceException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 MissingResourceException class.

This code example shows how to use the following methods:
 
		mockStatic(ResourceBundle.class);
		expect(ResourceBundle.getBundle("SomeBundleName", Locale.ENGLISH)).andReturn(bundle);
 
		final String key = "DUMMY";
		Exception e = new MissingResourceException(key, key, key);
		expect(bundle.getString(key)).andThrow(e);
 
		replayAll(); 
		instance.getResourceString(key);
	} 
 
	@Test(expected = MissingResourceException.class) 
	public final void testGetResourceStringWithBundleMissing() { 
 
		mockStatic(ResourceBundle.class);
		final String key = "DUMMY";
		Exception e = new MissingResourceException(key, key, key);
		expect(ResourceBundle.getBundle("SomeBundleName", Locale.ENGLISH)).andThrow(e);
 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: setStackTrace
            else { 
                return ResourceBundle.getBundle(this.errorBundleName, locale);
            } 
        } 
        catch (MissingResourceException mre) {
            MissingResourceException mre2 = new MissingResourceException(
                    "Could not find the error message resource bundle needed by Stripes. This " + 
                    "almost certainly means that a properties file called '" + 
                    this.errorBundleName + ".properties' could not be found in the classpath. " +
                    "This properties file is needed to lookup validation error messages. Please " + 
                    "ensure the file exists in WEB-INF/classes or elsewhere in your classpath.", 
                    this.errorBundleName, "");
            mre2.setStackTrace(mre.getStackTrace());
            throw mre2;
        } 
    } 
 
    /** 
     * Looks for a bundle called StripesResources with the supplied locale if one is provided, 
     * or with the default locale if the locale provided is null. 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	@Override 
	protected Object handleGetObject(String k) {
		if (k.equals(key)) {
			return value;
		} 
		throw new MissingResourceException(k, value, key);
	} 
 
	@Override 
	public Enumeration<String> getKeys() {
		return Collections.enumeration(Collections.singleton(key));
	} 
} 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getMessage
        } 
 
        try { 
            return ResourceBundle.getBundle(resourceName);
        } catch (final MissingResourceException e) {
            logger.warn(e.getMessage());
            return EMPTY_RESOURCE_BUNDLE;
        } 
    } 
 
} 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getClassName, getKey
        } catch (MissingResourceException e) {
            try { 
                return stockBundle.getString(key);
            } catch (MissingResourceException e1) {
                if (LOG.isWarnEnabled()) { 
                    LOG.warn("Cannot find resource " + e1.getKey() + " in bundle " + e1.getClassName());
                } 
                return ""; 
            } 
        } 
    } 
 
    private String escape(String message) {
        return message.replaceAll("'", "\\\\'");
    } 
} 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
		String result = properties.get(key);
		if (result == null) {
			if (parent != null) result = parent.get(key);
			if (result == null) {
				if (exceptionOnMissingKey)
					throw new MissingResourceException("Can't find bundle key " + key, this.getClass().getName(), key);
				else 
					return "???" + key + "???";
			} 
		} 
		return result;
	} 
 
	/** Gets the string with the specified key from this bundle or one of its parent after replacing the given arguments if they 
	 * occur. 
	 *  
	 * @param key the key for the desired string 
	 * @param args the arguments to be replaced in the string associated to the given key. 
	 * @exception NullPointerException if <code>key</code> is <code>null</code> 
	 * @exception MissingResourceException if no string for the given key can be found 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
      catch (MissingResourceException e2)
      { 
 
        // Now we are really in trouble. 
        // very bad, definitely very bad...not going to get very far 
        throw new MissingResourceException(
          "Could not load any resource bundles.", className, "");
      } 
    } 
  } 
 
  /** 
   * Return the resource file suffic for the indicated locale 
   * For most locales, this will be based the language code.  However 
   * for Chinese, we do distinguish between Taiwan and PRC 
   * 
   * @param locale the locale 
   * @return an String suffix which canbe appended to a resource name 
   */ 
  private static final String getResourceSuffix(Locale locale)
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: toString
            ResourceBundle resource = ResourceBundle.getBundle(
                    "resources.codepoint", 
                    Locale.getDefault());
            System.err.println(resource.getString("warning"));
        } catch (MissingResourceException e) {
            System.err.println(e.toString());
        } 
 
        System.exit(1);
    } 
} 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getClassName, getKey
MissingResourceException mre = (MissingResourceException) throwable;
 
        // Get class name and key 
        msg += " - "
          + mre.getKey()
          + "\n\t" 
          + "[Class Name: " 
          + mre.getClassName()
          + "]"; 
      } 
 
      // If throwable is InvocationTargetException,  
      // then target of exception 
      else if (throwable instanceof InvocationTargetException)
      { 
        InvocationTargetException ite = (InvocationTargetException) throwable;
 
        // Get target 
        msg += " - " + ite.getTargetException().toString();
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getMessage
	 
	static { 
		try { 
			RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
		} catch (MissingResourceException e) {
			System.out.println(e.getMessage());
		} 
	} 
 
	private Messages() { 
	} 
 
	public static String getString(String key) {
		try { 
			return RESOURCE_BUNDLE.getString(key);
		} catch (MissingResourceException e) {
			return '!' + key + '!';
		} 
	} 
	 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 MissingResourceException Questions & Answers:

See Code Examples for Java 8 MissingResourceException Methods: