「Java」ResourceBundleクラスの継承サンプル

書式
public abstract class ResourceBundle
リソース・バンドルには、ロケール固有のオブジェクトが含まれます。プログラムでStringなどのロケール固有のリソースが必要なときは、
現在のユーザーのロケールに合ったリソース・バンドルからロードできます。
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
public class MyResources extends ResourceBundle {
public Object handleGetObject(String key) {
if (key.equals("okKey")) return "Ok22";
if (key.equals("cancelKey")) return "Ca33";
return null;
}
public Enumeration<String> getKeys() {
return Collections.enumeration(keySet());
}
// handleKeySet()をオーバーライド
protected Set<String> handleKeySet() {
return new HashSet<String>(Arrays.asList("okKey", "cancelKey"));
}
}
public class MyResources extends ResourceBundle { public Object handleGetObject(String key) { if (key.equals("okKey")) return "Ok22"; if (key.equals("cancelKey")) return "Ca33"; return null; } public Enumeration<String> getKeys() { return Collections.enumeration(keySet()); } // handleKeySet()をオーバーライド protected Set<String> handleKeySet() { return new HashSet<String>(Arrays.asList("okKey", "cancelKey")); } }
public class MyResources extends ResourceBundle {
     public Object handleGetObject(String key) {
         if (key.equals("okKey")) return "Ok22";
         if (key.equals("cancelKey")) return "Ca33";
         return null;
     }

     public Enumeration<String> getKeys() {
         return Collections.enumeration(keySet());
     }

     //  handleKeySet()をオーバーライド 
     protected Set<String> handleKeySet() {
         return new HashSet<String>(Arrays.asList("okKey", "cancelKey"));
     }
 }

 

Java

Posted by arkgame