1 /***
2 *
3 * The owl-s matcher software is subject to the GNU Lesser General
4 * Public License Version 2.1 (the "License"). You may not copy or use this
5 * file, in either source code or executable form, except in compliance
6 * with the License. You may obtain a copy of the License at
7 * http://www.fsf.org/licenses/lgpl.txt or http://www.opensource.org/.
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied without
11 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the License for the specific language governing rights and
13 * limitations under the License.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this distribution; if not, write to the
17 *
18 * Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330,
20 * Boston, MA 02111-1307 USA
21 *
22 * Copyright (C) 2003-2004
23 * TU Berlin, FG IVS
24 * Stefan Tang,
25 * Christoph Liebetruth,
26 * Michael C. Jaeger,
27 *
28 * More information available at http://ivs.tu-berlin.de/
29 *
30 * $Id$
31 *
32 */
33 package de.tuberlin.ivs.owl.gui;
34
35 import java.io.*;
36
37 /***
38 * This class wraps around an outputstream to which information will be
39 * written to during the loading/pasring and matching process. This output
40 * stream will be passed to the parsers and the matching algorithm, which in
41 * turn call the write method of this stream. This will send the
42 * information to the corresponding progress frame, where the information will
43 * be displayed.
44 *
45 * @author Stefan Tang (steftang@stanford.edu), Christoph Liebetruth (christophl@voelcker.com)
46 * @version 1.1
47 */
48
49 public class MessageStream extends OutputStream {
50 /***
51 * The frame the displays the loading progress.
52 */
53 LoadingServiceProgressDialog progressFrame;
54
55 /***
56 * The frame that displays the matching progress.
57 */
58 MatchingProgressDialog matchFrame;
59
60 /***
61 * The information of this output stream.
62 */
63 String message;
64
65 int mode;
66 int LOAD = 0;
67 int MATCH = 1;
68
69 /***
70 * Constructor. Initializes this stream for the loading frame.
71 * @param frame The frame the displays the loading progress.
72 */
73 public MessageStream(LoadingServiceProgressDialog frame) {
74 progressFrame = frame;
75 mode = LOAD;
76 }
77
78 /***
79 * Constructor. Initializes this stream for the matching frame.
80 * @param frame The frame that displays the matching progress.
81 */
82 public MessageStream(MatchingProgressDialog frame) {
83 matchFrame = frame;
84 mode = MATCH;
85 }
86
87 /***
88 * Write method of this stream.
89 * @param parm1 The ascii index of the character that is to be written to
90 * this stream.
91 * @throws java.io.IOException
92 */
93 public void write(int parm1) throws java.io.IOException {
94 char symbol = (char)parm1;
95 message = message + symbol;
96 }
97
98 /***
99 * Flushes the current collected output to the frames.
100 */
101 public void flush() {
102 if (message!=null) {
103 message = message.trim();
104 if (message.length() != 0) {
105 if (mode==LOAD) {
106 progressFrame.messageLabel.setText(message);
107 message = new String();
108 } else if (mode==MATCH) {
109 matchFrame.messageLabel.setText(message);
110 message = new String();
111 }
112 }
113 }
114 }
115 }