KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > service > urlconversion > URLConverter


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.osgi.service.urlconversion;
12
13 import java.io.IOException JavaDoc;
14 import java.net.URL JavaDoc;
15
16 /**
17  * The interface of the service that allows client-defined protocol
18  * URLs to be converted to native file URLs on the local file system.
19  * <p>
20  * Clients may implement this interface.
21  * </p>
22  *
23  * @since 3.1
24  */

25 public interface URLConverter {
26
27     /**
28      * Converts a URL that uses a user-defined protocol into a URL that uses the file
29      * protocol. The contents of the URL may be extracted into a cache on the file-system
30      * in order to get a file URL.
31      * <p>
32      * If the protocol for the given URL is not recognized by this converter, the original
33      * URL is returned as-is.
34      * </p>
35      * @param url the original URL
36      * @return the converted file URL or the original URL passed in if it is
37      * not recognized by this converter
38      * @throws IOException if an error occurs during the conversion
39      * @since 3.2
40      */

41     public URL JavaDoc toFileURL(URL JavaDoc url) throws IOException JavaDoc;
42
43     /**
44      * Converts a URL that uses a client-defined protocol into a URL that uses a
45      * protocol which is native to the Java class library (file, jar, http, etc).
46      * <p>
47      * Note however that users of this API should not assume too much about the
48      * results of this method. While it may consistently return a file: URL in certain
49      * installation configurations, others may result in jar: or http: URLs.
50      * </p>
51      * <p>
52      * If the protocol is not reconized by this converter, then the original URL is
53      * returned as-is.
54      * </p>
55      * @param url the original URL
56      * @return the resolved URL or the original if the protocol is unknown to this converter
57      * @exception IOException if unable to resolve URL
58      * @throws IOException if an error occurs during the resolution
59      * @since 3.2
60      */

61     public URL JavaDoc resolve(URL JavaDoc url) throws IOException JavaDoc;
62 }
63
Popular Tags