consciouscode.util.resource
Class ZipResourceTree

java.lang.Object
  extended by consciouscode.util.resource.ZipResourceTree
All Implemented Interfaces:
ResourceTree

public class ZipResourceTree
extends Object
implements ResourceTree

A ResourceTree that reads resources from a ZIP archive.

See Also:
ZipFile

Constructor Summary
ZipResourceTree(File zipFile)
           
ZipResourceTree(File zipFile, ResourceTreeProvider provider)
           
 
Method Summary
protected  String ensureRelativePath(String path)
           
protected  ZipEntry getEntry(String path)
           
 Resource getResource(String path)
          Returns information about a resource file.
 ResourceTreeProvider getResourceTreeProvider()
          Gets the provider of this resource tree.
 URL getResourceUrl(String path)
          Returns a URL to a resource file.
 ZipFile getZipFile()
           
 String toString()
           
 URL toUrl(String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZipResourceTree

public ZipResourceTree(File zipFile)
                throws IOException
Parameters:
zipFile - must be a readable file in ZIP format.
Throws:
IOException - if there's a problem opening the archive.

ZipResourceTree

public ZipResourceTree(File zipFile,
                       ResourceTreeProvider provider)
                throws IOException
Parameters:
zipFile - must be a readable file in ZIP format.
Throws:
IOException - if there's a problem opening the archive.
Method Detail

getZipFile

public ZipFile getZipFile()

getResourceUrl

public URL getResourceUrl(String path)
Description copied from interface: ResourceTree
Returns a URL to a resource file.

Specified by:
getResourceUrl in interface ResourceTree
Returns:
null if no resource exists at the given path.

getResource

public Resource getResource(String path)
Description copied from interface: ResourceTree
Returns information about a resource file.

Specified by:
getResource in interface ResourceTree
Parameters:
path - identifies the desired resource.
Returns:
null if no resource exists at the given path.

getResourceTreeProvider

public ResourceTreeProvider getResourceTreeProvider()
Description copied from interface: ResourceTree
Gets the provider of this resource tree.

Specified by:
getResourceTreeProvider in interface ResourceTree
Returns:
may be null.

toString

public String toString()
Overrides:
toString in class Object

ensureRelativePath

protected String ensureRelativePath(String path)

getEntry

protected ZipEntry getEntry(String path)
Parameters:
path - can be either absolute or relative.

toUrl

public URL toUrl(String path)


Copyright © 2001–2012 Todd V. Jonker. All Rights Reserved.