2 * This file is part of the Vamsas Client version 0.2.
\r
3 * Copyright 2010 by Jim Procter, Iain Milne, Pierre Marguerite,
\r
4 * Andrew Waterhouse and Dominik Lindner.
\r
6 * Earlier versions have also been incorporated into Jalview version 2.4
\r
7 * since 2008, and TOPALi version 2 since 2007.
\r
9 * The Vamsas Client is free software: you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation, either version 3 of the License, or
\r
12 * (at your option) any later version.
\r
14 * The Vamsas Client is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public License
\r
20 * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.
\r
22 package uk.ac.vamsas.test.simpleclient;
\r
24 import java.io.BufferedInputStream;
\r
25 import java.io.File;
\r
26 import java.io.InputStream;
\r
27 import java.io.InputStreamReader;
\r
29 import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader;
\r
30 import uk.ac.vamsas.objects.core.VAMSAS;
\r
31 import uk.ac.vamsas.objects.core.VamsasDocument;
\r
33 public class ArchiveReader {
\r
35 * tests VamsasArchiveReader archive reader on a vamsas jar file
\r
39 public static void main(String args[]) {
\r
42 File av = new File(args[0]);
\r
43 VamsasArchiveReader var = new VamsasArchiveReader(av);
\r
44 VAMSAS roots[] = null;
\r
45 if (var.isValid()) {
\r
46 InputStreamReader vdoc = new InputStreamReader(var
\r
47 .getVamsasDocumentStream());
\r
48 VamsasDocument doc = VamsasDocument.unmarshal(vdoc);
\r
49 if (ArchiveReports.reportDocument(doc, var, true, System.out)) {
\r
50 roots = doc.getVAMSAS();
\r
53 InputStream vxmlis = var.getVamsasXmlStream();
\r
55 if (vxmlis != null) { // Might be an old vamsas file.
\r
56 BufferedInputStream ixml = new BufferedInputStream(var
\r
57 .getVamsasXmlStream());
\r
58 InputStreamReader vxml = new InputStreamReader(ixml);
\r
60 // unmarshal seems to always close the stream (should check this)
\r
61 if ((root = VAMSAS.unmarshal(vxml)) != null) {
\r
62 System.out.println("Read a root.");
\r
63 roots = new VAMSAS[1];
\r
68 if (!ArchiveReports.rootReport(roots, true, System.out))
\r
69 System.err.print(args[0] + " is not a valid vamsas archive.");
\r
70 } catch (Exception e) {
\r
71 e.printStackTrace(System.err);
\r