consciouscode.util.resource
Class FileResourceTree

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

public class FileResourceTree
extends Object
implements ResourceTree

A ResourceTree that reads resources directly from the file system.


Constructor Summary
FileResourceTree(File baseDirectory)
          Creates a new resource tree that exposes resources stored as a file system hierarchy within a base directory.
FileResourceTree(File baseDirectory, ResourceTreeProvider provider)
          Creates a new resource tree that exposes resources stored as a file system hierarchy within a base directory.
FileResourceTree(File baseDirectory, ResourceTreeProvider provider, boolean allowMissingBase)
          Creates a new resource tree that exposes resources stored as a file system hierarchy within a base directory.
 
Method Summary
 File getBaseDirectory()
          Gets the base directory that houses all of the resources of this tree.
 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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileResourceTree

public FileResourceTree(File baseDirectory)
Creates a new resource tree that exposes resources stored as a file system hierarchy within a base directory.

Parameters:
baseDirectory - must be a readable directory, not null.

FileResourceTree

public FileResourceTree(File baseDirectory,
                        ResourceTreeProvider provider)
Creates a new resource tree that exposes resources stored as a file system hierarchy within a base directory.

Parameters:
baseDirectory - must be a readable directory, not null.

FileResourceTree

public FileResourceTree(File baseDirectory,
                        ResourceTreeProvider provider,
                        boolean allowMissingBase)
Creates a new resource tree that exposes resources stored as a file system hierarchy within a base directory.

Parameters:
baseDirectory - must not null.
provider - may be null.
allowMissingBase - indicates whether this method will check for existence and readability of the baseDirectory.
Method Detail

getBaseDirectory

public File getBaseDirectory()
Gets the base directory that houses all of the resources of this tree.

Returns:
a readable directory, not null.

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.

getResourceUrl

public URL getResourceUrl(String path)
Returns a URL to a resource file.

Specified by:
getResourceUrl in interface ResourceTree
Parameters:
path - can be either absolute or relative, but it is always resolved relative to this layer's baseDirectory. It must not be null.
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


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