Source Code Cross Referenced for A_CmsReport.java in  » Content-Management-System » opencms » org » opencms » report » 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 » Content Management System » opencms » org.opencms.report 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/report/A_CmsReport.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:41 $
004:         * Version: $Revision: 1.25 $
005:         *
006:         * This library is part of OpenCms -
007:         * the Open Source Content Management System
008:         *
009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010:         *
011:         * This library is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public
013:         * License as published by the Free Software Foundation; either
014:         * version 2.1 of the License, or (at your option) any later version.
015:         *
016:         * This library is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019:         * Lesser General Public License for more details.
020:         *
021:         * For further information about Alkacon Software GmbH, please see the
022:         * company website: http://www.alkacon.com
023:         *
024:         * For further information about OpenCms, please see the
025:         * project website: http://www.opencms.org
026:         * 
027:         * You should have received a copy of the GNU Lesser General Public
028:         * License along with this library; if not, write to the Free Software
029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030:         */
031:
032:        package org.opencms.report;
033:
034:        import org.opencms.file.CmsRequestContext;
035:        import org.opencms.i18n.CmsMessageContainer;
036:        import org.opencms.i18n.CmsMessages;
037:        import org.opencms.util.CmsStringUtil;
038:
039:        import java.util.ArrayList;
040:        import java.util.List;
041:        import java.util.Locale;
042:
043:        /**
044:         * Base report class.<p> 
045:         * 
046:         * @author Alexander Kandzior   
047:         * @author Thomas Weckert  
048:         * @author Jan Baudisch 
049:         * @author Peter Bonrad
050:         * 
051:         * @version $Revision: 1.25 $ 
052:         * 
053:         * @since 6.0.0 
054:         */
055:        public abstract class A_CmsReport implements  I_CmsReport {
056:
057:            /** Contains all error messages generated by the report. */
058:            private List m_errors = new ArrayList();
059:
060:            /** The locale this report is written in. */
061:            private Locale m_locale;
062:
063:            /** The default report message bundle. */
064:            private CmsMessages m_messages;
065:
066:            /** The original site root of the user who started this report. */
067:            private String m_siteRoot;
068:
069:            /** Runtime of the report. */
070:            private long m_starttime;
071:
072:            /** Contains all warning messages generated by the report. */
073:            private List m_warnings = new ArrayList();
074:
075:            /**
076:             * @see org.opencms.report.I_CmsReport#addError(java.lang.Object)
077:             */
078:            public void addError(Object obj) {
079:
080:                m_errors.add(obj);
081:            }
082:
083:            /**
084:             * @see org.opencms.report.I_CmsReport#addWarning(java.lang.Object)
085:             */
086:            public void addWarning(Object obj) {
087:
088:                m_warnings.add(obj);
089:            }
090:
091:            /**
092:             * @see org.opencms.report.I_CmsReport#formatRuntime()
093:             */
094:            public String formatRuntime() {
095:
096:                return CmsStringUtil.formatRuntime(getRuntime());
097:            }
098:
099:            /**
100:             * @see org.opencms.report.I_CmsReport#getErrors()
101:             */
102:            public List getErrors() {
103:
104:                return m_errors;
105:            }
106:
107:            /**
108:             * @see org.opencms.report.I_CmsReport#getLocale()
109:             */
110:            public Locale getLocale() {
111:
112:                return m_locale;
113:            }
114:
115:            /**
116:             * @see org.opencms.report.I_CmsReport#getRuntime()
117:             */
118:            public long getRuntime() {
119:
120:                return System.currentTimeMillis() - m_starttime;
121:            }
122:
123:            /**
124:             * Returns the original site root of the user who started this report,
125:             * or <code>null</code> if the original site root has not been set.<p>
126:             * 
127:             * @return the original site root of the user who started this report
128:             */
129:            public String getSiteRoot() {
130:
131:                return m_siteRoot;
132:            }
133:
134:            /**
135:             * @see org.opencms.report.I_CmsReport#getWarnings()
136:             */
137:            public List getWarnings() {
138:
139:                return m_warnings;
140:            }
141:
142:            /**
143:             * @see org.opencms.report.I_CmsReport#hasError()
144:             */
145:            public boolean hasError() {
146:
147:                return (m_errors.size() > 0);
148:            }
149:
150:            /**
151:             * @see org.opencms.report.I_CmsReport#hasWarning()
152:             */
153:            public boolean hasWarning() {
154:
155:                return (m_warnings.size() > 0);
156:            }
157:
158:            /**
159:             * @see org.opencms.report.I_CmsReport#print(org.opencms.i18n.CmsMessageContainer)
160:             */
161:            public void print(CmsMessageContainer container) {
162:
163:                print(container.key(getLocale()), FORMAT_DEFAULT);
164:            }
165:
166:            /**
167:             * @see org.opencms.report.I_CmsReport#print(org.opencms.i18n.CmsMessageContainer, int)
168:             */
169:            public void print(CmsMessageContainer container, int format) {
170:
171:                print(container.key(getLocale()), format);
172:            }
173:
174:            /**
175:             * @see org.opencms.report.I_CmsReport#println(org.opencms.i18n.CmsMessageContainer)
176:             */
177:            public void println(CmsMessageContainer container) {
178:
179:                println(container.key(getLocale()), FORMAT_DEFAULT);
180:            }
181:
182:            /**
183:             * @see org.opencms.report.I_CmsReport#println(org.opencms.i18n.CmsMessageContainer, int)
184:             */
185:            public void println(CmsMessageContainer container, int format) {
186:
187:                println(container.key(getLocale()), format);
188:            }
189:
190:            /**
191:             * @see org.opencms.report.I_CmsReport#printMessageWithParam(org.opencms.i18n.CmsMessageContainer,Object)
192:             */
193:            public void printMessageWithParam(CmsMessageContainer container,
194:                    Object param) {
195:
196:                print(container, I_CmsReport.FORMAT_NOTE);
197:                print(Messages.get().container(Messages.RPT_ARGUMENT_1, param));
198:                print(Messages.get().container(Messages.RPT_DOTS_0));
199:            }
200:
201:            /**
202:             * @see org.opencms.report.I_CmsReport#printMessageWithParam(int,int,org.opencms.i18n.CmsMessageContainer,Object)
203:             */
204:            public void printMessageWithParam(int m, int n,
205:                    CmsMessageContainer container, Object param) {
206:
207:                print(Messages.get().container(Messages.RPT_SUCCESSION_2,
208:                        String.valueOf(m), String.valueOf(n)),
209:                        I_CmsReport.FORMAT_NOTE);
210:                printMessageWithParam(container, param);
211:            }
212:
213:            /**
214:             * Removes the report site root prefix from the absolute path in the resource name,
215:             * that is adjusts the resource name for the report site root.<p> 
216:             * 
217:             * If the site root for this report has not been set,
218:             * or the resource name does not start with the report site root,
219:             * the name it is left untouched.<p>
220:             * 
221:             * @param resourcename the resource name (full path)
222:             * 
223:             * @return the resource name adjusted for the report site root
224:             * 
225:             * @see CmsRequestContext#removeSiteRoot(String)
226:             */
227:            public String removeSiteRoot(String resourcename) {
228:
229:                if (m_siteRoot == null) {
230:                    // site root has not been set
231:                    return resourcename;
232:                }
233:
234:                String siteRoot = CmsRequestContext.getAdjustedSiteRoot(
235:                        m_siteRoot, resourcename);
236:                if ((siteRoot.equals(m_siteRoot))
237:                        && resourcename.startsWith(siteRoot)) {
238:                    resourcename = resourcename.substring(siteRoot.length());
239:                }
240:                return resourcename;
241:            }
242:
243:            /**
244:             * @see org.opencms.report.I_CmsReport#resetRuntime()
245:             */
246:            public void resetRuntime() {
247:
248:                m_starttime = System.currentTimeMillis();
249:            }
250:
251:            /**
252:             * Returns the default report message bundle.<p>
253:             * 
254:             * @return the default report message bundle
255:             */
256:            protected CmsMessages getMessages() {
257:
258:                return m_messages;
259:            }
260:
261:            /**
262:             * Initializes some member variables for this report.<p>
263:             * 
264:             * @param locale the locale for this report
265:             * @param siteRoot the site root of the user who started this report (may be <code>null</code>)
266:             */
267:            protected void init(Locale locale, String siteRoot) {
268:
269:                m_starttime = System.currentTimeMillis();
270:                m_locale = locale;
271:                m_siteRoot = siteRoot;
272:                m_messages = Messages.get().getBundle(locale);
273:            }
274:
275:            /**
276:             * Prints a String to the report.<p>
277:             *
278:             * @param value the String to add
279:             */
280:            protected void print(String value) {
281:
282:                print(value, FORMAT_DEFAULT);
283:            }
284:
285:            /**
286:             * Prints a String to the report, using the indicated formatting.<p>
287:             * 
288:             * Use the contants starting with <code>FORMAT</code> from this interface
289:             * to indicate which formatting to use.<p>
290:             *
291:             * @param value the message container to add
292:             * @param format the formatting to use for the output
293:             */
294:            protected abstract void print(String value, int format);
295:
296:            /**
297:             * Prints a String with line break to the report.<p>
298:             * 
299:             * @param value the message container to add
300:             */
301:            protected void println(String value) {
302:
303:                println(value, FORMAT_DEFAULT);
304:            }
305:
306:            /**
307:             * Prints a String with line break to the report, using the indicated formatting.<p>
308:             * 
309:             * Use the contants starting with <code>C_FORMAT</code> from this interface
310:             * to indicate which formatting to use.<p>
311:             *
312:             * @param value the String to add
313:             * @param format the formatting to use for the output
314:             */
315:            protected void println(String value, int format) {
316:
317:                print(value, format);
318:                println();
319:            }
320:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.