|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.util.ResourceBundle
java.util.ListResourceBundle
public abstract class ListResourceBundle
ListResourceBundle 是 ResourceBundle 的一个抽象类,用于管理方便而又易于使用的列表中的语言环境资源。有关资源包的常规信息,请参阅 ResourceBundle。
子类必须重写 getContents 并提供一个数组,其中数组中的每个项都是一个对象对。每对的第一个元素是键,该键必须是一个 String,并且第二个元素是和该键相关联的值。
下面的示例显示了具有基本名称 "MyResources" 的资源包系列的两个成员。"MyResources" 是资源包系列的默认成员,"MyResources_fr" 是 French 成员。这些成员是基于 ListResourceBundle(一个相关的示例显示了如何把一个资源包添加到基于属性文件的此系列)。此示例中的键形式为 "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
};
}
}
ResourceBundle,
PropertyResourceBundle| 嵌套类摘要 |
|---|
| 从类 java.util.ResourceBundle 继承的嵌套类/接口 |
|---|
ResourceBundle.Control |
| 字段摘要 |
|---|
| 从类 java.util.ResourceBundle 继承的字段 |
|---|
parent |
| 构造方法摘要 | |
|---|---|
ListResourceBundle()
单独的构造方法。 |
|
| 方法摘要 | |
|---|---|
protected abstract Object[][] |
getContents()
返回一个数组,其中 Object 数组中的每个项都是一个对象对。 |
Enumeration<String> |
getKeys()
返回包含在此 ResourceBundle 及其父包中的键的 Enumeration。 |
Object |
handleGetObject(String key)
从此资源包中获取给定键的对象。 |
protected Set<String> |
handleKeySet()
返回只 包含在此 ResourceBundle 中的键的 Set。 |
| 从类 java.util.ResourceBundle 继承的方法 |
|---|
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, keySet, setParent |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public ListResourceBundle()
| 方法详细信息 |
|---|
public final Object handleGetObject(String key)
ResourceBundle 复制的描述
ResourceBundle 中的 handleGetObjectkey - 所需对象的键
public Enumeration<String> getKeys()
ResourceBundle 及其父包中的键的 Enumeration。
ResourceBundle 中的 getKeysResourceBundle 及其父包中的键的 Enumeration。ResourceBundle.keySet()protected Set<String> handleKeySet()
ResourceBundle 中的键的 Set。
ResourceBundle 中的 handleKeySetResourceBundle 中的键的 SetResourceBundle.keySet()protected abstract Object[][] getContents()
Object 数组中的每个项都是一个对象对。每对的第一个元素是键,它必须是 String,第二个元素是与该键关联的值。有关详细信息,请参阅类描述。
Object 数组
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。