refactored standard static 'ArchiveReports' into their own class.
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 13 Jan 2006 14:06:39 +0000 (14:06 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 13 Jan 2006 14:06:39 +0000 (14:06 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@108 be28352e-c001-0410-b1a7-c7978e42abec

src/org/vamsas/test/simpleclient/ArchiveReader.java
src/org/vamsas/test/simpleclient/ArchiveReports.java [new file with mode: 0644]

index a0f71ca..5f7fd6a 100644 (file)
@@ -6,62 +6,10 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 
 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, 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().getDataReference();
-            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().getData().length+" bytes.");
-          }
-        }
-          
-      }
-      return true;
-    } else {
-      System.out.print("Document Object is null");
-    }
-    return false;
-  }
-  
-  public static boolean rootReport(VAMSAS[] roots) {
-    if (roots!=null) {
-      for (int i=0; i<roots.length; i++) {
-        VAMSAS r = roots[i];
-        System.out.print("Vamsas Root "+i+" (id="
-            +((r.getId()!=null) ? r.getId():"<none>")
-            +") contains "+r.getDataSetCount()+" DataSets, "
-            + r.getTreeCount()+" Global trees");
-      }
-      return true;
-    }
-    return false;
-  }
-  
   public static void main(String args[]) {
     
     try {
@@ -71,7 +19,7 @@ public class ArchiveReader {
       if (var.isValid()) {
         InputStreamReader vdoc = new InputStreamReader(var.getVamsasDocumentStream());
         VamsasDocument doc = VamsasDocument.unmarshal(vdoc);
-        if (reportDocument(doc, var)) {
+        if (ArchiveReports.reportDocument(doc, var)) {
           roots = doc.getVAMSAS();
         }
       } else {
@@ -89,7 +37,7 @@ public class ArchiveReader {
           }
         }
       }
-      if (!rootReport(roots))
+      if (!ArchiveReports.rootReport(roots))
         System.err.print(args[0]+" is not a valid vamsas archive.");
     } catch (Exception e) {
       e.printStackTrace(System.err);
diff --git a/src/org/vamsas/test/simpleclient/ArchiveReports.java b/src/org/vamsas/test/simpleclient/ArchiveReports.java
new file mode 100644 (file)
index 0000000..d2eaf84
--- /dev/null
@@ -0,0 +1,63 @@
+package org.vamsas.test.simpleclient;
+
+import java.io.InputStream;
+
+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 ArchiveReports {
+
+  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().getDataReference();
+            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().getData().length+" bytes.");
+          }
+        }
+          
+      }
+      return true;
+    } else {
+      System.out.print("Document Object is null");
+    }
+    return false;
+  }
+
+  public static boolean rootReport(VAMSAS[] roots) {
+    if (roots!=null) {
+      for (int i=0; i<roots.length; i++) {
+        VAMSAS r = roots[i];
+        System.out.print("Vamsas Root "+i+" (id="
+            +((r.getId()!=null) ? r.getId():"<none>")
+            +") contains "+r.getDataSetCount()+" DataSets, "
+            + r.getTreeCount()+" Global trees");
+      }
+      return true;
+    }
+    return false;
+  }
+
+}