blob: 5ba4f7bd4ee5bee275f2df6f908cd220fae22662 [file] [log] [blame]
Richard S. Hall2532cf82010-03-24 09:51:11 +00001/*
Carsten Ziegeler3314f912014-07-30 07:22:32 +00002 * Copyright (c) OSGi Alliance (2002, 2013). All Rights Reserved.
Richard S. Hall2532cf82010-03-24 09:51:11 +00003 *
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
17package org.osgi.service.url;
18
Carsten Ziegeler3314f912014-07-30 07:22:32 +000019import java.net.InetAddress;
20import java.net.URL;
21import java.net.URLConnection;
22import org.osgi.annotation.versioning.ConsumerType;
Richard S. Hall2532cf82010-03-24 09:51:11 +000023
24/**
25 * Service interface with public versions of the protected
Richard S. Halld0dca9b2011-05-18 14:52:16 +000026 * {@code java.net.URLStreamHandler} methods.
Richard S. Hall2532cf82010-03-24 09:51:11 +000027 * <p>
28 * The important differences between this interface and the
Richard S. Halldfd78a42012-05-11 20:19:02 +000029 * {@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. Hall2532cf82010-03-24 09:51:11 +000035 *
36 * @see AbstractURLStreamHandlerService
37 *
38 * @ThreadSafe
Carsten Ziegeler3314f912014-07-30 07:22:32 +000039 * @author $Id: 810d8718f5ad689981fbb2c22886ad2695f17297 $
Richard S. Hall2532cf82010-03-24 09:51:11 +000040 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +000041@ConsumerType
Richard S. Hall2532cf82010-03-24 09:51:11 +000042public interface URLStreamHandlerService {
43 /**
44 * @see "java.net.URLStreamHandler.openConnection"
45 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +000046 @SuppressWarnings("javadoc")
Richard S. Hall2532cf82010-03-24 09:51:11 +000047 public URLConnection openConnection(URL u) throws java.io.IOException;
48
49 /**
Richard S. Halldfd78a42012-05-11 20:19:02 +000050 * 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. Hall2532cf82010-03-24 09:51:11 +000053 *
Richard S. Halldfd78a42012-05-11 20:19:02 +000054 * @param realHandler The object on which {@code setURL} must be invoked for
55 * this URL.
Richard S. Hall2532cf82010-03-24 09:51:11 +000056 * @see "java.net.URLStreamHandler.parseURL"
57 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +000058 @SuppressWarnings("javadoc")
Richard S. Halldfd78a42012-05-11 20:19:02 +000059 public void parseURL(URLStreamHandlerSetter realHandler, URL u, String spec, int start, int limit);
Richard S. Hall2532cf82010-03-24 09:51:11 +000060
61 /**
62 * @see "java.net.URLStreamHandler.toExternalForm"
63 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +000064 @SuppressWarnings("javadoc")
Richard S. Hall2532cf82010-03-24 09:51:11 +000065 public String toExternalForm(URL u);
66
67 /**
68 * @see "java.net.URLStreamHandler.equals(URL, URL)"
69 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +000070 @SuppressWarnings("javadoc")
Richard S. Hall2532cf82010-03-24 09:51:11 +000071 public boolean equals(URL u1, URL u2);
72
73 /**
74 * @see "java.net.URLStreamHandler.getDefaultPort"
75 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +000076 @SuppressWarnings("javadoc")
Richard S. Hall2532cf82010-03-24 09:51:11 +000077 public int getDefaultPort();
78
79 /**
80 * @see "java.net.URLStreamHandler.getHostAddress"
81 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +000082 @SuppressWarnings("javadoc")
Richard S. Hall2532cf82010-03-24 09:51:11 +000083 public InetAddress getHostAddress(URL u);
84
85 /**
86 * @see "java.net.URLStreamHandler.hashCode(URL)"
87 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +000088 @SuppressWarnings("javadoc")
Richard S. Hall2532cf82010-03-24 09:51:11 +000089 public int hashCode(URL u);
90
91 /**
92 * @see "java.net.URLStreamHandler.hostsEqual"
93 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +000094 @SuppressWarnings("javadoc")
Richard S. Hall2532cf82010-03-24 09:51:11 +000095 public boolean hostsEqual(URL u1, URL u2);
96
97 /**
98 * @see "java.net.URLStreamHandler.sameFile"
99 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +0000100 @SuppressWarnings("javadoc")
Richard S. Hall2532cf82010-03-24 09:51:11 +0000101 public boolean sameFile(URL u1, URL u2);
102}