org.sapia.clazzy.loader
Class JarLoader

java.lang.Object
  |
  +--org.sapia.clazzy.loader.JarLoader
All Implemented Interfaces:
Loader, URLEnabled

public class JarLoader
extends Object
implements Loader, URLEnabled

Implements the Loader interface over a jar file. The underlying jar file is opened at instantiation time. An instance of this class should be disposed of appropriately (through the close() method), so that the underlying jar file is properly closed.

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2004 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Constructor Summary
JarLoader(File jar)
           
 
Method Summary
 void close()
          Releases all resources that this instance holds.
 File getJarFile()
           
 URL getURL()
           
 URL getURL(String resourceName)
           
 byte[] loadBytes(String resourceName)
          Loads a the bytes of the specified resources and returns them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarLoader

public JarLoader(File jar)
Method Detail

getJarFile

public File getJarFile()

getURL

public URL getURL()
           throws MalformedURLException
Specified by:
getURL in interface URLEnabled
Returns:
the URL of the File to which this instance corresponds.
Throws:
MalformedURLException

getURL

public URL getURL(String resourceName)
Specified by:
getURL in interface Loader
Parameters:
resourceName - the name of a resource.
Returns:
the URL corresponding to the given resource.
See Also:
Loader.getURL(java.lang.String)

loadBytes

public byte[] loadBytes(String resourceName)
Description copied from interface: Loader
Loads a the bytes of the specified resources and returns them.

Specified by:
loadBytes in interface Loader
Parameters:
resourceName -
Returns:
an array of bytes, or null if no resource could be found for the given name, or if the bytes could not be loaded for some reason.
See Also:
Loader.loadBytes(java.lang.String)

close

public void close()
Description copied from interface: Loader
Releases all resources that this instance holds.

Specified by:
close in interface Loader
See Also:
Loader.close()


Copyright © 2002 Sapia Open Community, Inc. All Rights Reserved.