Package org.daisy.dotify.common.io
Class AbstractResourceLocator
- java.lang.Object
-
- org.daisy.dotify.common.io.AbstractResourceLocator
-
- All Implemented Interfaces:
ResourceLocator
public abstract class AbstractResourceLocator extends Object implements ResourceLocator
Provides easy access to package resources. Simply extend AbstractResourceLocator in the package where the resources are located. Your implementation can then be used to locate the resources by specifying a location relative to the implementation.
-
-
Constructor Summary
Constructors Constructor Description AbstractResourceLocator()
Creates a new abstract resource locator.AbstractResourceLocator(String basePath)
Creates a new abstract resource locator with the specified sub-path prefix, in other words a sub-path from where all resources are resolved.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URL
getResource(String subpath)
Gets the URL for the given resource path.
-
-
-
Constructor Detail
-
AbstractResourceLocator
public AbstractResourceLocator()
Creates a new abstract resource locator. Resources are resolved relative to the location of the concrete implementation.
-
AbstractResourceLocator
public AbstractResourceLocator(String basePath)
Creates a new abstract resource locator with the specified sub-path prefix, in other words a sub-path from where all resources are resolved. Resources are resolved relative to the location of the concrete implementation.- Parameters:
basePath
- the sub-path prefix
-
-
Method Detail
-
getResource
public URL getResource(String subpath) throws ResourceLocatorException
Description copied from interface:ResourceLocator
Gets the URL for the given resource path.- Specified by:
getResource
in interfaceResourceLocator
- Parameters:
subpath
- the path to the resource- Returns:
- returns the URL for the given resource
- Throws:
ResourceLocatorException
- if the resource could not be found
-
-