01: /**
02: *
03: */package clime.messadmin.providers.userdata;
04:
05: import java.text.NumberFormat;
06: import java.util.Enumeration;
07: import java.util.LinkedList;
08: import java.util.List;
09:
10: import javax.servlet.ServletContext;
11:
12: import clime.messadmin.i18n.I18NSupport;
13: import clime.messadmin.providers.spi.ApplicationDataProvider;
14: import clime.messadmin.providers.spi.BaseTabularApplicationDataProvider;
15:
16: /**
17: * @author Cédrik LIME
18: */
19: public class ServletContextInitParametersProvider extends
20: BaseTabularApplicationDataProvider implements
21: ApplicationDataProvider {
22: private static final String BUNDLE_NAME = ServletContextInitParametersProvider.class
23: .getName();
24:
25: /**
26: *
27: */
28: public ServletContextInitParametersProvider() {
29: super ();
30: }
31:
32: /** {@inheritDoc} */
33: protected String getTableCaption(String[] labels, Object[][] values) {
34: NumberFormat numberFormatter = NumberFormat
35: .getNumberInstance(I18NSupport.getAdminLocale());
36: String caption = I18NSupport
37: .getLocalizedMessage(
38: BUNDLE_NAME,
39: null,
40: "table.caption", new Object[] { numberFormatter.format(values.length) });//$NON-NLS-1$
41: return caption;
42: }
43:
44: /**
45: * {@inheritDoc}
46: */
47: public String[] getApplicationTabularDataLabels(
48: ServletContext context) {
49: String name = I18NSupport.getLocalizedMessage(BUNDLE_NAME,
50: null, "label.name");//$NON-NLS-1$
51: String value = I18NSupport.getLocalizedMessage(BUNDLE_NAME,
52: null, "label.value");//$NON-NLS-1$
53: return new String[] { name, value };
54: }
55:
56: /**
57: * {@inheritDoc}
58: */
59: public Object[][] getApplicationTabularData(ServletContext context) {
60: List initParams = new LinkedList();
61: Enumeration enumeration = context.getInitParameterNames();
62: while (enumeration.hasMoreElements()) {
63: String name = (String) enumeration.nextElement();
64: String value = context.getInitParameter(name);
65: initParams.add(new String[] { name, value });
66: }
67: Object[][] result = (Object[][]) initParams
68: .toArray(new String[initParams.size()][]);
69: return result;
70: }
71:
72: /**
73: * {@inheritDoc}
74: */
75: public String getApplicationDataTitle(ServletContext context) {
76: return I18NSupport.getLocalizedMessage(BUNDLE_NAME, null,
77: "title");//$NON-NLS-1$
78: }
79:
80: /**
81: * {@inheritDoc}
82: */
83: public int getPriority() {
84: return 0;
85: }
86:
87: }
|