本文整理了Java中java.util.ResourceBundle.getKeys
方法的一些代码示例,展示了ResourceBundle.getKeys
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceBundle.getKeys
方法的具体详情如下:
包路径:java.util.ResourceBundle
类名称:ResourceBundle
方法名:getKeys
[英]Returns the names of the resources contained in this ResourceBundle.
[中]返回此ResourceBundle中包含的资源的名称。
代码示例来源:origin: prestodb/presto
private static boolean containsKey(ResourceBundle bundle, String key) {
for (Enumeration<String> en = bundle.getKeys(); en.hasMoreElements(); ) {
if (en.nextElement().equals(key)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.freemarker/freemarker
/**
* Returns true if this bundle contains no objects.
*/
@Override
public boolean isEmpty() {
return !((ResourceBundle) object).getKeys().hasMoreElements() &&
super.isEmpty();
}
代码示例来源:origin: joda-time/joda-time
private static boolean containsKey(ResourceBundle bundle, String key) {
for (Enumeration<String> en = bundle.getKeys(); en.hasMoreElements(); ) {
if (en.nextElement().equals(key)) {
return true;
}
}
return false;
}
代码示例来源:origin: JodaOrg/joda-time
private static boolean containsKey(ResourceBundle bundle, String key) {
for (Enumeration<String> en = bundle.getKeys(); en.hasMoreElements(); ) {
if (en.nextElement().equals(key)) {
return true;
}
}
return false;
}
代码示例来源: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: SonarSource/sonarqube
protected void initPlugin(String pluginKey) {
try {
String bundleKey = BUNDLE_PACKAGE + pluginKey;
ResourceBundle bundle = ResourceBundle.getBundle(bundleKey, Locale.ENGLISH, this.classloader, control);
Enumeration<String> keys = bundle.getKeys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
propertyToBundles.put(key, bundleKey);
}
} catch (MissingResourceException e) {
// ignore
}
}
代码示例来源:origin: robovm/robovm
public Set<String> keySet() {
Set<String> ret = new HashSet<String>();
Enumeration<String> keys = getKeys();
while (keys.hasMoreElements()) {
ret.add(keys.nextElement());
}
return ret;
}
代码示例来源: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: remkop/picocli
private static Set<String> keys(ResourceBundle rb) {
if (rb == null) { return Collections.emptySet(); }
Set<String> keys = new LinkedHashSet<String>();
for (Enumeration<String> k = rb.getKeys(); k.hasMoreElements(); keys.add(k.nextElement()));
return keys;
}
代码示例来源:origin: remkop/picocli
private void printResourceBundle(ResourceBundle resourceBundle, PrintWriter pw, String indent) {
if (resourceBundle == null) {
return;
}
pw.printf("%sResourceBundle:%n", indent);
indent += " ";
for (Enumeration<String> keys = resourceBundle.getKeys(); keys.hasMoreElements();) {
String key = keys.nextElement();
pw.printf("%s%s: '%s'%n", indent, key, resourceBundle.getString(key));
}
}
代码示例来源: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: org.freemarker/freemarker
@Override
protected Set keySet() {
Set set = super.keySet();
Enumeration e = ((ResourceBundle) object).getKeys();
while (e.hasMoreElements()) {
set.add(e.nextElement());
}
return set;
}
代码示例来源: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: stackoverflow.com
<%@page contentType="text/javascript; charset=UTF-8" %>
<%@ page import="java.util.ResourceBundle" %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.util.Enumeration" %>
<%@ page import="org.apache.commons.lang.StringEscapeUtils" %>
angular.module('translations', [])
.factory('translations', function(){ return {
<%
ResourceBundle labels = ResourceBundle.getBundle("language", request.getLocale());
Enumeration<String> keys = labels.getKeys();
while(keys.hasMoreElements()){
String key = keys.nextElement();
out.write("\""+key+"\":\""+StringEscapeUtils.escapeJavaScript(labels.getString(key))+"\"");
if(keys.hasMoreElements()){
out.write(",\n");
}
}
%>
}})
.filter('mpbtranslate', ['translations', function(translations) {
return function(input) {
var translation = translations[input];
return translation? translation: '???'+input+'???';
};
}]);
代码示例来源:origin: looly/hutool
/**
* ResourceBundle转化为JSONObject
*
* @param bundle ResourceBundle文件
* @return JSONObject
*/
public static JSONObject parseFromResourceBundle(ResourceBundle bundle) {
JSONObject jsonObject = new JSONObject();
Enumeration<String> keys = bundle.getKeys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
if (key != null) {
InternalJSONUtil.propertyPut(jsonObject, key, bundle.getString(key));
}
}
return jsonObject;
}
// -------------------------------------------------------------------- Pause end
代码示例来源:origin: zzz40500/GsonFormat
Enumeration<String> keys = bundle.getKeys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (key != null) {
代码示例来源:origin: looly/hutool
/**
* ResourceBundle转化为JSONObject
*
* @param bundle ResourceBundle文件
* @return JSONObject
*/
public static JSONObject parseFromResourceBundle(ResourceBundle bundle) {
JSONObject jsonObject = new JSONObject();
Enumeration<String> keys = bundle.getKeys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
if (key != null) {
InternalJSONUtil.propertyPut(jsonObject, key, bundle.getString(key));
}
}
return jsonObject;
}
// -------------------------------------------------------------------- Pause end
代码示例来源:origin: loklak/loklak_server
Enumeration<String> keys = bundle.getKeys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (key != null) {
代码示例来源:origin: primefaces/primefaces
Enumeration<String> keys = bundle.getKeys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (key != null) {
内容来源于网络,如有侵权,请联系作者删除!