Update ooo320-m1
[ooovba.git] / qadevOOo / runner / stats / SimpleFileOutProducer.java
blobb5e8f27cda3bab932d0ebae8819d718763c76dc0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SimpleFileOutProducer.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package stats;
33 import share.LogWriter;
34 import java.io.File;
35 import java.io.FileWriter;
37 public class SimpleFileOutProducer implements LogWriter {
40 /** initialization, here a filename might be given
41 * or a dbUrL
43 public boolean initialize(share.DescEntry entry, boolean active) {
44 return true;
47 /** Method to print
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) {
57 try {
58 String outpath = (String) entry.UserDefinedParams.get("OutputPath");
59 if (outpath==null) {
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 +" ) ******";
74 out.write(header+ls);
75 if (entry.hasErrorMsg) {
76 out.write(entry.ErrorMsg+ls);
77 out.write("Whole "+entry.EntryType+": "+entry.State+ls);
78 } else {
79 out.write("Whole "+entry.EntryType+": "+entry.State+ls);
81 String bottom="";
82 for (int i=0;i<header.length();i++) {
83 bottom += "*";
85 out.write(bottom+ls);
86 out.write(""+ls);
87 out.close();
88 } catch (java.io.IOException e) {
91 return true;
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);
100 } else {
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("");
107 return true;
110 public Object getWatcher() {
111 return null;
114 public void setWatcher(Object watcher) {