com.atlassian.modzdetector
Class FilesystemStreamMapper

java.lang.Object
  extended by com.atlassian.modzdetector.FilesystemStreamMapper
All Implemented Interfaces:
StreamMapper

public class FilesystemStreamMapper
extends java.lang.Object
implements StreamMapper

Implements a mapping for streams that are only ever loaded from a filesystem rooted at a specific configured directory.

// TODO can has remove filter?


Constructor Summary
FilesystemStreamMapper(java.io.File base, java.io.FileFilter filter)
          Constructor that provides the base directory.
 
Method Summary
 java.lang.String getResourceKey(java.io.File file)
          Given a file creates a resource key that would correspond to this file
 java.lang.String getResourcePath(java.lang.String resourceKey)
          Given a resource name returns a file path to this resource.
 java.io.InputStream mapStream(java.lang.String prefix, java.lang.String resourceName)
          Gets the input stream for the resource registered with the given name and prefix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilesystemStreamMapper

public FilesystemStreamMapper(java.io.File base,
                              java.io.FileFilter filter)
Constructor that provides the base directory. All registrations are expected to be relative to this base. The filter is used to restrict the specific scope of the stream mapping.

Parameters:
base - the base of the filesystem mapping.
filter - a filter to restrict what resources are visible.
Method Detail

mapStream

public java.io.InputStream mapStream(java.lang.String prefix,
                                     java.lang.String resourceName)
Description copied from interface: StreamMapper
Gets the input stream for the resource registered with the given name and prefix. Caller should close the stream when finished.

Specified by:
mapStream in interface StreamMapper
Returns:
null on failure to map.

getResourcePath

public java.lang.String getResourcePath(java.lang.String resourceKey)
Description copied from interface: StreamMapper
Given a resource name returns a file path to this resource. The root of the path is defined by the implementation.

Specified by:
getResourcePath in interface StreamMapper
Returns:

getResourceKey

public java.lang.String getResourceKey(java.io.File file)
Description copied from interface: StreamMapper
Given a file creates a resource key that would correspond to this file

Specified by:
getResourceKey in interface StreamMapper
Returns:


Copyright © 2011 Atlassian. All Rights Reserved.