1 package org.vamsas.test.simpleclient;
3 import java.io.BufferedInputStream;
5 import java.io.InputStream;
6 import java.io.InputStreamReader;
8 import org.vamsas.client.simpleclient.VamsasArchiveReader;
9 import org.vamsas.objects.core.VAMSAS;
10 import org.vamsas.objects.core.VamsasDocument;
12 public class ArchiveReader {
14 * tests VamsasArchiveReader archive reader on a vamsas jar file
17 public static void main(String args[]) {
20 File av = new File(args[0]);
21 VamsasArchiveReader var = new VamsasArchiveReader(av);
24 InputStreamReader vdoc = new InputStreamReader(var.getVamsasDocumentStream());
25 VamsasDocument doc = VamsasDocument.unmarshal(vdoc);
26 if (ArchiveReports.reportDocument(doc, var, true)) {
27 roots = doc.getVAMSAS();
30 InputStream vxmlis = var.getVamsasXmlStream();
32 if (vxmlis!=null) { // Might be an old vamsas file.
33 BufferedInputStream ixml = new BufferedInputStream(var.getVamsasXmlStream());
34 InputStreamReader vxml = new InputStreamReader(ixml);
36 // unmarshal seems to always close the stream (should check this)
37 if ((root = VAMSAS.unmarshal(vxml))!=null) {
38 System.out.println("Read a root.");
39 roots = new VAMSAS[1];
44 if (!ArchiveReports.rootReport(roots, true))
45 System.err.print(args[0]+" is not a valid vamsas archive.");
46 } catch (Exception e) {
47 e.printStackTrace(System.err);