From 85bcc8e60b7652bcbc3994463bb72dfb47c4766b Mon Sep 17 00:00:00 2001 From: jprocter <jprocter@compbio.dundee.ac.uk> Date: Fri, 11 Nov 2005 18:03:57 +0000 Subject: [PATCH] extended report of archive contents. git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@90 be28352e-c001-0410-b1a7-c7978e42abec --- .../vamsas/test/simpleclient/ArchiveReader.java | 32 ++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/org/vamsas/test/simpleclient/ArchiveReader.java b/src/org/vamsas/test/simpleclient/ArchiveReader.java index 2156c51..46ae199 100644 --- a/src/org/vamsas/test/simpleclient/ArchiveReader.java +++ b/src/org/vamsas/test/simpleclient/ArchiveReader.java @@ -4,17 +4,43 @@ import java.io.BufferedInputStream; import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; -import java.util.Vector; import org.vamsas.client.simpleclient.VamsasArchiveReader; +import org.vamsas.objects.core.ApplicationData; import org.vamsas.objects.core.VAMSAS; import org.vamsas.objects.core.VamsasDocument; public class ArchiveReader { - public static boolean reportDocument(VamsasDocument document) { + public static boolean reportDocument(VamsasDocument document, VamsasArchiveReader archive) { if (document!=null) { System.out.print("Vamsas Document version '"+document.getVersion()+"'"); System.out.print("Document contains "+document.getVAMSASCount()+" VAMSAS Elements and "+document.getApplicationDataCount()+" elements.\n"); + if (document.getApplicationDataCount()>0) { + System.out.print("There are "+document.getApplicationDataCount()+" ApplicationData references.\n"); + ApplicationData appd[] = document.getApplicationData(); + for (int i=0,j=appd.length; i<j; i++) { + System.out.print("Application "+i+": '"+appd[i].getName()+"'\nVersion '"+appd[i].getVersion()+"'\nURN: '"+appd[i].getUrn()+"'\n"); + System.out.print("AppData is "); + if (appd[i].getAppDataChoice().getDataReference()==null) { + String appData=appd[i].getAppDataChoice().getData(); + if (appData.length()>1) { + System.out.print("a reference ("+appData+")"); + InputStream jstrm; + if ((jstrm=archive.getAppdataStream(appData))!=null) + System.out.println(" which resolves to a JarEntry."); + else { + System.out.println(" which does not resolve to a JarEntry."); + System.err.println("Unresolved appdata reference '"+appData+"'"); + } + } else { + System.out.println("an empty reference."); + } + } else { + System.out.println("an embedded chunk of "+appd[i].getAppDataChoice().getDataReference().length+" bytes."); + } + } + + } return true; } else { System.out.print("Document Object is null"); @@ -45,7 +71,7 @@ public class ArchiveReader { if (var.isValid()) { InputStreamReader vdoc = new InputStreamReader(var.getVamsasDocumentStream()); VamsasDocument doc = VamsasDocument.unmarshal(vdoc); - if (reportDocument(doc)) { + if (reportDocument(doc, var)) { roots = doc.getVAMSAS(); } } else { -- 1.7.10.2