X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fuk%2Fac%2Fvamsas%2Ftest%2Fsimpleclient%2FArchiveReader.java;h=a00be7274fcd646bb7d319ea1530f250dd898d1b;hb=844ccad5a3fcbedec17b2af66d460f31abc7cff1;hp=68e6ff4c536b1588aae45dcab0a3d47b83c89db4;hpb=6f33f705957d674dc2ab6c994a6ea87f7a91f40f;p=vamsas.git diff --git a/src/uk/ac/vamsas/test/simpleclient/ArchiveReader.java b/src/uk/ac/vamsas/test/simpleclient/ArchiveReader.java index 68e6ff4..a00be72 100644 --- a/src/uk/ac/vamsas/test/simpleclient/ArchiveReader.java +++ b/src/uk/ac/vamsas/test/simpleclient/ArchiveReader.java @@ -1,51 +1,74 @@ -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.VamsasArchiveReader; -import uk.ac.vamsas.objects.core.VAMSAS; -import uk.ac.vamsas.objects.core.VamsasDocument; - -public class ArchiveReader { - /** - * tests VamsasArchiveReader archive reader on a vamsas jar file - * @param args - */ - public static void main(String args[]) { - - try { - File av = new File(args[0]); - VamsasArchiveReader var = new VamsasArchiveReader(av); - 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); - } - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +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.VamsasArchiveReader; +import uk.ac.vamsas.objects.core.VAMSAS; +import uk.ac.vamsas.objects.core.VamsasDocument; + +public class ArchiveReader { + /** + * tests VamsasArchiveReader archive reader on a vamsas jar file + * + * @param args + */ + public static void main(String args[]) { + + try { + File av = new File(args[0]); + VamsasArchiveReader var = new VamsasArchiveReader(av); + 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); + } + } +}