1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.util;
21
22 import javax.faces.application.Application;
23 import javax.faces.context.FacesContext;
24 import java.util.ResourceBundle;
25
26 public class ResourceUtils {
27
28 public static final String TOBAGO_RESOURCE_BUNDLE = "tobagoResourceBundle";
29
30 public static String getString(final String key) {
31 final FacesContext facesContext = FacesContext.getCurrentInstance();
32 final Application application = facesContext.getApplication();
33 final ResourceBundle resourceBundle = application.getResourceBundle(facesContext, TOBAGO_RESOURCE_BUNDLE);
34 return resourceBundle.getString(key);
35 }
36
37 public static String getString(final FacesContext facesContext, final String key) {
38 return facesContext.getApplication().getResourceBundle(facesContext, TOBAGO_RESOURCE_BUNDLE).getString(key);
39 }
40
41 public static String getString(final FacesContext facesContext, final Application application, final String key) {
42 return application.getResourceBundle(facesContext, TOBAGO_RESOURCE_BUNDLE).getString(key);
43 }
44
45 public static String getString(final String bundle, final String key) {
46 final FacesContext facesContext = FacesContext.getCurrentInstance();
47 return facesContext.getApplication().getResourceBundle(facesContext, bundle).getString(key);
48 }
49
50 public static String getString(final FacesContext facesContext, final String bundle, final String key) {
51 return facesContext.getApplication().getResourceBundle(facesContext, bundle).getString(key);
52 }
53
54 public static String getString(
55 final FacesContext facesContext, final Application application, final String bundle, final String key) {
56 return application.getResourceBundle(facesContext, bundle).getString(key);
57 }
58 }