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