Bundles! Have component bundles largely working. Wrote test code and ANT
tasks and XML parsing rule sets all the good stuff. Rewired up all the cast code to be amenable to bundling and did some other revamping. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@640 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// $Id: BundleUtil.java,v 1.1 2001/11/27 08:09:35 mdb Exp $
|
||||
|
||||
package com.threerings.cast.bundle;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
import com.threerings.resource.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Utility functions related to creating and manipulating component
|
||||
* bundles.
|
||||
*/
|
||||
public class BundleUtil
|
||||
{
|
||||
/** The path in the metadata bundle to the serialized action table. */
|
||||
public static final String ACTIONS_PATH = "actions.dat";
|
||||
|
||||
/** The path in the metadata bundle to the serialized action tile sets
|
||||
* table. */
|
||||
public static final String ACTION_SETS_PATH = "action_sets.dat";
|
||||
|
||||
/** The path in the metadata bundle to the serialized component class
|
||||
* table. */
|
||||
public static final String CLASSES_PATH = "classes.dat";
|
||||
|
||||
/** The path in the component bundle to the serialized component id to
|
||||
* class/type mapping. */
|
||||
public static final String COMPONENTS_PATH = "components.dat";
|
||||
|
||||
/** The file extension of our action tile images. */
|
||||
public static final String IMAGE_EXTENSION = ".png";
|
||||
|
||||
/**
|
||||
* Attempts to load an object from the supplied resource bundle with
|
||||
* the specified path.
|
||||
*
|
||||
* @return the unserialized object in question or null if no
|
||||
* serialized object data was available at the specified path.
|
||||
*
|
||||
* @exception IOException thrown if an I/O error occurs while reading
|
||||
* the object from the bundle.
|
||||
*/
|
||||
public static Object loadObject (ResourceBundle bundle, String path)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
InputStream bin = bundle.getResource(path);
|
||||
if (bin == null) {
|
||||
return null;
|
||||
}
|
||||
return new ObjectInputStream(bin).readObject();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user