2.17.2: 2011-06-17

net.sf.basedb.util.bfs
Class BaseInputStreamLocator

java.lang.Object
  extended by net.sf.basedb.util.bfs.BaseInputStreamLocator
All Implemented Interfaces:
InputStreamLocator

public class BaseInputStreamLocator
extends Object
implements InputStreamLocator

Input stream locator implementation that works with files within a given directory in the BASE file system. The files must be located in the specified root directory. Subdirectories or parent paths are not supported.

Version:
2.15
Author:
Nicklas
Last modified
$Date: 2010-01-29 14:34:03 +0100 (Fri, 29 Jan 2010) $

Field Summary
private  Map<String,File> cache
           
private  DbControl dc
           
private  Directory dir
           
 
Constructor Summary
BaseInputStreamLocator(DbControl dc, Directory dir)
          Create a new input stream locator.
 
Method Summary
private  File getFile(String filename)
           
 InputStream getInputStream(String filename)
          Finds and opens an input stream to the file with the given filename.
 long getSize(String filename)
          Get the size in bytes of the given named resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dc

private final DbControl dc

dir

private final Directory dir

cache

private final Map<String,File> cache
Constructor Detail

BaseInputStreamLocator

public BaseInputStreamLocator(DbControl dc,
                              Directory dir)
Create a new input stream locator.

Parameters:
dc - A DbControl to use for database access
dir - The directory in the BASE file system in which the files should be located
Method Detail

getInputStream

public InputStream getInputStream(String filename)
                           throws IOException
Finds and opens an input stream to the file with the given filename.

Specified by:
getInputStream in interface InputStreamLocator
Parameters:
filename - The name (for example a file name) of the resource
Returns:
An input stream
Throws:
IOException - If there is any problem with locating or opening the resource

getSize

public long getSize(String filename)
Description copied from interface: InputStreamLocator
Get the size in bytes of the given named resource.

Specified by:
getSize in interface InputStreamLocator
Parameters:
filename - The name (for example a file name) of the resouce
Returns:
The size in bytes, or -1 if not known

getFile

private File getFile(String filename)

2.17.2: 2011-06-17