org.jbehave.web.io
Class ResourceFinder

java.lang.Object
  extended by org.jbehave.web.io.ResourceFinder

public class ResourceFinder
extends java.lang.Object

A utility class to retrieve resource, either from classpath or from filesystem, and convert them to strings. Classpath resources are identified by a configurable classpath prefix, which defaults to "classpath:". The finder will resolve the resource path (i.e. stripping the prefix) and first try to find the resource in the injected classloader, which default the current thread context classloader, and failing that will fall back on looking for the resource in the filesystem.


Nested Class Summary
static class ResourceFinder.ResourceNotFoundException
           
static class ResourceFinder.ResourceRetrievalFailedException
           
 
Field Summary
static java.lang.String DEFAULT_CLASSPATH_PREFIX
           
 
Constructor Summary
ResourceFinder(java.lang.ClassLoader classLoader, java.lang.String rootDirectory)
           
ResourceFinder(java.lang.ClassLoader classLoader, java.lang.String rootDirectory, java.lang.String classpathPrefix)
           
ResourceFinder(java.lang.String rootDirectory)
           
 
Method Summary
 java.lang.String resourceAsString(java.lang.String relativePath)
           
 void useRootDirectory(java.lang.String rootDirectory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CLASSPATH_PREFIX

public static final java.lang.String DEFAULT_CLASSPATH_PREFIX
See Also:
Constant Field Values
Constructor Detail

ResourceFinder

public ResourceFinder(java.lang.String rootDirectory)

ResourceFinder

public ResourceFinder(java.lang.ClassLoader classLoader,
                      java.lang.String rootDirectory)

ResourceFinder

public ResourceFinder(java.lang.ClassLoader classLoader,
                      java.lang.String rootDirectory,
                      java.lang.String classpathPrefix)
Method Detail

resourceAsString

public java.lang.String resourceAsString(java.lang.String relativePath)

useRootDirectory

public void useRootDirectory(java.lang.String rootDirectory)


Copyright © 2009. All Rights Reserved.