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