1 package org.devaki.nextobjects.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.Writer;
22 import org.devaki.nextobjects.ui.components.JTextAreaOutputStream;
23 /***
24 * LogWriter has the ability to forward the log4j output to a LogFrame class
25 * Inspired by Thomas Weber from OpenAI, http://openai.sourceforge.net/
26 */
27 public class LogWriter extends Writer
28 {
29 /*** Ref to the LogFrame instance that should receive the output */
30 private JTextAreaOutputStream jTextAreaOutputStream;
31 /***
32 * Constructs a new LogWriter and registers the LogFrame
33 * @param pjTextAreaOutputStream the textarea
34 */
35 public LogWriter(final JTextAreaOutputStream pjTextAreaOutputStream)
36 {
37 this.jTextAreaOutputStream = pjTextAreaOutputStream;
38 }
39 /***
40 * Common flux write method
41 *
42 * @param parm1 char array to be written
43 * @param parm2 start offset to be written
44 * @param parm3 number of char to write
45 * @throws java.io.IOException a standard io exception
46 */
47 public final void write(
48 final char[] parm1,
49 final int parm2,
50 final int parm3)
51 throws java.io.IOException
52 {
53 write(String.valueOf(parm1, parm2, parm3));
54 }
55 /***
56 * Mandatory Method declaration
57 * @throws java.io.IOException a standard io exception
58 */
59 public void flush() throws java.io.IOException
60 {
61 }
62 /***
63 * Mandatory close Method declaration
64 *
65 * @throws java.io.IOException a standard io exception
66 */
67 public void close() throws java.io.IOException
68 {
69 }
70 /***
71 * Append 'text' to the LogFrame textarea
72 * @param text the text
73 */
74 public final void write(final String text)
75 {
76 jTextAreaOutputStream.write(text);
77 }
78 }