Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 1 | /* |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 2 | * Copyright (c) OSGi Alliance (2002, 2013). All Rights Reserved. |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.osgi.service.url; |
| 18 | |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 19 | import java.net.InetAddress; |
| 20 | import java.net.URL; |
| 21 | import java.net.URLConnection; |
| 22 | import org.osgi.annotation.versioning.ConsumerType; |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Service interface with public versions of the protected |
Richard S. Hall | d0dca9b | 2011-05-18 14:52:16 +0000 | [diff] [blame] | 26 | * {@code java.net.URLStreamHandler} methods. |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 27 | * <p> |
| 28 | * The important differences between this interface and the |
Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [diff] [blame] | 29 | * {@code URLStreamHandler} class are that the {@code setURL} method is absent |
| 30 | * and the {@code parseURL} method takes a {@link URLStreamHandlerSetter} object |
| 31 | * as the first argument. Classes implementing this interface must call the |
| 32 | * {@code setURL} method on the {@code URLStreamHandlerSetter} object received |
| 33 | * in the {@code parseURL} method instead of {@code URLStreamHandler.setURL} to |
| 34 | * avoid a {@code SecurityException}. |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 35 | * |
| 36 | * @see AbstractURLStreamHandlerService |
| 37 | * |
| 38 | * @ThreadSafe |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 39 | * @author $Id: 810d8718f5ad689981fbb2c22886ad2695f17297 $ |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 40 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 41 | @ConsumerType |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 42 | public interface URLStreamHandlerService { |
| 43 | /** |
| 44 | * @see "java.net.URLStreamHandler.openConnection" |
| 45 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 46 | @SuppressWarnings("javadoc") |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 47 | public URLConnection openConnection(URL u) throws java.io.IOException; |
| 48 | |
| 49 | /** |
Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [diff] [blame] | 50 | * Parse a URL. This method is called by the {@code URLStreamHandler} proxy, |
| 51 | * instead of {@code java.net.URLStreamHandler.parseURL}, passing a |
| 52 | * {@code URLStreamHandlerSetter} object. |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 53 | * |
Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [diff] [blame] | 54 | * @param realHandler The object on which {@code setURL} must be invoked for |
| 55 | * this URL. |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 56 | * @see "java.net.URLStreamHandler.parseURL" |
| 57 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 58 | @SuppressWarnings("javadoc") |
Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [diff] [blame] | 59 | public void parseURL(URLStreamHandlerSetter realHandler, URL u, String spec, int start, int limit); |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 60 | |
| 61 | /** |
| 62 | * @see "java.net.URLStreamHandler.toExternalForm" |
| 63 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 64 | @SuppressWarnings("javadoc") |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 65 | public String toExternalForm(URL u); |
| 66 | |
| 67 | /** |
| 68 | * @see "java.net.URLStreamHandler.equals(URL, URL)" |
| 69 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 70 | @SuppressWarnings("javadoc") |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 71 | public boolean equals(URL u1, URL u2); |
| 72 | |
| 73 | /** |
| 74 | * @see "java.net.URLStreamHandler.getDefaultPort" |
| 75 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 76 | @SuppressWarnings("javadoc") |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 77 | public int getDefaultPort(); |
| 78 | |
| 79 | /** |
| 80 | * @see "java.net.URLStreamHandler.getHostAddress" |
| 81 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 82 | @SuppressWarnings("javadoc") |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 83 | public InetAddress getHostAddress(URL u); |
| 84 | |
| 85 | /** |
| 86 | * @see "java.net.URLStreamHandler.hashCode(URL)" |
| 87 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 88 | @SuppressWarnings("javadoc") |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 89 | public int hashCode(URL u); |
| 90 | |
| 91 | /** |
| 92 | * @see "java.net.URLStreamHandler.hostsEqual" |
| 93 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 94 | @SuppressWarnings("javadoc") |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 95 | public boolean hostsEqual(URL u1, URL u2); |
| 96 | |
| 97 | /** |
| 98 | * @see "java.net.URLStreamHandler.sameFile" |
| 99 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 100 | @SuppressWarnings("javadoc") |
Richard S. Hall | 2532cf8 | 2010-03-24 09:51:11 +0000 | [diff] [blame] | 101 | public boolean sameFile(URL u1, URL u2); |
| 102 | } |