kiwi.util
Class CompressedResourceLoader
java.lang.Object
|
+--kiwi.util.ResourceLoader
|
+--kiwi.util.CompressedResourceLoader
- public class CompressedResourceLoader
- extends ResourceLoader
A utility class containing methods for retrieving compressed application
resources; these resources typically reside within a JAR file among the
classes that make up an application. The location of a resource is
specified as a path relative to the location of its associated object's
class within the application's class hierarchy.
Resources may be retrieved as byte arrays, as String
s, as
InputStream
s, as AudioClip
s, as
Image
s,, or as Properties
objects.
Both the GZIP and ZIP compression formats are supported.
- Version:
- 1.0.1 (10/98)
- Author:
- Mark Lindner, PING Software Group
- See Also:
ResourceLoader
Field Summary |
static int |
DEFAULT_INFLATER
The default inflater type. |
static int |
GZIP
The GZIP inflater type. |
protected static int |
inflater
|
static int |
ZIP
The ZIP inflater type. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
GZIP
public static final int GZIP
- The GZIP inflater type.
ZIP
public static final int ZIP
- The ZIP inflater type.
DEFAULT_INFLATER
public static final int DEFAULT_INFLATER
- The default inflater type.
inflater
protected static int inflater
CompressedResourceLoader
public CompressedResourceLoader(Class clazz)
- Construct a new
CompressedResourceLoader
with a default
input buffer size and inflater type.
- Parameters:
clazz
- The class object that serves as the resource anchor for this
CompressedResourceLoader
.
CompressedResourceLoader
public CompressedResourceLoader(Class clazz,
int type)
throws IllegalArgumentException
- Create a new compressed resource loader with the default input buffer
size.
- Parameters:
clazz
- The class object that serves as the resource anchor for this
CompressedResourceLoader
.type
- The inflater type; one of the static constants declared
above.- Throws:
- IllegalArgumentException - If the value of
type
is invalid.
CompressedResourceLoader
public CompressedResourceLoader(Class clazz,
int type,
int size)
throws IllegalArgumentException
- Create a new compressed resource loader. A new resource loader is created
with the specified input buffer size and inflater type.
- Parameters:
clazz
- The class object that serves as the resource anchor for this
CompressedResourceLoader
.type
- The inflater type; one of the static constants declared
above.size
- The input buffer size.- Throws:
- IllegalArgumentException - If the value of
type
or size
is invalid.
getInflaterType
public int getInflaterType()
- Get the inflater type.
- Returns:
- The inflater type used by this loader.
getResourceAsStream
public InputStream getResourceAsStream(String path)
throws IOException
- Retrieve a compressed resource as a stream. Resources are located at a
path that is relative to a given class. The data read will be
automatically decompressed using the specified appropriate inflater type,
or the default inflater type if none was specified.
- Parameters:
clazz
- The class object associated with this resource.path
- A file path specifying the location of the resource; the path
is relative to the location of the class file.- Returns:
- An
InputStream
from which the (decompressed)
resource data may be read. - Throws:
- IOException - If the resource was not found.
- Overrides:
- getResourceAsStream in class ResourceLoader