1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 import java
.io
.PrintWriter
;
30 import java
.io
.StringWriter
;
33 * Write all logs into a java.io.PrintWriter, i.e. a StringBuffer.
34 * Log is gathered there.
36 public class InternalLogWriter
extends PrintWriter
37 implements share
.LogWriter
{
40 /** write all output to a StringBuffer **/
41 static StringWriter writer
= new StringWriter();
46 public InternalLogWriter() {
47 super(new PrintWriter(writer
));
53 * @param entry The description entry.
54 * @param active Logging is active.
55 * @return True, if initialize worked.
57 public boolean initialize(share
.DescEntry entry
, boolean active
) {
63 * Method to print a line that is added to the StringBuffer.
64 * @param msg The message that is printed.
66 public void println(String msg
) {
72 * Method to print to the StringBuffer.
73 * @param msg The message that is printed.
75 public void print(String msg
) {
82 * Is used to sum up the information.
83 * The summary is also added to the StringBuffer.
84 * @param entry The description entry.
85 * @return True, if a summary could be created.
87 public boolean summary(share
.DescEntry entry
) {
89 String header
= "***** State for "+entry
.longName
+" ******";
91 if (entry
.hasErrorMsg
) {
92 println(entry
.ErrorMsg
);
93 println("Whole "+entry
.EntryType
+": "+entry
.State
);
95 println("Whole "+entry
.EntryType
+": "+entry
.State
);
97 for (int i
=0;i
<header
.length();i
++) {
105 * Return all the written stuff.
106 * @return All that was written to the StringBuffer with the
107 * 'println()', 'print()' and 'summarize()' methods.
108 * The StringBuffer is emptied afterwards.
110 public String
getLog() {
111 String message
= writer
.getBuffer().toString();
112 writer
= new StringWriter();
116 public Object
getWatcher() {
120 public void setWatcher(Object watcher
) {