2 * This file is part of the Vamsas Client version 0.2.
\r
3 * Copyright 2010 by Jim Procter, Iain Milne, Pierre Marguerite,
\r
4 * Andrew Waterhouse and Dominik Lindner.
\r
6 * Earlier versions have also been incorporated into Jalview version 2.4
\r
7 * since 2008, and TOPALi version 2 since 2007.
\r
9 * The Vamsas Client is free software: you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation, either version 3 of the License, or
\r
12 * (at your option) any later version.
\r
14 * The Vamsas Client is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public License
\r
20 * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.
\r
22 package uk.ac.vamsas.client;
\r
24 import java.io.DataOutputStream;
\r
25 import java.io.IOException;
\r
26 import java.io.OutputStream;
\r
28 import org.apache.commons.logging.Log;
\r
29 import org.apache.commons.logging.LogFactory;
\r
35 public class AppDataOutputStream extends DataOutputStream {
\r
36 private Log log = LogFactory.getLog(AppDataOutputStream.class);
\r
38 private boolean isOpen = true;
\r
43 public AppDataOutputStream(OutputStream out) {
\r
51 * @see java.io.DataOutputStream#flush()
\r
53 public void flush() throws IOException {
\r
57 log.warn("flush() called on closed AppDataOutputStream");
\r
63 * @see java.io.DataOutputStream#write(byte[], int, int)
\r
65 public synchronized void write(byte[] b, int off, int len) throws IOException {
\r
67 super.write(b, off, len);
\r
69 log.debug("write(b,off,len) called on closed AppDataOutputStream");
\r
70 throw new IOException("Attempt to write to closed AppDataOutputStream");
\r
77 * @see java.io.DataOutputStream#write(int)
\r
79 public synchronized void write(int b) throws IOException {
\r
83 log.debug("write(b) called on closed AppDataOutputStream");
\r
84 throw new IOException("Attempt to write to closed AppDataOutputStream");
\r
89 * Sets an internal flag preventing further write operations to the AppData
\r
90 * output stream and flushes any pending writes.
\r
92 * @see java.io.FilterOutputStream#close()
\r
94 public void close() throws IOException {
\r
97 log.debug("AppDataOutputStream was closed.");
\r
103 * @see java.io.FilterOutputStream#write(byte[])
\r
105 public void write(byte[] b) throws IOException {
\r
109 log.debug("write(b[]) called on closed AppDataOutputStream");
\r
110 throw new IOException("Attempt to write to closed AppDataOutputStream");
\r
115 * @return true if stream is still Open.
\r
117 public boolean isOpen() {
\r