本文整理了Java中java.util.ResourceBundle.getObject
方法的一些代码示例,展示了ResourceBundle.getObject
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceBundle.getObject
方法的具体详情如下:
包路径:java.util.ResourceBundle
类名称:ResourceBundle
方法名:getObject
[英]Returns the named resource from this ResourceBundle. If the resource cannot be found in this bundle, it falls back to the parent bundle (if it's not null) by calling the #handleGetObject method. If the resource still can't be found it throws a MissingResourceException.
[中]返回此ResourceBundle中的命名资源。如果在这个捆绑包中找不到资源,它会通过调用#handleGetObject方法返回父捆绑包(如果它不为null)。如果仍然找不到资源,它会抛出MissingResourceException。
代码示例来源:origin: lets-blade/blade
public Object getObject(String key) {
return resourceBundle.getObject(key);
}
public boolean containsKey(String key) {
代码示例来源:origin: lets-blade/blade
public Object getObject(String key) {
return resourceBundle.getObject(key);
}
public boolean containsKey(String key) {
代码示例来源:origin: org.netbeans.api/org-openide-util
protected @Override Object handleGetObject(String key) throws MissingResourceException {
try {
return sub1.getObject(key);
} catch (MissingResourceException mre) {
// Ignore exception, and...
return sub2.getObject(key);
}
}
}
代码示例来源:origin: robovm/robovm
/**
* Returns the named resource from this {@code ResourceBundle}.
*
* @param key
* the name of the resource.
* @return the resource string array.
* @throws MissingResourceException
* if the resource is not found.
* @throws ClassCastException
* if the resource found is not an array of strings.
* @see #getObject(String)
*/
public final String[] getStringArray(String key) {
return (String[]) getObject(key);
}
代码示例来源:origin: robovm/robovm
/**
* Returns the named string resource from this {@code ResourceBundle}.
*
* @param key
* the name of the resource.
* @return the resource string.
* @throws MissingResourceException
* if the resource is not found.
* @throws ClassCastException
* if the resource found is not a string.
* @see #getObject(String)
*/
public final String getString(String key) {
return (String) getObject(key);
}
代码示例来源:origin: SonarSource/sonarqube
@Override
protected Object handleGetObject(String key) {
for (ResourceBundle b : bundles) {
try {
return b.getObject(key);
} catch (MissingResourceException mre) {
// iterate
}
}
throw new MissingResourceException(null, null, key);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Register bean definitions contained in a ResourceBundle.
* <p>Similar syntax as for a Map. This method is useful to enable
* standard Java internationalization support.
* @param rb the ResourceBundle to load from
* @param prefix a filter within the keys in the map: e.g. 'beans.'
* (can be empty or {@code null})
* @return the number of bean definitions found
* @throws BeanDefinitionStoreException in case of loading or parsing errors
*/
public int registerBeanDefinitions(ResourceBundle rb, @Nullable String prefix) throws BeanDefinitionStoreException {
// Simply create a map and call overloaded method.
Map<String, Object> map = new HashMap<>();
Enumeration<String> keys = rb.getKeys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
map.put(key, rb.getObject(key));
}
return registerBeanDefinitions(map, prefix);
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Creates a new HashMap using data copied from a ResourceBundle.
*
* @param resourceBundle the resource bundle to convert, may not be null
* @return the hashmap containing the data
* @throws NullPointerException if the bundle is null
*/
public static Map toMap(final ResourceBundle resourceBundle) {
Enumeration enumeration = resourceBundle.getKeys();
Map map = new HashMap();
while (enumeration.hasMoreElements()) {
String key = (String) enumeration.nextElement();
Object value = resourceBundle.getObject(key);
map.put(key, value);
}
return map;
}
代码示例来源:origin: wildfly/wildfly
/**
* Creates a new HashMap using data copied from a ResourceBundle.
*
* @param resourceBundle the resource bundle to convert, may not be null
* @return the hashmap containing the data
* @throws NullPointerException if the bundle is null
*/
public static Map toMap(final ResourceBundle resourceBundle) {
Enumeration enumeration = resourceBundle.getKeys();
Map map = new HashMap();
while (enumeration.hasMoreElements()) {
String key = (String) enumeration.nextElement();
Object value = resourceBundle.getObject(key);
map.put(key, value);
}
return map;
}
代码示例来源:origin: pmd/pmd
/**
* Convert <code>resourceBundle</code> to usable {@link Properties}.
*
* @param resourceBundle
* ResourceBundle
* @return Properties
*/
public static Properties getResourceBundleAsProperties(ResourceBundle resourceBundle) {
Properties properties = new Properties();
for (String key : resourceBundle.keySet()) {
properties.put(key, resourceBundle.getObject(key));
}
return properties;
}
代码示例来源:origin: org.apache.commons/commons-collections4
/**
* Creates a new HashMap using data copied from a ResourceBundle.
*
* @param resourceBundle the resource bundle to convert, may not be null
* @return the hashmap containing the data
* @throws NullPointerException if the bundle is null
*/
public static Map<String, Object> toMap(final ResourceBundle resourceBundle) {
final Enumeration<String> enumeration = resourceBundle.getKeys();
final Map<String, Object> map = new HashMap<>();
while (enumeration.hasMoreElements()) {
final String key = enumeration.nextElement();
final Object value = resourceBundle.getObject(key);
map.put(key, value);
}
return map;
}
代码示例来源:origin: org.springframework/spring-beans
/**
* Register bean definitions contained in a ResourceBundle.
* <p>Similar syntax as for a Map. This method is useful to enable
* standard Java internationalization support.
* @param rb the ResourceBundle to load from
* @param prefix a filter within the keys in the map: e.g. 'beans.'
* (can be empty or {@code null})
* @return the number of bean definitions found
* @throws BeanDefinitionStoreException in case of loading or parsing errors
*/
public int registerBeanDefinitions(ResourceBundle rb, @Nullable String prefix) throws BeanDefinitionStoreException {
// Simply create a map and call overloaded method.
Map<String, Object> map = new HashMap<>();
Enumeration<String> keys = rb.getKeys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
map.put(key, rb.getObject(key));
}
return registerBeanDefinitions(map, prefix);
}
代码示例来源:origin: javax.el/javax.el-api
if (property != null) {
try {
return ((ResourceBundle) base).getObject(property
.toString());
} catch (MissingResourceException e) {
代码示例来源:origin: stackoverflow.com
return parent.getObject(key);
代码示例来源:origin: org.freemarker/freemarker
try {
if (!it.hasNext()) {
return wrap(((ResourceBundle) object).getObject(key));
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
return NbBundle.getBundle(arr[0]).getObject(arr[1]);
代码示例来源:origin: org.freemarker/freemarker
/**
* Overridden to invoke the getObject method of the resource bundle.
*/
@Override
protected TemplateModel invokeGenericGet(Map keyMap, Class clazz, String key)
throws TemplateModelException {
try {
return wrap(((ResourceBundle) object).getObject(key));
} catch (MissingResourceException e) {
throw new _TemplateModelException(e,
"No ", new _DelayedJQuote(key), " key in the ResourceBundle. "
+ "Note that conforming to the ResourceBundle Java API, this is an error and not just "
+ "a missing sub-variable (a null).");
}
}
代码示例来源:origin: ron190/jsql-injection
/**
* Return the text corresponding to a i18n key in the properties.
* @param key a i18n key in the properties
* @return text corresponding to the key
*/
public static String valueByKey(String key) {
return (String) I18n.localeDefault.getObject(key);
}
代码示例来源:origin: javaee/glassfish
@Override
protected Object handleGetObject(String key) {
if (contextBundle != null) {
return contextBundle.getObject(key);
}
return null;
}
代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel
@Override
protected Object handleGetObject(String key) {
if (key == null) {
throw new NullPointerException();
}
for (ResourceBundle resourceBundle : _resourceBundles) {
if (!resourceBundle.containsKey(key)) {
continue;
}
try {
return resourceBundle.getObject(key);
}
catch (MissingResourceException mre) {
}
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!