X-Git-Url: http://source.jalview.org/gitweb/?p=vamsas.git;a=blobdiff_plain;f=src%2Fuk%2Fac%2Fvamsas%2Fclient%2FAppDataOutputStream.java;h=eaaa7ef8a05c869b79fe7864f38e08221237e753;hp=5eb1ff3fbe812d49ee69100c6701159c7dd4af62;hb=844ccad5a3fcbedec17b2af66d460f31abc7cff1;hpb=6f33f705957d674dc2ab6c994a6ea87f7a91f40f diff --git a/src/uk/ac/vamsas/client/AppDataOutputStream.java b/src/uk/ac/vamsas/client/AppDataOutputStream.java index 5eb1ff3..eaaa7ef 100644 --- a/src/uk/ac/vamsas/client/AppDataOutputStream.java +++ b/src/uk/ac/vamsas/client/AppDataOutputStream.java @@ -1,86 +1,121 @@ -/** - * - */ -package uk.ac.vamsas.client; - -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * @author jimp - * - */ -public class AppDataOutputStream extends DataOutputStream { - private Log log = LogFactory.getLog(AppDataOutputStream.class); - private boolean isOpen=true; - /** - * @param out - */ - public AppDataOutputStream(OutputStream out) { - super(out); - isOpen=true; - } - /* (non-Javadoc) - * @see java.io.DataOutputStream#flush() - */ - public void flush() throws IOException { - if (isOpen) - super.flush(); - else - log.warn("flush() called on closed AppDataOutputStream"); - } - /* (non-Javadoc) - * @see java.io.DataOutputStream#write(byte[], int, int) - */ - public synchronized void write(byte[] b, int off, int len) throws IOException { - if (isOpen) { - super.write(b, off, len); - } else { - log.debug("write(b,off,len) called on closed AppDataOutputStream"); - throw new IOException("Attempt to write to closed AppDataOutputStream"); - } - } - /* (non-Javadoc) - * @see java.io.DataOutputStream#write(int) - */ - public synchronized void write(int b) throws IOException { - if (isOpen) { - super.write(b); - } else { - log.debug("write(b) called on closed AppDataOutputStream"); - throw new IOException("Attempt to write to closed AppDataOutputStream"); - } - } - /** - * Sets an internal flag preventing further write operations - * to the AppData output stream and flushes any pending writes. - * @see java.io.FilterOutputStream#close() - */ - public void close() throws IOException { - isOpen=false; - super.flush(); - log.debug("AppDataOutputStream was closed."); - } - /* (non-Javadoc) - * @see java.io.FilterOutputStream#write(byte[]) - */ - public void write(byte[] b) throws IOException { - if (isOpen) { - super.write(b); - } else { - log.debug("write(b[]) called on closed AppDataOutputStream"); - throw new IOException("Attempt to write to closed AppDataOutputStream"); - } - } - /** - * @return true if stream is still Open. - */ - public boolean isOpen() { - return isOpen; - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author jimp + * + */ +public class AppDataOutputStream extends DataOutputStream { + private Log log = LogFactory.getLog(AppDataOutputStream.class); + + private boolean isOpen = true; + + /** + * @param out + */ + public AppDataOutputStream(OutputStream out) { + super(out); + isOpen = true; + } + + /* + * (non-Javadoc) + * + * @see java.io.DataOutputStream#flush() + */ + public void flush() throws IOException { + if (isOpen) + super.flush(); + else + log.warn("flush() called on closed AppDataOutputStream"); + } + + /* + * (non-Javadoc) + * + * @see java.io.DataOutputStream#write(byte[], int, int) + */ + public synchronized void write(byte[] b, int off, int len) throws IOException { + if (isOpen) { + super.write(b, off, len); + } else { + log.debug("write(b,off,len) called on closed AppDataOutputStream"); + throw new IOException("Attempt to write to closed AppDataOutputStream"); + } + } + + /* + * (non-Javadoc) + * + * @see java.io.DataOutputStream#write(int) + */ + public synchronized void write(int b) throws IOException { + if (isOpen) { + super.write(b); + } else { + log.debug("write(b) called on closed AppDataOutputStream"); + throw new IOException("Attempt to write to closed AppDataOutputStream"); + } + } + + /** + * Sets an internal flag preventing further write operations to the AppData + * output stream and flushes any pending writes. + * + * @see java.io.FilterOutputStream#close() + */ + public void close() throws IOException { + isOpen = false; + super.flush(); + log.debug("AppDataOutputStream was closed."); + } + + /* + * (non-Javadoc) + * + * @see java.io.FilterOutputStream#write(byte[]) + */ + public void write(byte[] b) throws IOException { + if (isOpen) { + super.write(b); + } else { + log.debug("write(b[]) called on closed AppDataOutputStream"); + throw new IOException("Attempt to write to closed AppDataOutputStream"); + } + } + + /** + * @return true if stream is still Open. + */ + public boolean isOpen() { + return isOpen; + } + +}