1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SimpleFileOutProducer.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import share
.LogWriter
;
35 import java
.io
.FileWriter
;
37 public class SimpleFileOutProducer
implements LogWriter
{
40 /** initialization, here a filename might be given
43 public boolean initialize(share
.DescEntry entry
, boolean active
) {
49 public void println(String msg
) {
53 /** will mostly be used by outproducers to sum up
54 * the information, maybe write them to a db
56 public boolean summary(share
.DescEntry entry
) {
58 String outpath
= (String
) entry
.UserDefinedParams
.get("OutputPath");
60 System
.out
.println("## Parameter OutputPath isn't defined using default");
61 return summary_default(entry
);
63 String FileName
= entry
.longName
+ ".out";
64 if (!entry
.EntryType
.equals("component")) {
65 FileName
= entry
.longName
.substring(0,
66 entry
.longName
.indexOf(":")) + ".out";
68 util
.utils
.make_Directories("",outpath
);
69 File outputFile
= new File(outpath
, FileName
);
70 FileWriter out
= new FileWriter(outputFile
.toString(),true);
71 String ls
= System
.getProperty("line.separator");
72 String date
= new java
.util
.Date().toString();
73 String header
= "***** State for "+entry
.longName
+"( "+ date
+" ) ******";
75 if (entry
.hasErrorMsg
) {
76 out
.write(entry
.ErrorMsg
+ls
);
77 out
.write("Whole "+entry
.EntryType
+": "+entry
.State
+ls
);
79 out
.write("Whole "+entry
.EntryType
+": "+entry
.State
+ls
);
82 for (int i
=0;i
<header
.length();i
++) {
88 } catch (java
.io
.IOException e
) {
94 public boolean summary_default(share
.DescEntry entry
) {
95 String header
= "***** State for "+entry
.longName
+" ******";
96 System
.out
.println(header
);
97 if (entry
.hasErrorMsg
) {
98 System
.out
.println(entry
.ErrorMsg
);
99 System
.out
.println("Whole "+entry
.EntryType
+": "+entry
.State
);
101 System
.out
.println("Whole "+entry
.EntryType
+": "+entry
.State
);
103 for (int i
=0;i
<header
.length();i
++) {
104 System
.out
.print("*");
106 System
.out
.println("");
110 public Object
getWatcher() {
114 public void setWatcher(Object watcher
) {