KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > resource > ResourceHandler


1 package org.sapia.resource;
2
3 import java.io.IOException JavaDoc;
4 import java.io.InputStream JavaDoc;
5 import java.net.URI JavaDoc;
6
7 /**
8  * Specifies the behavior of classes used to resolve resources.
9  *
10  * @author Yanick Duchesne
11  */

12 public interface ResourceHandler {
13   /**
14    * Returns the stream corresponding to the given URI.
15    *
16    * @param uri a URI.
17    * @return an <code>InputStream</code>.
18    * @throws ResourceNotFoundException if a resource corresponding to the
19    * URI could does not exist.
20    * @throws IOException if a problem occurs.
21    */

22   public InputStream JavaDoc getResource(String JavaDoc uri) throws IOException JavaDoc, ResourceNotFoundException;
23
24   /**
25    * Returns the resource object corresponding to the given URI.
26    *
27    * @param uri
28    * a URI.
29    * @return a <code>Resource</code>.
30    * @throws IOException
31    * if a problem occurs.
32    */

33   public Resource getResourceObject(String JavaDoc uri) throws IOException JavaDoc;
34
35   /**
36    * Returns <code>true</code> if this handler "recognizes" resources with the
37    * given URI. This methods is used to hold resource handlers in a chain of
38    * responsability.
39    *
40    * @param uri
41    * a URI.
42    * @return <code>true</code> if this handler can handle resources with the
43    * given URI.
44    */

45   public boolean accepts(String JavaDoc uri);
46   
47   /**
48    * @see #accepts(String)
49    *
50    * @param uri
51    * a <code>URI</code>.
52    * @return <code>true</code> if this handler can handle resources with the
53    * given URI.
54    */

55   public boolean accepts(URI JavaDoc uri);
56
57 }
58
Popular Tags