View Javadoc

1   package org.astrogrid.io.trace;
2   
3   /***
4    * Insert the type's description here.
5    * Creation date: (18/01/00 13:56:10)
6    * @author:
7    */
8   
9   public class TraceOutputStream extends java.io.FilterOutputStream  {
10     private TraceWindow traceWindow = null;
11     private boolean on = false;
12     /***
13      * TraceInputStream constructor comment.
14      * @param in java.io.InputStream
15      */
16     public TraceOutputStream(java.io.OutputStream out) {
17        super(out);
18     }
19     /***
20      * Insert the method's description here.
21      * Creation date: (18/01/00 14:01:27)
22      * @return trace.TraceWindow
23      */
24     private TraceWindow getTraceWindow() {
25        
26        if (traceWindow == null) {
27           traceWindow = new TraceWindow();
28           traceWindow.setTitle(toString());
29           traceWindow.show();
30        }
31        
32        return traceWindow;
33     }
34     /***
35      * Insert the method's description here.
36      * Creation date: (18/01/00 19:47:05)
37      */
38     public void newLine() {
39        
40        if (on) getTraceWindow().newLine();
41        
42     }
43     /***
44      * Insert the method's description here.
45      * Creation date: (20/01/00 16:22:46)
46      * @param newOn boolean
47      */
48     public void setState(boolean newOn) {
49        
50        on = newOn;
51     }
52     /***
53      * Insert the method's description here.
54      * Creation date: (18/01/00 14:04:58)
55      * @param i int
56      * @exception java.io.IOException The exception description.
57      */
58     public void write(int i) throws java.io.IOException {
59        
60        super.write(i);
61        
62        if (on) {
63           if (getTraceWindow().isShowing())
64              getTraceWindow().write(i);
65           else {
66              setState(false);
67              traceWindow = null;
68           }
69        }
70        
71     }
72  }