com.programix.io
Class IOTools.BaseDirectoryResourceLocator
java.lang.Object
com.programix.io.IOTools.BaseDirectoryResourceLocator
- All Implemented Interfaces:
- IOTools.ResourceLocator
- Enclosing class:
- IOTools
public static class IOTools.BaseDirectoryResourceLocator
- extends Object
- implements IOTools.ResourceLocator
An implementation of IOTools.ResourceLocator that uses the specified
base directory to try to locate resources. Requested resources are
assumed to be under the specified base directory or sub-directories
of the base directory.
A moderate attempt is made to avoid a resource requesting a file that
is not under the base directory. For example, any leading "/" or
".." from a resource name is stripped. However, there is no guarantee
that this is secure. If you can't trust the code requesting
resource locations, then you should NOT use this locator.
- Author:
- Paul Hyde
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IOTools.BaseDirectoryResourceLocator
public IOTools.BaseDirectoryResourceLocator(File baseDirectory)
throws IOException
- Throws:
IOException
IOTools.BaseDirectoryResourceLocator
public IOTools.BaseDirectoryResourceLocator(String baseDirectoryName)
throws IOException
- Throws:
IOException
getInputStreamForResource
public InputStream getInputStreamForResource(String resourceLocation)
- Description copied from interface:
IOTools.ResourceLocator
- Returns an InputStream that gets its bytes from the
specified resource. A return value of null indicates
that the resource could not be found (do not throw an exception
as the search may continue on to other locators). A return
value of null can also be used to indicate that this
particular locator can not supply the resource in the desired
format (for example, it can not be returned as a
URL,
but it might be able to be returned as an InputStream).
- Specified by:
getInputStreamForResource in interface IOTools.ResourceLocator
- Parameters:
resourceLocation - the name of the resource to find.
- Returns:
- the InputStream or null if the specified
resource could not be found by this locator.
getUrlForResource
public URL getUrlForResource(String resourceLocation)
- Description copied from interface:
IOTools.ResourceLocator
- Returns a URL that gets its bytes from the
specified resource. A return value of null indicates
that the resource could not be found (do not throw an exception
as the search may continue on to other locators). A return
value of null can also be used to indicate that this
particular locator can not supply the resource in the desired
format (for example, it can not be returned as an
URL,
but it might be able to be returned as an InputStream).
- Specified by:
getUrlForResource in interface IOTools.ResourceLocator
- Parameters:
resourceLocation - the name of the resource to find.
- Returns:
- the URL or null if the specified
resource could not be found by this locator.
Copyright © 2001-2009
Programix Incorporated.
All rights reserved.
ProgramixGenericLib is free
and is
OSI Certified
Open Source Software under the BSD
license.