KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > repository > Resource


1 /*
2  * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
3  * Copyright Jayasoft 2005 - All rights reserved
4  *
5  * #SNAPSHOT#
6  */

7 package fr.jayasoft.ivy.repository;
8
9 import java.io.IOException JavaDoc;
10 import java.io.InputStream JavaDoc;
11
12 /**
13  * Represents a resource in an Ivy {@link Repository}.
14  *
15  * The resource interface allows one to obtain the following information about a resource:
16  * <ul>
17  * <li>resource name/identifier in repository syntax</li>
18  * <li>date the resource was last modified.</li>
19  * <li>size of the resource in bytes.</li>
20  * <li>if the resource is available.</li>
21  *</ul>
22  *</p>
23  *<h4>Implementation Notes</h4>
24  * In implementing the interface you need to ensure the following behaviors:
25  * <ul>
26  * <li>All of the methods specified in the interface fail by returning an empty value
27  * (<code>false</code>, <code>0</code>, <code>""</code>). In other words, the specified interface
28  * methods should not throw RuntimeExceptions.
29  * </li>
30  * <li>Failure conditions should be logged using the
31  * {@link fr.jayasoft.ivy.util.Message#verbose} method.
32  * </li>
33  * <li>Failure of one of the interface's specified methods results in all other interface specified
34  * methods returning an empty value (<code>false</code>, <code>0</code>, <code>""</code>).</li>
35  * </ul>
36  * </p>
37  */

38
39 public interface Resource {
40     /**
41      * Get the name of the resource.
42      *
43      * @return the repositorie's assigned resource name/identifier.
44      */

45     public String JavaDoc getName();
46     
47     /**
48      * Get the date the resource was last modified
49      *
50      * @return A <code>long</code> value representing the time the file was
51      * last modified, measured in milliseconds since the epoch
52      * (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the
53      * file does not exist or if an I/O error occurs.
54      */

55     public long getLastModified();
56     
57     /**
58      * Get the resource size
59      *
60      * @return a <code>long</code> value representing the size of the resource in bytes.
61      */

62     public long getContentLength();
63     
64     /**
65      * Determine if the resource is available.
66      * </p>
67      * Note that this method only checks for availability, not for actual existence.
68      *
69      * @return <code>boolean</code> value indicating if the resource is available.
70      */

71     public boolean exists();
72     
73     /**
74      * Is this resource local to this host, i.e. is it on the file system?
75      *
76      * @return <code>boolean</code> value indicating if the resource is local.
77      */

78     public boolean isLocal();
79
80     /**
81      * Clones this resource with a new resource with a different name
82      * @param cloneName the name of the clone
83      * @return the cloned resource
84      */

85     public Resource clone(String JavaDoc cloneName);
86     
87     /**
88      * Opens a stream on this resource
89      * @return the opened input stream
90      */

91     public InputStream JavaDoc openStream() throws IOException JavaDoc;
92 }
93
Popular Tags