From 50873b116cd2089762cbde8b026f7f7e2a4b47ec Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Sun, 16 Dec 2001 23:12:37 +0000 Subject: [PATCH] Utility to dump component bundles. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@812 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../cast/bundle/tools/DumpBundle.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/java/com/threerings/cast/bundle/tools/DumpBundle.java diff --git a/src/java/com/threerings/cast/bundle/tools/DumpBundle.java b/src/java/com/threerings/cast/bundle/tools/DumpBundle.java new file mode 100644 index 000000000..bb40a08c2 --- /dev/null +++ b/src/java/com/threerings/cast/bundle/tools/DumpBundle.java @@ -0,0 +1,66 @@ +// +// $Id: DumpBundle.java,v 1.1 2001/12/16 23:12:37 shaper Exp $ + +package com.threerings.cast.tools.bundle; + +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import com.samskivert.util.HashIntMap; +import com.samskivert.util.StringUtil; + +import com.threerings.resource.ResourceBundle; +import com.threerings.cast.bundle.BundleUtil; + +/** + * Dumps the contents of a component bundle to stdout. + */ +public class DumpBundle +{ + public static void main (String[] args) + { + if (args.length < 1) { + String usage = "Usage: DumpBundle bundle.jar [bundle.jar ...]"; + System.err.println(usage); + System.exit(-1); + } + + for (int i = 0; i < args.length; i++) { + File file = new File(args[i]); + try { + ResourceBundle bundle = new ResourceBundle(file); + + HashMap actions = (HashMap)BundleUtil.loadObject( + bundle, BundleUtil.ACTIONS_PATH); + dumpTable("actions: ", actions); + + HashMap actionSets = (HashMap)BundleUtil.loadObject( + bundle, BundleUtil.ACTION_SETS_PATH); + dumpTable("actionSets: ", actionSets); + + HashMap classes = (HashMap)BundleUtil.loadObject( + bundle, BundleUtil.CLASSES_PATH); + dumpTable("classes: ", classes); + + HashIntMap comps = (HashIntMap)BundleUtil.loadObject( + bundle, BundleUtil.COMPONENTS_PATH); + dumpTable("components: ", comps); + + } catch (Exception e) { + System.err.println("Error dumping bundle [path=" + args[i] + + ", error=" + e + "]."); + e.printStackTrace(); + } + } + } + + protected static void dumpTable (String prefix, Map table) + { + if (table != null) { + Iterator iter = table.entrySet().iterator(); + System.out.println(prefix + StringUtil.toString(iter)); + } + } +}