|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sapia.resource.FileResourceHandler
public class FileResourceHandler
Resolves resources from the file system.
FileResourceHandler handler = new FileResourceHandler();
// resolving a file URL
InputStream is = handler.getResource("file:/opt/some/file.txt");
// resolving an absolute path
InputStream is = handler.getResource("/opt/some/file.txt");
// resolving a relative path (assuming current dir is /opt)
InputStream is = handler.getResource("some/file.txt");
FileResource| Field Summary |
|---|
| Fields inherited from interface org.sapia.resource.Schemes |
|---|
SCHEME_FILE, SCHEME_FTP, SCHEME_HTTP, SCHEME_RESOURCE |
| Constructor Summary | |
|---|---|
FileResourceHandler()
|
|
| Method Summary | |
|---|---|
boolean |
accepts(java.lang.String uri)
Returns true if this handler "recognizes" resources with the
given URI. |
boolean |
accepts(java.net.URI uri)
|
java.io.File |
getFile(java.lang.String uri)
|
java.io.InputStream |
getResource(java.lang.String uri)
Returns the stream corresponding to the given URI. |
Resource |
getResourceObject(java.lang.String uri)
Returns the resource object corresponding to the given URI. |
void |
setBasedir(java.lang.String basedir)
Sets the directory from which relative paths should be evaluated. |
void |
setFallBackToClasspath(boolean fallback)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileResourceHandler()
| Method Detail |
|---|
public Resource getResourceObject(java.lang.String uri)
throws java.io.IOException
ResourceHandler
getResourceObject in interface ResourceHandleruri - a URI.
Resource.
java.io.IOException - if a problem occurs.
public java.io.File getFile(java.lang.String uri)
throws java.io.IOException
uri - a URI.
File corresponding to the given URI.
java.io.IOException
public java.io.InputStream getResource(java.lang.String uri)
throws java.io.IOException
ResourceHandler
getResource in interface ResourceHandleruri - a URI.
InputStream.
ResourceNotFoundException - if a resource corresponding to the
URI could does not exist.
java.io.IOException - if a problem occurs.public void setFallBackToClasspath(boolean fallback)
fallback - if true, this instance will resort to looking up
the classpath if it cannot find a resource on the file system.public void setBasedir(java.lang.String basedir)
basedir - the path to a directorypublic boolean accepts(java.lang.String uri)
ResourceHandlertrue if this handler "recognizes" resources with the
given URI. This methods is used to hold resource handlers in a chain of
responsability.
accepts in interface ResourceHandleruri - a URI.
true if this handler can handle resources with the
given URI.public boolean accepts(java.net.URI uri)
accepts in interface ResourceHandleruri - a URI.
true if this handler can handle resources with the
given URI.ResourceHandler.accepts(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||