-/**
- *
- */
-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;
- }
-
-}
+/*\r
+ * This file is part of the Vamsas Client version 0.1. \r
+ * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, \r
+ * Andrew Waterhouse and Dominik Lindner.\r
+ * \r
+ * Earlier versions have also been incorporated into Jalview version 2.4 \r
+ * since 2008, and TOPALi version 2 since 2007.\r
+ * \r
+ * The Vamsas Client is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU Lesser General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * The Vamsas Client is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU Lesser General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU Lesser General Public License\r
+ * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+package uk.ac.vamsas.client;\r
+\r
+import java.io.DataOutputStream;\r
+import java.io.IOException;\r
+import java.io.OutputStream;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+/**\r
+ * @author jimp\r
+ * \r
+ */\r
+public class AppDataOutputStream extends DataOutputStream {\r
+ private Log log = LogFactory.getLog(AppDataOutputStream.class);\r
+\r
+ private boolean isOpen = true;\r
+\r
+ /**\r
+ * @param out\r
+ */\r
+ public AppDataOutputStream(OutputStream out) {\r
+ super(out);\r
+ isOpen = true;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see java.io.DataOutputStream#flush()\r
+ */\r
+ public void flush() throws IOException {\r
+ if (isOpen)\r
+ super.flush();\r
+ else\r
+ log.warn("flush() called on closed AppDataOutputStream");\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see java.io.DataOutputStream#write(byte[], int, int)\r
+ */\r
+ public synchronized void write(byte[] b, int off, int len) throws IOException {\r
+ if (isOpen) {\r
+ super.write(b, off, len);\r
+ } else {\r
+ log.debug("write(b,off,len) called on closed AppDataOutputStream");\r
+ throw new IOException("Attempt to write to closed AppDataOutputStream");\r
+ }\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see java.io.DataOutputStream#write(int)\r
+ */\r
+ public synchronized void write(int b) throws IOException {\r
+ if (isOpen) {\r
+ super.write(b);\r
+ } else {\r
+ log.debug("write(b) called on closed AppDataOutputStream");\r
+ throw new IOException("Attempt to write to closed AppDataOutputStream");\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Sets an internal flag preventing further write operations to the AppData\r
+ * output stream and flushes any pending writes.\r
+ * \r
+ * @see java.io.FilterOutputStream#close()\r
+ */\r
+ public void close() throws IOException {\r
+ isOpen = false;\r
+ super.flush();\r
+ log.debug("AppDataOutputStream was closed.");\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see java.io.FilterOutputStream#write(byte[])\r
+ */\r
+ public void write(byte[] b) throws IOException {\r
+ if (isOpen) {\r
+ super.write(b);\r
+ } else {\r
+ log.debug("write(b[]) called on closed AppDataOutputStream");\r
+ throw new IOException("Attempt to write to closed AppDataOutputStream");\r
+ }\r
+ }\r
+\r
+ /**\r
+ * @return true if stream is still Open.\r
+ */\r
+ public boolean isOpen() {\r
+ return isOpen;\r
+ }\r
+\r
+}\r