KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > util > UrlResource


1 package org.sapia.soto.util;
2
3 import java.io.IOException JavaDoc;
4 import java.io.InputStream JavaDoc;
5
6 import java.net.URL JavaDoc;
7
8
9 /**
10  * Implements a <code>Resource</code> over a <code>URL</code>
11  *
12  * @see org.sapia.soto.util.Resource
13  * @see java.net.URL
14  *
15  * @author Yanick Duchesne
16  *
17  * <dl>
18  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
19  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
20  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
21  * </dl>
22  */

23 public class UrlResource implements Resource {
24   static final long UNDEFINED = -1;
25   private URL JavaDoc _url;
26
27   public UrlResource(URL JavaDoc url) {
28     _url = url;
29   }
30
31   /**
32    * @see org.sapia.soto.util.Resource#lastModified()
33    */

34   public long lastModified() {
35     return UNDEFINED;
36   }
37
38   /**
39    * @see org.sapia.soto.util.Resource#getInputStream()
40    */

41   public InputStream JavaDoc getInputStream() throws IOException JavaDoc {
42     return _url.openStream();
43   }
44
45   /**
46    * @see org.sapia.soto.util.Resource#getURI()
47    */

48   public String JavaDoc getURI() {
49     return _url.toExternalForm();
50   }
51
52   public String JavaDoc toString() {
53     return _url.toExternalForm();
54   }
55 }
56
Popular Tags