1
2 package org.freehep.graphicsio.swf.test;
3
4 import hep.aida.IAnalysisFactory;
5 import hep.aida.ITree;
6 import hep.aida.ITuple;
7 import hep.aida.ITupleFactory;
8
9 import java.io.FileInputStream;
10 import java.io.IOException;
11
12 import org.freehep.graphicsio.swf.SWFHeader;
13 import org.freehep.graphicsio.swf.SWFInputStream;
14 import org.freehep.util.io.Tag;
15
16
17
18
19
20 public class SWFAnalyze {
21
22 public static void main(String[] args) {
23
24 try {
25 IAnalysisFactory af = IAnalysisFactory.create();
26 ITree tree = af.createTreeFactory().create("SWFAnalyze.aida",
27 "xml", false, true);
28 ITupleFactory tf = af.createTupleFactory(tree);
29 ITuple tuple = tf.create("SWF", "TagType", new String[] { "Tag",
30 "TagSize" }, new Class[] { String.class, int.class });
31
32 FileInputStream fis = new FileInputStream(args[0]);
33 SWFInputStream swf = new SWFInputStream(fis);
34
35 long start = System.currentTimeMillis();
36 SWFHeader header = swf.readHeader();
37 System.out.println(header);
38
39 Tag tag = swf.readTag();
40 while (tag != null) {
41
42 tuple.fill(0, tag.getName());
43 System.out.print(" " + tag.getName());
44 tuple.addRow();
45 tag = swf.readTag();
46
47 }
48 tree.commit();
49 System.out.println("Analyzed file in: "
50 + (System.currentTimeMillis() - start) + " ms.");
51 } catch (IOException e) {
52 e.printStackTrace();
53 }
54 }
55 }