From: jprocter Date: Mon, 20 Mar 2006 15:58:47 +0000 (+0000) Subject: added for completeness, but may not be necessary. X-Git-Tag: Release_0.2~329 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4fed8739a653eb797d852295d9a1aadde4fccf6a;p=vamsas.git added for completeness, but may not be necessary. git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@191 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/org/vamsas/client/simpleclient/AppDataInputStream.java b/src/org/vamsas/client/simpleclient/AppDataInputStream.java new file mode 100644 index 0000000..0785ed6 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/AppDataInputStream.java @@ -0,0 +1,53 @@ +/** + * + */ +package org.vamsas.client.simpleclient; + +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.jar.JarInputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author jimp + * LATER: this may not be a necessary or useful class to return from IClientAppdata get*InputStream() methods + */ +public class AppDataInputStream extends DataInputStream implements DataInput { + private Log log = LogFactory.getLog(AppDataInputStream.class); + private boolean isOpen = false; + /** + * Wrapper for writing to/from AppData Entries in a Vamsas Document. + */ + public AppDataInputStream(InputStream inputstream) { + super(inputstream); + isOpen=true; + } + + /* (non-Javadoc) + * @see java.io.FilterInputStream#close() + */ + public void close() throws IOException { + if (!isOpen) { + log.debug("close() called on closed AppDataInputStream."); + // throw new IOException("Attempt to close an already closed AppDataInputStream"); + } else { + isOpen=false; + } + } + + /** + * Will return zero if stream has been closed. + * @see java.io.FilterInputStream#available() + */ + public int available() throws IOException { + if (isOpen) + return super.available(); + else + return 0; + } + +}