01: /**
02: *
03: */package clime.messadmin.providers.userdata;
04:
05: import java.text.NumberFormat;
06: import java.util.ArrayList;
07: import java.util.Iterator;
08: import java.util.List;
09: import java.util.Map;
10:
11: import clime.messadmin.i18n.I18NSupport;
12: import clime.messadmin.model.Server;
13: import clime.messadmin.providers.spi.BaseTabularServerDataProvider;
14: import clime.messadmin.providers.spi.ServerDataProvider;
15:
16: /**
17: * @author Cédrik LIME
18: */
19: public class SystemPropertiesProvider extends
20: BaseTabularServerDataProvider implements ServerDataProvider {
21: private static final String BUNDLE_NAME = SystemPropertiesProvider.class
22: .getName();
23:
24: /**
25: *
26: */
27: public SystemPropertiesProvider() {
28: super ();
29: }
30:
31: /**
32: * {@inheritDoc}
33: */
34: public String[] getServerTabularDataLabels() {
35: String key = I18NSupport.getLocalizedMessage(BUNDLE_NAME, null,
36: "label.key");//$NON-NLS-1$
37: String value = I18NSupport.getLocalizedMessage(BUNDLE_NAME,
38: null, "label.value");//$NON-NLS-1$
39: return new String[] { key, value };
40: }
41:
42: /**
43: * {@inheritDoc}
44: */
45: protected String getTableCaption(String[] labels, Object[][] values) {
46: NumberFormat numberFormatter = NumberFormat
47: .getNumberInstance(I18NSupport.getAdminLocale());
48: String caption = I18NSupport
49: .getLocalizedMessage(
50: BUNDLE_NAME,
51: null,
52: "table.caption", new Object[] { numberFormatter.format(values.length) });//$NON-NLS-1$
53: return caption;
54: }
55:
56: /**
57: * {@inheritDoc}
58: */
59: public Object[][] getServerTabularData() {
60: Map sysProps = Server.getInstance().getServerInfo()
61: .getSystemProperties();
62: List resultList = new ArrayList(sysProps.size());
63: Iterator iter = sysProps.entrySet().iterator();
64: while (iter.hasNext()) {
65: Map.Entry prop = (Map.Entry) iter.next();
66: resultList.add(new Object[] { prop.getKey(),
67: prop.getValue() });
68: }
69: Object[][] result = new Object[resultList.size()][];
70: return (Object[][]) resultList.toArray(result);
71: }
72:
73: /**
74: * {@inheritDoc}
75: */
76: public String getServerDataTitle() {
77: return I18NSupport.getLocalizedMessage(BUNDLE_NAME, null,
78: "title");//$NON-NLS-1$
79: }
80:
81: /**
82: * {@inheritDoc}
83: */
84: public int getPriority() {
85: return 10;
86: }
87:
88: }
|