added for completeness, but may not be necessary.
authorjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 20 Mar 2006 15:58:47 +0000 (15:58 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 20 Mar 2006 15:58:47 +0000 (15:58 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@191 be28352e-c001-0410-b1a7-c7978e42abec

src/org/vamsas/client/simpleclient/AppDataInputStream.java [new file with mode: 0644]

diff --git a/src/org/vamsas/client/simpleclient/AppDataInputStream.java b/src/org/vamsas/client/simpleclient/AppDataInputStream.java
new file mode 100644 (file)
index 0000000..0785ed6
--- /dev/null
@@ -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;
+  }
+  
+}