public abstract class ListResourceBundle extends ResourceBundle
ListResourceBundle是
ResourceBundle管理资源在一个方便和易于使用的列表区域抽象类。看到有关通用资源束的更多信息
ResourceBundle。
子类必须重写getContents并提供一个数组,在数组中的每个元素是一个对对象。每对中的第一个元素是关键,它必须是一个String,第二元是该键所关联的值。
以下example显示两个成员的基名称“MyResources”资源束的家庭。”MyResources”是捆绑家庭的默认成员,和“myresources_fr”是法国的成员。这些成员是基于ListResourceBundle(相关example显示你如何添加一个束于这个家庭,是基于一个属性文件)。在这个例子中的关键是形成“S1”等实际键是完全取决于你的选择,只要是你在你的程序中使用的从束检索对象相同的键。键是区分大小写的。
public class MyResources extends ListResourceBundle {
protected Object[][] getContents() {
return new Object[][] {
// LOCALIZE THIS
{"s1", "The disk \"{1}\" contains {0}."}, // MessageFormat pattern
{"s2", "1"}, // location of {0} in pattern
{"s3", "My Disk"}, // sample disk name
{"s4", "no files"}, // first ChoiceFormat choice
{"s5", "one file"}, // second ChoiceFormat choice
{"s6", "{0,number} files"}, // third ChoiceFormat choice
{"s7", "3 Mar 96"}, // sample date
{"s8", new Dimension(1,5)} // real object, not just string
// END OF MATERIAL TO LOCALIZE
};
}
}
public class MyResources_fr extends ListResourceBundle {
protected Object[][] getContents() {
return new Object[][] {
// LOCALIZE THIS
{"s1", "Le disque \"{1}\" {0}."}, // MessageFormat pattern
{"s2", "1"}, // location of {0} in pattern
{"s3", "Mon disque"}, // sample disk name
{"s4", "ne contient pas de fichiers"}, // first ChoiceFormat choice
{"s5", "contient un fichier"}, // second ChoiceFormat choice
{"s6", "contient {0,number} fichiers"}, // third ChoiceFormat choice
{"s7", "3 mars 1996"}, // sample date
{"s8", new Dimension(1,3)} // real object, not just string
// END OF MATERIAL TO LOCALIZE
};
}
}
一个ListResourceBundle子类的实现必须是同时被多个线程使用是线程安全的。在这个类中的方法的默认实现是线程安全的。
ResourceBundle,
PropertyResourceBundle
ResourceBundle.Controlparent| Constructor and Description |
|---|
ListResourceBundle()
唯一的构造函数。
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract Object[][] |
getContents()
返回一个数组,其中每一项是一个
Object阵列对对象。
|
Enumeration<String> |
getKeys()
返回包含在这
ResourceBundle及其父束的关键一
Enumeration。
|
Object |
handleGetObject(String key)
从这个资源包中获取给定密钥的对象。
|
protected Set<String> |
handleKeySet()
返回一个
Set的钥匙只有在这
ResourceBundle。
|
clearCache, clearCache, containsKey, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, keySet, setParentpublic final Object handleGetObject(String key)
ResourceBundle
handleGetObject 方法重写,继承类
ResourceBundle
key -预期目标的关键
public Enumeration<String> getKeys()
ResourceBundle及其父束的关键一
Enumeration。
getKeys 方法重写,继承类
ResourceBundle
ResourceBundle及其父母管束的
Enumeration的钥匙。
ResourceBundle.keySet()
protected Set<String> handleKeySet()
Set的钥匙只有在这
ResourceBundle。
handleKeySet 方法重写,继承类
ResourceBundle
ResourceBundle包含
Set的钥匙
ResourceBundle.keySet()
protected abstract Object[][] getContents()
Object阵列对对象。每对中的第一个元素是关键,它必须是一个
String,第二元是该键所关联的值。查看详细的类描述。
Object数组代表一个键值对数组。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.