KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > report > CmsShellReport


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/report/CmsShellReport.java,v $
3  * Date : $Date: 2006/10/04 07:35:21 $
4  * Version: $Revision: 1.23 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.report;
33
34 import java.util.Locale JavaDoc;
35
36 /**
37  * Report class used for the shell.<p>
38  *
39  * It stores nothing. It just prints everthing to <code>System.out</code><p>.
40  *
41  * @author Alexander Kandzior
42  * @author Jan Baudisch
43  *
44  * @version $Revision: 1.23 $
45  *
46  * @since 6.0.0
47  */

48 public class CmsShellReport extends A_CmsReport {
49
50     /**
51      * Constructs a new report using the provided locale for the output language.<p>
52      *
53      * @param locale the locale to use for the output language
54      */

55     public CmsShellReport(Locale JavaDoc locale) {
56
57         init(locale, null);
58     }
59
60     /**
61      * @see org.opencms.report.I_CmsReport#getReportUpdate()
62      */

63     public synchronized String JavaDoc getReportUpdate() {
64
65         return "";
66     }
67
68     /**
69      * @see org.opencms.report.A_CmsReport#print(java.lang.String, int)
70      */

71     public synchronized void print(String JavaDoc value, int format) {
72
73         StringBuffer JavaDoc buf;
74         switch (format) {
75             case FORMAT_HEADLINE:
76                 buf = new StringBuffer JavaDoc();
77                 buf.append("------ ");
78                 buf.append(value);
79                 System.out.print(buf);
80                 break;
81             case FORMAT_WARNING:
82                 buf = new StringBuffer JavaDoc();
83                 buf.append("!!! ");
84                 buf.append(value);
85                 System.out.print(buf);
86                 addWarning(value);
87                 break;
88             case FORMAT_ERROR:
89                 buf = new StringBuffer JavaDoc();
90                 buf.append("!!! ");
91                 buf.append(value);
92                 System.out.print(buf);
93                 addError(value);
94                 break;
95             case FORMAT_NOTE:
96             case FORMAT_OK:
97             case FORMAT_DEFAULT:
98             default:
99                 System.out.print(value);
100         }
101     }
102
103     /**
104      * @see org.opencms.report.I_CmsReport#println()
105      */

106     public synchronized void println() {
107
108         System.out.println();
109     }
110
111     /**
112      * @see org.opencms.report.I_CmsReport#println(java.lang.Throwable)
113      */

114     public synchronized void println(Throwable JavaDoc t) {
115
116         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
117         buf.append(getMessages().key(Messages.RPT_EXCEPTION_0));
118         buf.append(t.getMessage());
119         this.println(new String JavaDoc(buf), FORMAT_ERROR);
120         t.printStackTrace(System.out);
121     }
122 }
Popular Tags