當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceBundle.keySet方法代碼示例

本文整理匯總了Java中java.util.ResourceBundle.keySet方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceBundle.keySet方法的具體用法?Java ResourceBundle.keySet怎麽用?Java ResourceBundle.keySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.ResourceBundle的用法示例。


在下文中一共展示了ResourceBundle.keySet方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getKey

import java.util.ResourceBundle; //導入方法依賴的package包/類
private static String getKey(String item, Locale locale, String baseName) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle(baseName, locale, new XMLResourceBundleControl());

    String itemTyped = correctItemName(item);
    String bestMatch = null;
    int diffScore = Integer.MAX_VALUE;

    for (String key : resourceBundle.keySet()) {
        String itemName = correctItemName(resourceBundle.getString(key));
        if (itemTyped.equals(itemName)) {
            return key;
        } else {
            int score = compareFuzzy(itemName, itemTyped);
            if (score < diffScore) {
                diffScore = score;
                bestMatch = key;
            }
        }
    }
    if (scoreIsGood(itemTyped, diffScore)) {
        return bestMatch;
    } else {
        throw new RuntimeException(String.format("Can't find %s in %s %s", item, baseName, locale.toLanguageTag()));
    }
}
 
開發者ID:BlackCraze,項目名稱:GameResourceBot,代碼行數:26,代碼來源:Resource.java

示例2: getMessagesValues

import java.util.ResourceBundle; //導入方法依賴的package包/類
public static List<String> getMessagesValues(Locale locale, String keyPrefix) {
    ResourceBundle rb = loadLocalResourceBundle(locale);
    List<String> res = new ArrayList<>();

    for (String key : rb.keySet()) {
        if (key.startsWith(keyPrefix)) {
            res.add(key);
        }
    }

    Collections.sort(res);

    return res;
}
 
開發者ID:intranda,項目名稱:goobi-viewer-connector,代碼行數:15,代碼來源:MessageResourceBundle.java

示例3: getKeysFromFile

import java.util.ResourceBundle; //導入方法依賴的package包/類
private Set<String> getKeysFromFile(
        Map<String, ResourceBundle> defaultMessageProperties,
        Map<String, Properties> localizedProperties, String locale,
        String sheetName) {
    if (BaseBean.LABEL_USERINTERFACE_TRANSLARIONS.equals(sheetName)) {
        ResourceBundle bundle = defaultMessageProperties.get(locale);
        if (bundle != null) {
            return bundle.keySet();
        }
    } else {
        return loadKeySetFromProperties(localizedProperties, locale
                + StandardLanguage.COLUMN_HEADING_SUFFIX);
    }
    return new HashSet<String>();
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:16,代碼來源:ManageLanguageCtrl.java

示例4: logEnvironment

import java.util.ResourceBundle; //導入方法依賴的package包/類
private static void logEnvironment(Logger logger) {
	ResourceBundle res = ResourceBundle.getBundle("fr.inra.maiage.bibliome.alvisnlp.core.app.cli.LogEnvironment");
	for (String var : res.keySet()) {
		String value = System.getenv(var);
		if (value == null)
			continue;
		String label = res.getString(var);
		logger.config(label + ": " + value);
	}
}
 
開發者ID:Bibliome,項目名稱:alvisnlp,代碼行數:11,代碼來源:AbstractAlvisNLP.java

示例5: service

import java.util.ResourceBundle; //導入方法依賴的package包/類
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
	final String path = req.getPathInfo();

	if( path.equals("/refresh") )
	{
		languageService.refreshBundles();

		resp.setContentType("text/plain");
		ServletOutputStream out = resp.getOutputStream();
		out.print("Bundles refreshed");
		out.close();
		return;
	}

	Matcher m = Pattern.compile("^/([a-zA-Z_]*)/([a-zA-Z-]+)\\.properties$").matcher(path);
	if( !m.matches() || m.groupCount() != 2 )
	{

		throw new ServletException("Bundle Group name is invalid: " + path);
	}

	final ResourceBundle resourceBundle = languageService.getResourceBundle(LocaleUtils.parseLocale(m.group(1)),
		m.group(2));

	final Properties text = new Properties();
	for( String key : resourceBundle.keySet() )
	{
		text.put(key, resourceBundle.getString(key));
	}

	resp.setContentType("text/plain");
	resp.setHeader("Content-Disposition", "inline; filename=" + path + ".properties");

	text.store(resp.getOutputStream(), null);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:38,代碼來源:LanguageServlet.java

示例6: testReadResource1

import java.util.ResourceBundle; //導入方法依賴的package包/類
public void testReadResource1() {
    ResourceBundle bundle = ResourceBundle.getBundle("sun.security.util.Resources");
    Set<String> strings = bundle.keySet();
    System.out.println(strings);
    Enumeration<String> keys = bundle.getKeys();
    int i = 0;
    while (keys.hasMoreElements()) {
        String s = keys.nextElement();
        System.out.println(i + ": " + s);
        i++;
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:13,代碼來源:KeyStoreTest.java

示例7: loadPropertiesFromBundle

import java.util.ResourceBundle; //導入方法依賴的package包/類
/**
 * Loads properties based on a resource bundle name.
 * 
 * @param bundleName the resource bundle name.
 * 
 * @return loaded properties from the named resource bundle.
 */
public static Properties loadPropertiesFromBundle(String bundleName) {
   ResourceBundle rb = ResourceBundle.getBundle(bundleName);
   Properties properties = new Properties();
   for (String key : rb.keySet()) {
      String value = rb.getString(key);
      properties.put(key, value);
   }
   return properties;
}
 
開發者ID:mqsysadmin,項目名稱:dpdirect,代碼行數:17,代碼來源:FileUtils.java

示例8: handleKeySet

import java.util.ResourceBundle; //導入方法依賴的package包/類
@Override
protected Set<String> handleKeySet() {
    if (keys == null) {
        ResourceBundle info = getBreakIteratorInfo();
        Set<String> k = info.keySet();
        k.removeAll(NON_DATA_KEYS);
        synchronized (this) {
            if (keys == null) {
                keys = k;
            }
        }
    }
    return keys;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:BreakIteratorResourceBundle.java

示例9: displayValues

import java.util.ResourceBundle; //導入方法依賴的package包/類
public void displayValues(ResourceBundle bundle) {
    for (String k : bundle.keySet()) {
        String v = bundle.getString(k);
        System.out.println("i18n: " + k + "=" + v);
    }
}
 
開發者ID:openaudible,項目名稱:openaudible,代碼行數:7,代碼來源:Translate.java


注:本文中的java.util.ResourceBundle.keySet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。