01: /*
02: * NullOutputStream.java February 2001
03: *
04: * Copyright (C) 2001, Niall Gallagher <niallg@users.sf.net>
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General
16: * Public License along with this library; if not, write to the
17: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18: * Boston, MA 02111-1307 USA
19: */
20:
21: package simple.http;
22:
23: import java.io.OutputStream;
24: import java.io.IOException;
25:
26: /**
27: * The purpose of this <code>OutputStream</code> is to provide an
28: * <code>OutputStream</code> that does nothing. If a stream is
29: * needed for some task but the stream is not writing to anything
30: * the <code>NullOutputStream</code> is used.
31: * <p>
32: * This acts similar to a <code>MonitoredOutputStream</code> in
33: * that it notifies an <code>OutputMonitor</code>. However, this
34: * will not wait for an I/O event before notification, once this
35: * has been created a <code>notifyFinished</code> is issued.
36: *
37: * @author Niall Gallagher
38: */
39: class NullOutputStream extends OutputStream {
40:
41: /**
42: * Constructor for the <code>NullOutputStream</code>. This is
43: * used to provide a <code>notifyFinished</code> to this given
44: * <code>OutputMonitor</code> so signify output is finished.
45: *
46: * @param out the stream that that data is to be written to
47: * @param mon the monitor that will be notified of I/O events
48: */
49: public NullOutputStream(OutputStream out, OutputMonitor mon) {
50: mon.notifyFinished(out);
51: }
52:
53: /**
54: * This is an empty implementation of <code>write</code>. This
55: * is the only abstract of the <code>OutputStream</code> object
56: * and is delegated to by other <code>write</code> methods.
57: *
58: * @param octet this is the byte that is intended to be written
59: *
60: * @exception IOException this exception will never be thrown
61: */
62: public void write(int octet) throws IOException {
63: }
64: }
|