View Javadoc
1 /* ------------------------------------------------------------------- 2 * Java source file for the class ResourceBundleUtil 3 * 4 * Copyright (c), 2002, Masahiro Takatsuka. 5 * All Rights Researved. 6 * 7 * Original Author: Masahiro Takatsuka (masa@jbeans.net) 8 * $Author: takatsukam $ 9 * 10 * $Date: 2003/07/25 04:51:47 $ 11 * 12 * $Id: ResourceBundleUtil.java,v 1.1.1.1 2003/07/25 04:51:47 takatsukam Exp $ 13 * 14 * Reference: Document no: 15 * ___ ___ 16 * 17 * To Do: 18 * ___ 19 * 20 ------------------------------------------------------------------- */ 21 22 /* --------------------------- Package ---------------------------- */ 23 package net.jbeans.util; 24 25 /* ------------------ Import classes (packages) ------------------- *//package-summary/html">color="#329900"> ------------------ Import classes (packages) ------------------- *//package-summary.html">color="#329900">/* ------------------ Import classes (packages) ------------------- *//package-summary.html">color="#329900"> ------------------ Import classes (packages) ------------------- */ 26 import java.util.*; 27 28 /*==================================================================== 29 Implementation of class ResourceBundleUtil 30 ====================================================================*/ 31 /*** 32 * generally describe ResourceBundleUtil in here 33 * 34 * @version $Revision: 1.1.1.1 $ 35 * @author Masahiro Takatsuka (masa@jbeans.net) 36 */ 37 38 public final class ResourceBundleUtil { 39 private static ResourceBundle sBundle; 40 private static Map sBundles; 41 42 private ResourceBundleUtil() { 43 super(); 44 } 45 46 public final static String getResourceValue(ClassLoader classLoader, String resource, String key){ 47 if (sBundles == null) { 48 sBundles = Collections.synchronizedMap(new HashMap()); 49 } 50 sBundle = (ResourceBundle) sBundles.get(resource); 51 if (sBundle == null) { 52 try{ 53 Locale locale = Locale.getDefault(); 54 sBundle = ResourceBundle.getBundle(resource, locale, classLoader); 55 sBundles.put(resource, sBundle); 56 } catch(MissingResourceException e){ 57 e.printStackTrace(); 58 //System.exit(0); 59 } 60 } 61 62 String value = ""; 63 try{ 64 value = (String) sBundle.getObject(key); 65 }catch (MissingResourceException e){ 66 e.printStackTrace(); 67 System.out.println("ResourceBundleUtil.getResourceValue:Could not find " + key); 68 } 69 return value; 70 } 71 72 public final static String getResourceValue(String resource, String key){ 73 return getResourceValue(ResourceBundleUtil.class.getClassLoader(), 74 resource, key); 75 } 76 } // ResourceBundleUtil

This page was automatically generated by Maven