com.objexcel.util
Class ZipClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--com.objexcel.util.ZipClassLoader

public final class ZipClassLoader
extends java.lang.ClassLoader

class to load java from directories, zip files, input streams


Constructor Summary
ZipClassLoader()
           
 
Method Summary
static ZipClassLoader getInstance()
          get a singleton instance
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Get an InputStream on a given resource.
 boolean isLoaded(java.io.File f)
          has the file already been loaded? based on file's absolute path.
 boolean isLoaded(java.lang.String location)
          is the location loaded (location is http://...
 void load(java.io.File f)
          load resources from a file (or directory).
 void load(java.lang.String location)
          from string figure out whether we're loading from an URL, a file or directory
 java.lang.Class loadClass(java.lang.String name)
          Load a class from this class loader.
 void loadZipInputStream(java.util.zip.ZipInputStream zr)
          Load classes from a zip input stream
static byte[] readInputStream(java.io.InputStream is)
          return as a byte array the given input stream
static char[] readInputStreamReader(java.io.InputStreamReader is, int iEntrySize)
          read the input stream from a stream reader.
static byte[] readZipEntry(java.util.zip.ZipInputStream zipStream, java.util.zip.ZipEntry zipEntry)
          return as a byte array the given zip entry
static byte[] resizeBuffer(byte[] bBuffer, int iNewBufferSize)
          return an array with a length of iNewBufferSize containing as many elements from array as will fit.
 
Methods inherited from class java.lang.ClassLoader
getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipClassLoader

public ZipClassLoader()
Method Detail

getInstance

public static ZipClassLoader getInstance()
get a singleton instance

isLoaded

public boolean isLoaded(java.lang.String location)
is the location loaded (location is http://... or a file's absolute path)

isLoaded

public boolean isLoaded(java.io.File f)
has the file already been loaded? based on file's absolute path.

load

public void load(java.lang.String location)
          throws java.lang.Exception
from string figure out whether we're loading from an URL, a file or directory

loadZipInputStream

public void loadZipInputStream(java.util.zip.ZipInputStream zr)
                        throws java.io.IOException
Load classes from a zip input stream

load

public void load(java.io.File f)
          throws java.io.IOException
load resources from a file (or directory). If a directory is specified, it recursively sucks in everything under it

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Get an InputStream on a given resource. Will return null if no resource with this name is found. name is in the form "dir/dir/name.ext";
Overrides:
getResourceAsStream in class java.lang.ClassLoader

loadClass

public java.lang.Class loadClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Load a class from this class loader.
Overrides:
loadClass in class java.lang.ClassLoader

readInputStream

public static byte[] readInputStream(java.io.InputStream is)
                              throws java.io.IOException
return as a byte array the given input stream

readZipEntry

public static byte[] readZipEntry(java.util.zip.ZipInputStream zipStream,
                                  java.util.zip.ZipEntry zipEntry)
return as a byte array the given zip entry

readInputStreamReader

public static char[] readInputStreamReader(java.io.InputStreamReader is,
                                           int iEntrySize)
read the input stream from a stream reader. if the entry size is unknown, make it -1

resizeBuffer

public static byte[] resizeBuffer(byte[] bBuffer,
                                  int iNewBufferSize)
return an array with a length of iNewBufferSize containing as many elements from array as will fit. Null padded.