KickJava   Java API By Example, From Geeks To Geeks.

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


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.File JavaDoc;
10 import java.io.IOException JavaDoc;
11 import java.util.List JavaDoc;
12
13 import fr.jayasoft.ivy.Artifact;
14
15 /**
16  * Represents a collection of resources available to Ivy. Ivy uses one or more
17  * repositories as both a source of resources for Ivy enabled build systems and
18  * as a distribution center for resources generated by Ivy enabled build systems.
19  * </p>
20  * <p>A repository supports the following fundamental operations
21  * <ul>
22  * <li>retrieving a resource from the repository.</li>
23  * <li>transfering a resource to the repository.</li>
24  * <li>retrieving a listing of resources.</li>
25  * </ul>
26  * </p>
27  * <h4>Resource Retrieval</h4>
28  * </p>
29  * <p>{@link #get} retrieves a resource specified by a provided identifier creating a new file .</p>
30  * </p>
31  * <h4>resource Publication</h4>
32  * </p>
33  * <p>{@link #put} transfers a file to the repository.
34  * </p>
35  * </p>
36  * <h4>resource Listing</h4>
37  * </p>
38  * <p>{@link #list} returns a listing of file like objects
39  * belonging to a specified parent directory.</p>
40  * </p>
41  */

42 public interface Repository {
43     
44     /**
45      * Return the resource associated with a specified identifier.
46      *
47      * If the resource does not exist, it should return a Resource with exists() returning false.
48      *
49      * An IOException should only be thrown when a real IO problem occurs, like the impossibility to
50      * connect to a server.
51      *
52      * @param source A string identifying the resource.
53      * @return The resource associated with the resource identifier.
54      * @throws IOException On error whle trying to get resource.
55      */

56     Resource getResource(String JavaDoc source) throws IOException JavaDoc;
57     
58     /**
59      * Fetch a resource from the repository.
60      *
61      * @param source A string identifying the resource to be fetched.
62      * @param destination Where to place the fetched resource.
63      * @throws IOException On retrieval failure.
64      */

65     void get(String JavaDoc source, File JavaDoc destination) throws IOException JavaDoc;
66     
67     
68     /**
69      * Transfer a resource to the repository
70      * @param artifact The artifact to be transferred.
71      * @param source The local file to be transferred.
72      * @param destination Where to transfer the resource.
73      * @param overwrite Whether the transfer should overwrite an existing resource.
74      *
75      * @throws IOException On publication failure.
76      */

77     void put(Artifact artifact, File JavaDoc source, String JavaDoc destination, boolean overwrite) throws IOException JavaDoc;
78     
79     /**
80      * Return a listing of resources names
81      *
82      * @param parent The parent directory from which to generate the listing.
83      * @return A listing of the parent directory's file content, as a List of String.
84      * @throws IOException On listing failure.
85      */

86     List JavaDoc list(String JavaDoc parent) throws IOException JavaDoc;
87     
88     /**
89      * Add a listener to the repository.
90      *
91      * @param listener The listener to attach to the repository.
92      */

93     void addTransferListener(TransferListener listener);
94     
95     /**
96      * Remove a listener on the repository
97      *
98      * @param listener The listener to remove
99      */

100     void removeTransferListener(TransferListener listener);
101     
102     /**
103      * Determine if a given listener is attached to the repository.
104      *
105      * @param listener The listener being quireied
106      * @return <code>true</code> if the provided listener is attached to the repository,
107      * <code>false</code> if not.
108      */

109     boolean hasTransferListener(TransferListener listener);
110     
111     /**
112      * Get the repository's file separator string.
113      *
114      * @return The repository's file separator delimiter
115      */

116     String JavaDoc getFileSeparator();
117     
118     /**
119      * Normalize a string.
120      *
121      * @param source The string to normalize.
122      * @return The normalized string.
123      */

124     String JavaDoc standardize(String JavaDoc source);
125     
126     /**
127      * Return the name of the repository
128      *
129      */

130     String JavaDoc getName();
131 }
132
Popular Tags