org.sapia.resource
Class ClasspathResourceHandler
java.lang.Object
org.sapia.resource.ClasspathResourceHandler
- All Implemented Interfaces:
- ResourceHandler, Schemes
public class ClasspathResourceHandler
- extends Object
- implements ResourceHandler, Schemes
Handles resources on the classpath.
ClassPathResourceHandler handler = new ClassPathResourceHandler();
URL url = new URL(handler.getResourceObject("some/resource/path").getURI());
...
- Author:
- Yanick Duchesne
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ClasspathResourceHandler
public ClasspathResourceHandler()
getResourceObject
public Resource getResourceObject(String uri)
throws IOException
- Description copied from interface:
ResourceHandler
- Returns the resource object corresponding to the given URI.
- Specified by:
getResourceObject in interface ResourceHandler
- Parameters:
uri - a URI.
- Returns:
- a
Resource.
- Throws:
IOException - if a problem occurs.
getResource
public InputStream getResource(String uri)
throws IOException
- Description copied from interface:
ResourceHandler
- Returns the stream corresponding to the given URI.
- Specified by:
getResource in interface ResourceHandler
- Parameters:
uri - a URI.
- Returns:
- an
InputStream.
- Throws:
ResourceNotFoundException - if a resource corresponding to the
URI could does not exist.
IOException - if a problem occurs.
accepts
public boolean accepts(String uri)
- Description copied from interface:
ResourceHandler
- Returns
true if this handler "recognizes" resources with the
given URI. This methods is used to hold resource handlers in a chain of
responsability.
- Specified by:
accepts in interface ResourceHandler
- Parameters:
uri - a URI.
- Returns:
true if this handler can handle resources with the
given URI.
accepts
public boolean accepts(URI uri)
- Specified by:
accepts in interface ResourceHandler
- Parameters:
uri - a URI.
- Returns:
true if this handler can handle resources with the
given URI.- See Also:
ResourceHandler.accepts(String)
Copyright © 2007 Sapia Open Community, Inc. All Rights Reserved.