Source Code Cross Referenced for BaseTabularDataProvider.java in  » Profiler » MessAdmin » clime » messadmin » providers » spi » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Profiler » MessAdmin » clime.messadmin.providers.spi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package clime.messadmin.providers.spi;
004:
005:        import java.util.ResourceBundle;
006:
007:        import javax.servlet.ServletContext;
008:        import javax.servlet.http.HttpSession;
009:
010:        import clime.messadmin.i18n.I18NSupport;
011:        import clime.messadmin.model.Server;
012:
013:        /**
014:         * Base implementation class for DataProvider displaying tabular data.
015:         * @author Cédrik LIME
016:         */
017:        public abstract class BaseTabularDataProvider {
018:
019:            /**
020:             * 
021:             */
022:            public BaseTabularDataProvider() {
023:                super ();
024:            }
025:
026:            /**
027:             * Convenience method for i18n
028:             * @since 4.1
029:             */
030:            protected ClassLoader getClassLoader(final HttpSession session) {
031:                return Server.getInstance().getApplication(
032:                        session.getServletContext()).getApplicationInfo()
033:                        .getClassLoader();
034:            }
035:
036:            /**
037:             * Convenience method for i18n
038:             * @since 4.1
039:             */
040:            protected ClassLoader getClassLoader(final ServletContext context) {
041:                return Server.getInstance().getApplication(context)
042:                        .getApplicationInfo().getClassLoader();
043:            }
044:
045:            /**
046:             * Convenience method for i18n
047:             * @since 4.1
048:             */
049:            protected ResourceBundle getResourceBundle(String baseName,
050:                    ClassLoader cl) {
051:                return I18NSupport.getResourceBundle(baseName, cl);
052:            }
053:
054:            /**
055:             * Convenience method for i18n
056:             * @since 4.1
057:             */
058:            protected String getLocalizedMessage(String baseName,
059:                    ClassLoader cl, String key) {
060:                return I18NSupport.getLocalizedMessage(baseName, cl, key);
061:            }
062:
063:            /**
064:             * Convenience method for i18n
065:             * @since 4.1
066:             */
067:            protected String getLocalizedMessage(String baseName,
068:                    ClassLoader cl, String key, Object[] args) {
069:                return I18NSupport.getLocalizedMessage(baseName, cl, key, args);
070:            }
071:
072:            //	/**
073:            //	 * @param object
074:            //	 * @return specific data labels for given object, or null if it can be determined
075:            //	 */
076:            //	public abstract String[] getTabularDataLabels(final Object object);
077:            //	/**
078:            //	 * @param object
079:            //	 * @return specific data values for given object, or null if it can be determined
080:            //	 */
081:            //	public abstract Object[][] getTabularData(final Object object);
082:            //
083:            //	protected abstract String getTableCaption(String[] labels, Object[][] data);
084:            //
085:            //	protected String getXHTMLData(Object object) {
086:            //		try {
087:            //			String[] labels = getTabularDataLabels(object);
088:            //			Object[][] values = getTabularData(object);
089:            //			return buildXHTML(labels, values, tableId, getTableCaption(labels, values));
090:            //		} catch (RuntimeException rte) {
091:            //			return "Error in " + this.getClass().getName() + ": " + rte;
092:            //		}
093:            //	}
094:
095:            protected String buildXHTML(String[] labels, Object[][] values,
096:                    String tableId, String tableCaption) {
097:                if (labels == null || values == null || values.length == 0) {
098:                    return "";
099:                }
100:                StringBuffer buffer = new StringBuffer(128 + 16 * labels.length
101:                        + 16 * values.length * labels.length);
102:                buffer
103:                        .append("<table id=\"")
104:                        .append(tableId)
105:                        .append(
106:                                "\" class=\"strippable\" style=\"text-align: left;\" border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n");
107:                appendCaption(buffer, tableCaption);
108:                appendHeader(buffer, labels);
109:                appendFooter(buffer, labels);
110:                appendBody(buffer, values);
111:                buffer.append("</table>\n");
112:                return buffer.toString();
113:            }
114:
115:            protected void appendCaption(StringBuffer buffer,
116:                    String tableCaption) {
117:                buffer.append("<caption style=\"font-variant: small-caps;\">")
118:                        .append(tableCaption).append("</caption>\n");
119:            }
120:
121:            protected void appendHeader(StringBuffer buffer, String[] labels) {
122:                buffer.append("<thead><tr>\n");
123:                for (int i = 0; i < labels.length; ++i) {
124:                    String label = labels[i];
125:                    buffer.append("<th>");
126:                    appendHeaderLabel(buffer, label);
127:                    buffer.append("</th>");
128:                }
129:                buffer.append("\n</tr></thead>\n");
130:            }
131:
132:            protected void appendHeaderLabel(StringBuffer buffer, String label) {
133:                if (label != null) {
134:                    buffer.append(label);
135:                }
136:            }
137:
138:            protected void appendBody(StringBuffer buffer, Object[][] values) {
139:                buffer.append("<tbody>\n");
140:                for (int i = 0; i < values.length; ++i) {
141:                    Object[] row = values[i];
142:                    appendRow(buffer, row);
143:                }
144:                buffer.append("</tbody>\n");
145:            }
146:
147:            protected void appendRow(StringBuffer buffer, Object[] row) {
148:                buffer.append("<tr>\n");
149:                for (int j = 0; j < row.length; ++j) {
150:                    Object value = row[j];
151:                    buffer.append("<td>");
152:                    appendValue(buffer, value);
153:                    buffer.append("</td>");
154:                }
155:                buffer.append("</tr>\n");
156:            }
157:
158:            protected void appendValue(StringBuffer buffer, Object value) {
159:                if (value != null) {
160:                    //			buffer.append("<span title=\"").append(value.getClass()).append("\">");
161:                    buffer.append(value);
162:                    //			buffer.append("</span>");
163:                }
164:            }
165:
166:            protected void appendFooter(StringBuffer buffer, String[] labels) {
167:                //		buffer.append("<tfoot><tr>\n");
168:                //		for (int i = 0; i < labels.length; ++i) {
169:                //			String label = labels[i];
170:                //			buffer.append("<th>");
171:                //			appendFooterLabel(buffer, label);
172:                //			buffer.append("</th>");
173:                //		}
174:                //		buffer.append("\n</tr></tfoot>\n");
175:            }
176:
177:            protected void appendFooterLabel(StringBuffer buffer, String label) {
178:                appendHeaderLabel(buffer, label);
179:            }
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.