Source code: com/mysql/jdbc/WatchableOutputStream.java
1 /*
2 Copyright (C) 2002-2004 MySQL AB
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of version 2 of the GNU General Public License as
6 published by the Free Software Foundation.
7
8
9 There are special exceptions to the terms and conditions of the GPL
10 as it is applied to this software. View the full text of the
11 exception exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
12 software distribution.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23 */
24 package com.mysql.jdbc;
25
26 import java.io.ByteArrayOutputStream;
27 import java.io.IOException;
28
29
30 /**
31 * A java.io.OutputStream used to write ASCII data into
32 * Blobs and Clobs
33 *
34 * @author Mark Matthews
35 */
36 class WatchableOutputStream extends ByteArrayOutputStream {
37 private OutputStreamWatcher watcher;
38
39 /**
40 * DOCUMENT ME!
41 *
42 * @param watcher DOCUMENT ME!
43 */
44 public void setWatcher(OutputStreamWatcher watcher) {
45 this.watcher = watcher;
46 }
47
48 /**
49 * @see java.io.OutputStream#close()
50 */
51 public void close() throws IOException {
52 super.close();
53
54 if (this.watcher != null) {
55 this.watcher.streamClosed(this);
56 }
57 }
58 }