KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jnlp > DownloadService


1 /*
2  * @(#)DownloadService.java 1.14 04/03/12
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.jnlp;
9
10 import java.net.URL;
11 import java.io.IOException;
12
13 /**
14  * <code>DownloadService</code> service allows an application
15  * to control how its own resources are cached, to determine
16  * which of its resources are currently cached, to force resources
17  * to be cached, and to remove resources from the cache. The JNLP
18  * Client is responsible for providing a specific implementation of
19  * this service.
20  *
21  * @since 1.0
22  */

23
24 public interface DownloadService {
25     
26     /**
27      * Returns <code>true</code> if the resource referred to by the
28      * given URL and version is cached, and that resource is
29      * mentioned in the JNLP file for the application.
30      *
31      * @param ref The URL for the resource.
32      *
33      * @param version The version string, or <code>null</code> for
34      * no version.
35      *
36      * @return <code>true</code> if the above conditions are
37      * met, and <code>false</code> otherwise.
38      */

39     public boolean isResourceCached(URL ref, String version);
40     
41     /**
42      * Returns <code>true</code> if the part referred to by the
43      * given string is cached, and that part is
44      * mentioned in the JNLP file for the application.
45      *
46      * @param part The name of the part.
47      *
48      * @return <code>true</code> if the above conditions are
49      * met, and <code>false</code> otherwise.
50      */

51     public boolean isPartCached(String part);
52     
53     /**
54      * Returns <code>true</code> if the parts referred to by the
55      * given array are cached, and those parts are
56      * mentioned in the JNLP file for the application.
57      *
58      * @param parts An array of part names.
59      *
60      * @return <code>true</code> if the above conditions are
61      * met, and <code>false</code> otherwise.
62      */

63     public boolean isPartCached(String [] parts);
64     
65     /**
66      * Returns <code>true</code> if the given part of the given
67      * extension is cached, and the extension and part are
68      * mentioned in the JNLP file for the application.
69      *
70      * @param ref The URL for the resource.
71      *
72      * @param version The version string, or <code>null</code> for
73      * no version.
74      *
75      * @param part The name of the part.
76      *
77      * @return <code>true</code> if the above conditions are
78      * met, and <code>false</code> otherwise.
79      */

80     public boolean isExtensionPartCached(URL ref, String version, String part);
81     
82     /**
83      * Returns <code>true</code> if the given parts of the given
84      * extension are cached, and the extension and parts are
85      * mentioned in the JNLP file for the application.
86      *
87      * @param ref The URL for the resource.
88      *
89      * @param version The version string, or <code>null</code> for
90      * no version.
91      *
92      * @param parts An array of part names.
93      *
94      * @return <code>true</code> if the above conditions are
95      * met, and <code>false</code> otherwise.
96      */

97     public boolean isExtensionPartCached(URL ref, String version, String [] parts);
98     
99     /**
100      * Downloads the given resource, if the resource is mentioned in
101      * the JNLP file for the application. This method will block
102      * until the download is completed or an exception occurs.
103      *
104      * @param ref The URL for the resource.
105      *
106      * @param version The version string, or <code>null</code> for
107      * no version.
108      *
109      * @param progress Download progress callback object.
110      */

111     public void loadResource(URL ref, String version, DownloadServiceListener progress) throws IOException;
112     
113     /**
114      * Downloads the given part, if the part is mentioned in
115      * the JNLP file for the application. This method will block
116      * until the download is completed or an exception occurs.
117      *
118      * @param part The name of the part.
119      *
120      * @param progress Download progress callback object.
121      */

122     public void loadPart(String part, DownloadServiceListener progress) throws IOException;
123     
124     /**
125      * Downloads the given parts, if the parts are mentioned in
126      * the JNLP file for the application. This method will block
127      * until the download is completed or an exception occurs.
128      *
129      * @param parts An array of part names.
130      *
131      * @param progress Download progress callback object.
132      */

133     public void loadPart(String [] parts, DownloadServiceListener progress) throws IOException;
134     
135     /**
136      * Downloads the given part of the given extension, if the part
137      * and the extension are mentioned in the JNLP file for the
138      * application. This method will block until the download is
139      * completed or an exception occurs.
140      *
141      * @param ref The URL for the resource.
142      *
143      * @param version The version string, or <code>null</code> for
144      * no version.
145      *
146      * @param part The name of the part.
147      *
148      * @param progress Download progress callback object.
149      */

150     public void loadExtensionPart(URL ref, String version, String part, DownloadServiceListener progress)
151         throws IOException;
152     
153     /**
154      * Downloads the given parts of the given extension, if the parts
155      * and the extension are mentioned in the JNLP file for the
156      * application. This method will block until the download is
157      * completed or an exception occurs.
158      *
159      * @param ref The URL for the resource.
160      *
161      * @param version The version string, or <code>null</code> for
162      * no version.
163      *
164      * @param parts An array of part names to load.
165      *
166      * @param progress Download progress callback object.
167      */

168     public void loadExtensionPart(URL ref, String version, String [] parts, DownloadServiceListener progress)
169         throws IOException;
170     
171     /**
172      * Removes the given resource from the cache, if the resource
173      * is mentioned in the JNLP file for the application.
174      *
175      * @param ref The URL for the resource.
176      *
177      * @param version The version string, or <code>null</code> for
178      * no version.
179      */

180     public void removeResource(URL ref, String version) throws IOException;
181     
182     /**
183      * Removes the given part from the cache, if the part
184      * is mentioned in the JNLP file for the application.
185      *
186      * @param part The name of the part.
187      */

188     public void removePart(String part) throws IOException;
189     
190     /**
191      * Removes the given parts from the cache, if the parts
192      * are mentioned in the JNLP file for the application.
193      *
194      * @param parts An array of part names.
195      */

196     public void removePart(String [] parts) throws IOException;
197     
198     /**
199      * Removes the given part of the given extension from the cache,
200      * if the part and the extension are mentioned in the JNLP file
201      * for the application.
202      * @param ref The URL for the resource.
203      *
204      * @param version The version string, or <code>null</code> for
205      * no version.
206      *
207      * @param part The name of the part.
208      */

209     public void removeExtensionPart(URL ref, String version, String part) throws IOException;
210     
211     /**
212      * Removes the given parts of the given extension from the cache,
213      * if the parts and the extension are mentioned in the JNLP file
214      * for the application.
215      * @param ref The URL for the resource.
216      *
217      * @param version The version string, or <code>null</code> for
218      * no version.
219      *
220      * @param parts An array of part names.
221      */

222     public void removeExtensionPart(URL ref, String version, String [] parts) throws IOException;
223     
224     /**
225      * Return a default {@link DownloadServiceListener} implementation which, when passed to
226      * a <code>load</code> method, should pop up and update a progress window as the load
227      * progresses.
228      *
229      * @return A <code>DownloadServiceListener</code> object representing a download progress
230      * listener.
231      */

232     public DownloadServiceListener getDefaultProgressWindow();
233     
234 }
235
Popular Tags