import org.exolab.castor.xml.*;\r
import jalview.binding.*;\r
import jalview.schemes.*;\r
+import jalview.util.jarInputStreamProvider;\r
\r
/**\r
* DOCUMENT ME!\r
* @param file\r
* DOCUMENT ME!\r
*/\r
- public AlignFrame LoadJalviewAlign(final String file)\r
+ public AlignFrame LoadJalviewAlign(final jarInputStreamProvider jprovider)\r
{\r
-\r
+ final String file = jprovider.getFilename();\r
jalview.gui.AlignFrame af = null;\r
\r
try\r
{\r
- // UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING\r
- URL url = null;\r
-\r
- if (file.startsWith("http://"))\r
- {\r
- url = new URL(file);\r
- }\r
-\r
JarInputStream jin = null;\r
JarEntry jarentry = null;\r
int entryCount = 1;\r
\r
do\r
{\r
- if (url != null)\r
- {\r
- jin = new JarInputStream(url.openStream());\r
- }\r
- else\r
- {\r
- jin = new JarInputStream(new FileInputStream(file));\r
- }\r
+ jin = jprovider.getJarInputStream();\r
\r
for (int i = 0; i < entryCount; i++)\r
{\r
--- /dev/null
+package jalview.util;\r
+\r
+import java.io.IOException;\r
+import java.util.jar.JarInputStream;\r
+\r
+/**\r
+ * input stream provider interface to be implemented\r
+ * by any non-file or URL datasources so that all Jar entries\r
+ * can be read from the datasource by repeatedly re-opening the JarInputStream.\r
+ * \r
+ * This is a workaround necessary because castor's unmarshaller will close the input stream after an unmarshalling session, which normally closes the whole Jar input stream, not just the current JarEntry's stream. \r
+ */\r
+public interface jarInputStreamProvider {\r
+ /**\r
+ * @return properly initialized jar input stream\r
+ */\r
+ JarInputStream getJarInputStream() throws IOException;\r
+ /**\r
+ * \r
+ * @return human readable name for datasource used when reporting any problems with it\r
+ */\r
+ String getFilename();\r
+}
\ No newline at end of file