01: /**
02: *
03: */package clime.messadmin.providers.spi;
04:
05: import java.text.NumberFormat;
06:
07: import clime.messadmin.i18n.I18NSupport;
08:
09: /**
10: * Base implementation class for ServerDataProvider displaying tabular data.
11: * @author Cédrik LIME
12: */
13: public abstract class BaseTabularServerDataProvider extends
14: BaseTabularDataProvider implements ServerDataProvider {
15:
16: /**
17: *
18: */
19: public BaseTabularServerDataProvider() {
20: super ();
21: }
22:
23: /**
24: * @return application-specific data labels for given HttpSession, or null if it can be determined
25: */
26: public abstract String[] getServerTabularDataLabels();
27:
28: /**
29: * @return application-specific data values for given HttpSession, or null if it can be determined
30: */
31: public abstract Object[][] getServerTabularData();
32:
33: protected String getTableCaption(String[] labels, Object[][] values) {
34: NumberFormat numberFormatter = NumberFormat
35: .getNumberInstance(I18NSupport.getAdminLocale());
36: return "" + numberFormatter.format(values.length)
37: + " server-specific attributes";
38: }
39:
40: /**
41: * {@inheritDoc}
42: */
43: public String getXHTMLServerData() {
44: try {
45: String[] labels = getServerTabularDataLabels();
46: Object[][] values = getServerTabularData();
47: return buildXHTML(labels, values,
48: "extraServerAttributesTable-"
49: + getClass().getName(), getTableCaption(
50: labels, values));
51: } catch (RuntimeException rte) {
52: return "Error in " + this .getClass().getName() + ": " + rte;
53: }
54: }
55:
56: }
|