net.officefloor.plugin.servlet.resource
Class ClassPathResourceLocator

java.lang.Object
  extended by net.officefloor.plugin.servlet.resource.ClassPathResourceLocator
All Implemented Interfaces:
ResourceLocator

public class ClassPathResourceLocator
extends Object
implements ResourceLocator

ResourceLocator for the class path.

Author:
Daniel Sagenschneider

Constructor Summary
ClassPathResourceLocator(String classPathPrefix, ClassLoader classLoader, String... defaultDirectoryFileNames)
          Initiate.
 
Method Summary
 URL getResource(String resourcePath)
          Obtains the URL for the resource.
 InputStream getResourceAsStream(String resourcePath)
          Obtains the InputStream to the contents of the resource.
 Set<String> getResourceChildren(String resourcePath)
          Obtains the direct children for the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassPathResourceLocator

public ClassPathResourceLocator(String classPathPrefix,
                                ClassLoader classLoader,
                                String... defaultDirectoryFileNames)
Initiate.

Parameters:
classPathPrefix - Class path prefix.
classLoader - ClassLoader to use to locate resources.
defaultDirectoryFileNames - Names of the default files within a directory.
Method Detail

getResourceChildren

public Set<String> getResourceChildren(String resourcePath)
Description copied from interface: ResourceLocator
Obtains the direct children for the resource.

Specified by:
getResourceChildren in interface ResourceLocator
Parameters:
resourcePath - Path to the resource.
Returns:
Direct children for the resource.

getResource

public URL getResource(String resourcePath)
                throws MalformedURLException
Description copied from interface: ResourceLocator
Obtains the URL for the resource.

Specified by:
getResource in interface ResourceLocator
Parameters:
resourcePath - Path to the resource.
Returns:
URL to the resource or null if no resource at path.
Throws:
MalformedURLException - If resource path is malformed.

getResourceAsStream

public InputStream getResourceAsStream(String resourcePath)
Description copied from interface: ResourceLocator
Obtains the InputStream to the contents of the resource.

Specified by:
getResourceAsStream in interface ResourceLocator
Parameters:
resourcePath - Path to the resource.
Returns:
InputStream to the contents of the resource or null if no resource at path.


Copyright © 2005-2012. All Rights Reserved.