source: trunk/autoquest-jfcmonitor/src/main/java/de/ugoe/cs/autoquest/jfcmonitor/JFCMonitorOutputWriter.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 2.0 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.jfcmonitor;
16
17import java.io.IOException;
18import java.io.OutputStreamWriter;
19
20import de.ugoe.cs.util.StringTools;
21/**
22 * <p>
23 * This class is used as wrapper for writers for JFCMonitor logs.
24 * </p>
25 * @author Fabian Glaser
26 * @version 1.0
27 *
28 */
29public class JFCMonitorOutputWriter{
30         /**
31     * <p>
32     * Writer for logging events.
33     * </p>
34     */
35    final private OutputStreamWriter outputWriter;
36   
37    /**
38     * <p>
39     * Constructor. Creates a new JFCMonitorOutputWriter with a given {@link OutputStreamWriter}, where the
40     * monitored information is written to. It writes log header information on construction to
41     * given OutputStreamWriter. 
42     * </p>
43     *
44     * @param outputWriter
45     *            writer for the logged information
46     */
47   
48    public JFCMonitorOutputWriter(OutputStreamWriter outputWriter) {
49        this.outputWriter = outputWriter;
50        write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE);
51        write("<sessions>" + StringTools.ENDLINE);
52    }
53   
54    /**
55     * <p>
56     * Writes a string to the internal OutputStreamWriter.
57     * </p>
58     * @param str
59     */
60    public synchronized void write(String str){
61        try {
62                        outputWriter.write(str);
63                        outputWriter.flush();
64                } catch (IOException e) {
65                System.err.println("JFCMONITOR -- Failure writing to log: " + e.getMessage());
66                }
67    }
68}
Note: See TracBrowser for help on using the repository browser.