javazoom.jl.decoder

Class JavaLayerUtils


public class JavaLayerUtils
extends java.lang.Object

The JavaLayerUtils class is not strictly part of the JavaLayer API. It serves to provide useful methods and system-wide hooks.

Method Summary

static Object
deserialize(InputStream in)
Deserializes an object from the given InputStream.
static Object
deserialize(InputStream in, Class cls)
Deserializes the object contained in the given input stream.
static Object
deserializeArray(InputStream in, Class elemType, int length)
Deserializes an array from a given InputStream.
static Object
deserializeArrayResource(String name, Class elemType, int length)
static JavaLayerHook
getHook()
static InputStream
getResourceAsStream(String name)
Retrieves an InputStream for a named resource.
static void
serialize(OutputStream out, Object obj)
static void
setHook(JavaLayerHook hook0)
Sets the system-wide JavaLayer hook.

Method Details

deserialize

public static Object deserialize(InputStream in)
            throws IOException
Deserializes an object from the given InputStream. The deserialization is delegated to an ObjectInputStream instance.
Parameters:
in - The InputStream to deserialize an object from.
Returns:
The object deserialized from the stream.
See Also:
java.io.ObjectInputStream

deserialize

public static Object deserialize(InputStream in,
                                 Class cls)
            throws IOException
Deserializes the object contained in the given input stream.
Parameters:
in - The input stream to deserialize an object from.
cls - The expected class of the deserialized object.

deserializeArray

public static Object deserializeArray(InputStream in,
                                      Class elemType,
                                      int length)
            throws IOException
Deserializes an array from a given InputStream.
Parameters:
in - The InputStream to deserialize an object from.
elemType - The class denoting the type of the array elements.
length - The expected length of the array, or -1 if any length is expected.

deserializeArrayResource

public static Object deserializeArrayResource(String name,
                                              Class elemType,
                                              int length)
            throws IOException

getHook

public static JavaLayerHook getHook()

getResourceAsStream

public static InputStream getResourceAsStream(String name)
Retrieves an InputStream for a named resource.
Parameters:
name - The name of the resource. This must be a simple name, and not a qualified package name.
Returns:
The InputStream for the named resource, or null if the resource has not been found. If a hook has been provided, its getResourceAsStream() method is called to retrieve the resource.

serialize

public static void serialize(OutputStream out,
                             Object obj)
            throws IOException

setHook

public static void setHook(JavaLayerHook hook0)
Sets the system-wide JavaLayer hook.

JavaZOOM 1999-2005