-package uk.ac.vamsas.test.simpleclient;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-
-import uk.ac.vamsas.client.simpleclient.SessionFile;
-import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader;
-import uk.ac.vamsas.client.simpleclient.VamsasFile;
-import uk.ac.vamsas.objects.core.VAMSAS;
-import uk.ac.vamsas.objects.core.VamsasDocument;
-
-public class ArchiveStreamReader {
- /**
- * tests VamsasArchiveReader archive reader on a vamsas jar file opened as a stream
- * @param args
- */
- public static void main(String args[]) {
-
- try {
- VamsasFile av = new VamsasFile(new File(args[0]));
- VamsasArchiveReader var = new VamsasArchiveReader(av.getLock());
- VAMSAS roots[]=null;
- if (var.isValid()) {
- InputStreamReader vdoc = new InputStreamReader(var.getVamsasDocumentStream());
- VamsasDocument doc = VamsasDocument.unmarshal(vdoc);
- if (ArchiveReports.reportDocument(doc, var, true, System.out)) {
- roots = doc.getVAMSAS();
- }
- } else {
- InputStream vxmlis = var.getVamsasXmlStream();
-
- if (vxmlis!=null) { // Might be an old vamsas file.
- BufferedInputStream ixml = new BufferedInputStream(var.getVamsasXmlStream());
- InputStreamReader vxml = new InputStreamReader(ixml);
- VAMSAS root;
- // unmarshal seems to always close the stream (should check this)
- if ((root = VAMSAS.unmarshal(vxml))!=null) {
- System.out.println("Read a root.");
- roots = new VAMSAS[1];
- roots[0] = root;
- }
- }
- }
- if (!ArchiveReports.rootReport(roots, true, System.out))
- System.err.print(args[0]+" is not a valid vamsas archive.");
- } catch (Exception e) {
- e.printStackTrace(System.err);
- }
- }
-}
+/*\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.test.simpleclient;\r
+\r
+import java.io.BufferedInputStream;\r
+import java.io.File;\r
+import java.io.InputStream;\r
+import java.io.InputStreamReader;\r
+\r
+import uk.ac.vamsas.client.simpleclient.SessionFile;\r
+import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader;\r
+import uk.ac.vamsas.client.simpleclient.VamsasFile;\r
+import uk.ac.vamsas.objects.core.VAMSAS;\r
+import uk.ac.vamsas.objects.core.VamsasDocument;\r
+\r
+public class ArchiveStreamReader {\r
+ /**\r
+ * tests VamsasArchiveReader archive reader on a vamsas jar file opened as a\r
+ * stream\r
+ * \r
+ * @param args\r
+ */\r
+ public static void main(String args[]) {\r
+\r
+ try {\r
+ VamsasFile av = new VamsasFile(new File(args[0]));\r
+ VamsasArchiveReader var = new VamsasArchiveReader(av.getLock());\r
+ VAMSAS roots[] = null;\r
+ if (var.isValid()) {\r
+ InputStreamReader vdoc = new InputStreamReader(var\r
+ .getVamsasDocumentStream());\r
+ VamsasDocument doc = VamsasDocument.unmarshal(vdoc);\r
+ if (ArchiveReports.reportDocument(doc, var, true, System.out)) {\r
+ roots = doc.getVAMSAS();\r
+ }\r
+ } else {\r
+ InputStream vxmlis = var.getVamsasXmlStream();\r
+\r
+ if (vxmlis != null) { // Might be an old vamsas file.\r
+ BufferedInputStream ixml = new BufferedInputStream(var\r
+ .getVamsasXmlStream());\r
+ InputStreamReader vxml = new InputStreamReader(ixml);\r
+ VAMSAS root;\r
+ // unmarshal seems to always close the stream (should check this)\r
+ if ((root = VAMSAS.unmarshal(vxml)) != null) {\r
+ System.out.println("Read a root.");\r
+ roots = new VAMSAS[1];\r
+ roots[0] = root;\r
+ }\r
+ }\r
+ }\r
+ if (!ArchiveReports.rootReport(roots, true, System.out))\r
+ System.err.print(args[0] + " is not a valid vamsas archive.");\r
+ } catch (Exception e) {\r
+ e.printStackTrace(System.err);\r
+ }\r
+ }\r
+}\r