新聞中心
ListResourceBundle

創(chuàng)新互聯(lián)主營晉源網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,app軟件開發(fā)公司,晉源h5小程序設(shè)計搭建,晉源網(wǎng)站營銷推廣歡迎晉源等地區(qū)企業(yè)咨詢
java.lang.Object
|---java.util.ResourceBundle
|---|---java.util.ListResourceBundle
public abstract class ListResourceBundle
extends ResourceBundleListResourceBundle 是 ResourceBundle 的抽象子類,它以方便且易于使用的列表管理區(qū)域設(shè)置的資源。
子類必須覆蓋 getContents 并提供一個數(shù)組,其中數(shù)組中的每個項目都是一對對象。 每對的第一個元素是鍵,它必須是一個字符串,第二個元素是與該鍵關(guān)聯(lián)的值。
以下示例顯示了具有基本名稱“MyResources”的資源束系列的兩個成員。 “MyResources”是捆綁包系列的默認(rèn)成員,“MyResources_fr”是法語成員。 這些成員基于 ListResourceBundle(相關(guān)示例顯示了如何將捆綁添加到基于屬性文件的該系列)。 此示例中的鍵采用“s1”等形式。實際的鍵完全取決于您的選擇,只要它們與您在程序中用于從包中檢索對象的鍵相同。 鍵是區(qū)分大小寫的。
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 子類同時被多個線程使用,則它的實現(xiàn)必須是線程安全的。 此類中方法的默認(rèn)實現(xiàn)是線程安全的。
嵌套類摘要
| 從類 java.util.ResourceBundle 繼承的嵌套類/接口 |
|---|
| ResourceBundle.Control |
字段摘要
| 從類 java.util.ResourceBundle 繼承的字段 |
|---|
| parent |
構(gòu)造函數(shù)摘要
| 構(gòu)造函數(shù) | 描述 |
|---|---|
| ListResourceBundle() | 唯一的構(gòu)造函數(shù)。 |
方法總結(jié)
| 修飾符和類型 | 方法 | 描述 |
|---|---|---|
| protected abstract Object | getContents() | 返回一個數(shù)組,其中每個項目都是 Object 數(shù)組中的一對對象。 |
| EnumerationString | getKeys() | 返回此 ResourceBundle 及其父捆綁包中包含的鍵的枚舉。 |
| Object | handleGetObject(String key) | 從此資源包中獲取給定鍵的對象。 |
| protected SetString | handleKeySet() | 返回僅包含在此 ResourceBundle 中的一組鍵。 |
| 從類 java.lang.Object 繼承的方法 |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 從類 java.util.ResourceBundle 繼承的方法 |
|---|
| clearCache, clearCache, containsKey, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, keySet, setParent |
構(gòu)造函數(shù)詳細(xì)信息
ListResourceBundle
public ListResourceBundle()
唯一的構(gòu)造函數(shù)。 (用于子類構(gòu)造函數(shù)的調(diào)用,通常是隱式的。)
方法詳情
handleGetObject
public final Object handleGetObject(String key)
從類復(fù)制的描述:ResourceBundle
從此資源包中獲取給定鍵的對象。 如果此資源包不包含給定鍵的對象,則返回 null。
指定者:
類 ResourceBundle 中的 handleGetObject
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| key | 所需對象的鍵 |
返回:
給定鍵的對象,或 null
getKeys
public EnumerationString getKeys()
返回此 ResourceBundle 及其父捆綁包中包含的鍵的枚舉。
指定者:
類 ResourceBundle 中的 getKeys
返回:
此 ResourceBundle 及其父捆綁包中包含的鍵的枚舉。
handleKeySet
protected SetString handleKeySet()
返回僅包含在此 ResourceBundle 中的一組鍵。
覆蓋:
類 ResourceBundle 中的 handleKeySet
返回:
僅包含在此 ResourceBundle 中的一組鍵
getContents
protected abstract Object getContents()
返回一個數(shù)組,其中每個項目都是 Object 數(shù)組中的一對對象。 每對的第一個元素是鍵,它必須是一個字符串,第二個元素是與該鍵關(guān)聯(lián)的值。
返回:
表示鍵值對的 Object 數(shù)組的數(shù)組。
網(wǎng)站名稱:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OSListResourceBundle
文章源于:http://fisionsoft.com.cn/article/cdhidps.html


咨詢
建站咨詢
