View Javadoc
1   package au.gov.amsa.ais;
2   
3   import java.util.ResourceBundle;
4   
5   /**
6    * Handles resource lookup.
7    * 
8    * @author dxm
9    * 
10   */
11  public class Internationalization {
12  
13  	private static final String BUNDLE_NAME = "au.gov.amsa.ais.messages";
14  
15  	private static ResourceBundle bundle = null;
16  
17  	/**
18  	 * Constructor.
19  	 */
20  	private Internationalization() {
21  	}
22  
23  	/**
24  	 * Calls the private constructor to ensure 100% cobertura coverage.
25  	 */
26  	static void forTestCoverageOnly() {
27  		new Internationalization();
28  	}
29  
30  	/**
31  	 * Returns the relevant {@link ResourceBundle} for the current locale.
32  	 * 
33  	 * @return
34  	 */
35  	private static synchronized ResourceBundle getBundle() {
36  		if (bundle == null)
37  			bundle = ResourceBundle.getBundle(BUNDLE_NAME);
38  		return bundle;
39  
40  	}
41  
42  	/**
43  	 * Returns the value from the current {@link ResourceBundle} for the given
44  	 * key.
45  	 * 
46  	 * @param key
47  	 * @return
48  	 */
49  	public static String getString(String key) {
50  
51  		return getBundle().getString(key);
52  
53  	}
54  }