URL.java revision 5426
2362N/A * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Class <code>URL</code> represents a Uniform Resource 0N/A * Locator, a pointer to a "resource" on the World 0N/A * Wide Web. A resource can be something as simple as a file or a 0N/A * directory, or it can be a reference to a more complicated object, 0N/A * such as a query to a database or to a search engine. More 0N/A * information on the types of URLs and their formats can be found at: 0N/A * In general, a URL can be broken into several parts. The previous 0N/A * example of a URL indicates that the protocol to use is 0N/A * <code>http</code> (HyperText Transfer Protocol) and that the 0N/A * information resides on a host machine named 0N/A * <code>www.socs.uts.edu.au</code>. The information on that host 0N/A * meaning of this name on the host machine is both protocol 0N/A * dependent and host dependent. The information normally resides in 0N/A * a file, but it could be generated on the fly. This component of 0N/A * the URL is called the <i>path</i> component. 0N/A * A URL can optionally specify a "port", which is the 0N/A * port number to which the TCP connection is made on the remote host 0N/A * machine. If the port is not specified, the default port for 0N/A * the protocol is used instead. For example, the default port for 0N/A * <code>http</code> is <code>80</code>. An alternative port could be 0N/A * </pre></blockquote> 0N/A * The syntax of <code>URL</code> is defined by <a 0N/A * Resource Identifiers (URI): Generic Syntax</i></a>, amended by <a 0N/A * Literal IPv6 Addresses in URLs</i></a>. The Literal IPv6 address format 0N/A * also supports scope_ids. The syntax and usage of scope_ids is described 0N/A * A URL may have appended to it a "fragment", also known 0N/A * as a "ref" or a "reference". The fragment is indicated by the sharp 0N/A * sign character "#" followed by more characters. For example, 0N/A * </pre></blockquote> 0N/A * This fragment is not technically part of the URL. Rather, it 0N/A * indicates that after the specified resource is retrieved, the 0N/A * application is specifically interested in that part of the 0N/A * document that has the tag <code>chapter1</code> attached to it. The 0N/A * meaning of a tag is resource specific. 0N/A * An application can also specify a "relative URL", 0N/A * which contains only enough information to reach the resource 0N/A * relative to another URL. Relative URLs are frequently used within 0N/A * HTML pages. For example, if the contents of the URL: 0N/A * </pre></blockquote> 0N/A * contained within it the relative URL: 0N/A * </pre></blockquote> 0N/A * it would be a shorthand for: 0N/A * </pre></blockquote> 0N/A * The relative URL need not specify all the components of a URL. If 0N/A * the protocol, host name, or port number is missing, the value is 0N/A * inherited from the fully specified URL. The file component must be 0N/A * specified. The optional fragment is not inherited. 0N/A * The URL class does not itself encode or decode any URL components 0N/A * according to the escaping mechanism defined in RFC2396. It is the 0N/A * responsibility of the caller to encode any fields, which need to be 0N/A * escaped prior to calling URL, and also to decode any escaped fields, 0N/A * that are returned from URL. Furthermore, because URL has no knowledge 0N/A * of URL escaping, it does not recognise equivalence between the encoded 0N/A * or decoded form of the same URL. For example, the two URLs:<br> 0N/A * would be considered not equal to each other. 0N/A * Note, the {@link java.net.URI} class does perform escaping of its 0N/A * component fields in certain circumstances. The recommended way 0N/A * to manage the encoding and decoding of URLs is to use {@link java.net.URI}, 0N/A * and to convert between these two classes using {@link #toURI()} and 0N/A * {@link URI#toURL()}. 0N/A * The {@link URLEncoder} and {@link URLDecoder} classes can also be 0N/A * used, but only for HTML form encoding, which is not the same 0N/A * as the encoding scheme defined in RFC2396. 0N/A * @author James Gosling 0N/A * The property which specifies the package prefix list to be scanned 0N/A * for protocol handlers. The value of this property (if any) should 0N/A * be a vertical bar delimited list of package names to search through 0N/A * for a protocol handler to load. The policy of this class is that 0N/A * all protocol handlers will be in a class called <protocolname>.Handler, 0N/A * and each package in the list is examined in turn for a matching 0N/A * handler. If none are found (or the property is not specified), the 0N/A * default package prefix, sun.net.www.protocol, is used. The search 0N/A * proceeds from the first package in the list to the last and stops 0N/A * when a match is found. 0N/A * The protocol to use (ftp, http, nntp, ... etc.) . 0N/A * The host name to connect to. 0N/A * The protocol port to connect to. 0N/A * The specified file name on that host. <code>file</code> is 0N/A * defined as <code>path[?query]</code> 0N/A * The query part of this URL. 0N/A * The authority part of this URL. 0N/A * The path part of this URL. 0N/A * The userinfo part of this URL. 0N/A * The host's IP address, used in equals and hashCode. 0N/A * Computed on demand. An uninitialized or unknown hostAddress is null. 0N/A * The URLStreamHandler for this URL. 0N/A * Creates a <code>URL</code> object from the specified 0N/A * <code>protocol</code>, <code>host</code>, <code>port</code> 0N/A * number, and <code>file</code>.<p> 0N/A * <code>host</code> can be expressed as a host name or a literal 0N/A * IP address. If IPv6 literal address is used, it should be 0N/A * enclosed in square brackets (<tt>'['</tt> and <tt>']'</tt>), as 0N/A * However, the literal IPv6 address format defined in <a 0N/A * Version 6 Addressing Architecture</i></a> is also accepted.<p> 0N/A * Specifying a <code>port</code> number of <code>-1</code> 0N/A * indicates that the URL should use the default port for the 0N/A * If this is the first URL object being created with the specified 0N/A * protocol, a <i>stream protocol handler</i> object, an instance of 0N/A * class <code>URLStreamHandler</code>, is created for that protocol: 0N/A * <li>If the application has previously set up an instance of 0N/A * <code>URLStreamHandlerFactory</code> as the stream handler factory, 0N/A * then the <code>createURLStreamHandler</code> method of that instance 0N/A * is called with the protocol string as an argument to create the 0N/A * stream protocol handler. 0N/A * <li>If no <code>URLStreamHandlerFactory</code> has yet been set up, 0N/A * or if the factory's <code>createURLStreamHandler</code> method 0N/A * returns <code>null</code>, then the constructor finds the 0N/A * value of the system property: 0N/A * java.protocol.handler.pkgs 0N/A * </pre></blockquote> 0N/A * If the value of that system property is not <code>null</code>, 0N/A * it is interpreted as a list of packages separated by a vertical 0N/A * slash character '<code>|</code>'. The constructor tries to load 0N/A * <<i>package</i>>.<<i>protocol</i>>.Handler 0N/A * </pre></blockquote> 0N/A * where <<i>package</i>> is replaced by the name of the package 0N/A * and <<i>protocol</i>> is replaced by the name of the protocol. 0N/A * If this class does not exist, or if the class exists but it is not 0N/A * a subclass of <code>URLStreamHandler</code>, then the next package 0N/A * in the list is tried. 0N/A * <li>If the previous step fails to find a protocol handler, then the 0N/A * constructor tries to load from a system default package. 0N/A * <<i>system default package</i>>.<<i>protocol</i>>.Handler 0N/A * </pre></blockquote> 0N/A * If this class does not exist, or if the class exists but it is not a 0N/A * subclass of <code>URLStreamHandler</code>, then a 0N/A * <code>MalformedURLException</code> is thrown. 0N/A * <p>Protocol handlers for the following protocols are guaranteed 0N/A * to exist on the search path :- 0N/A * http, https, ftp, file, and jar 0N/A * </pre></blockquote> 0N/A * Protocol handlers for additional protocols may also be 0N/A * <p>No validation of the inputs is performed by this constructor. 0N/A * @param protocol the name of the protocol to use. 0N/A * @param host the name of the host. 0N/A * @param port the port number on the host. 0N/A * @param file the file on the host 0N/A * @exception MalformedURLException if an unknown protocol is specified. 0N/A * @see java.lang.System#getProperty(java.lang.String) 0N/A * @see java.net.URL#setURLStreamHandlerFactory( 0N/A * java.net.URLStreamHandlerFactory) 0N/A * @see java.net.URLStreamHandler 0N/A * @see java.net.URLStreamHandlerFactory#createURLStreamHandler( 0N/A * Creates a URL from the specified <code>protocol</code> 0N/A * name, <code>host</code> name, and <code>file</code> name. The 0N/A * default port for the specified protocol is used. 0N/A * This method is equivalent to calling the four-argument 0N/A * constructor with the arguments being <code>protocol</code>, 0N/A * <code>host</code>, <code>-1</code>, and <code>file</code>. 0N/A * No validation of the inputs is performed by this constructor. 0N/A * @param protocol the name of the protocol to use. 0N/A * @param host the name of the host. 0N/A * @param file the file on the host. 0N/A * @exception MalformedURLException if an unknown protocol is specified. 0N/A * @see java.net.URL#URL(java.lang.String, java.lang.String, 0N/A * int, java.lang.String) 0N/A * Creates a <code>URL</code> object from the specified 0N/A * <code>protocol</code>, <code>host</code>, <code>port</code> 0N/A * number, <code>file</code>, and <code>handler</code>. Specifying 0N/A * a <code>port</code> number of <code>-1</code> indicates that 0N/A * the URL should use the default port for the protocol. Specifying 0N/A * a <code>handler</code> of <code>null</code> indicates that the URL 0N/A * should use a default stream handler for the protocol, as outlined 0N/A * java.net.URL#URL(java.lang.String, java.lang.String, int, 0N/A * <p>If the handler is not null and there is a security manager, 0N/A * the security manager's <code>checkPermission</code> 0N/A * method is called with a 0N/A * <code>NetPermission("specifyStreamHandler")</code> permission. 0N/A * This may result in a SecurityException. 0N/A * No validation of the inputs is performed by this constructor. 0N/A * @param protocol the name of the protocol to use. 0N/A * @param host the name of the host. 0N/A * @param port the port number on the host. 0N/A * @param file the file on the host 0N/A * @param handler the stream handler for the URL. 0N/A * @exception MalformedURLException if an unknown protocol is specified. 0N/A * @exception SecurityException 0N/A * if a security manager exists and its 0N/A * <code>checkPermission</code> method doesn't allow 0N/A * specifying a stream handler explicitly. 0N/A * @see java.lang.System#getProperty(java.lang.String) 0N/A * @see java.net.URL#setURLStreamHandlerFactory( 0N/A * java.net.URLStreamHandlerFactory) 0N/A * @see java.net.URLStreamHandler 0N/A * @see java.net.URLStreamHandlerFactory#createURLStreamHandler( 0N/A * @see SecurityManager#checkPermission 0N/A * @see java.net.NetPermission 0N/A // check for permission to specify a handler 0N/A * if host is a literal IPv6 address, 0N/A * we will make it conform to RFC 2732 0N/A // Note: we don't do validation of the URL here. Too risky to change 0N/A // right now, but worth considering for future reference. -br 0N/A * Creates a <code>URL</code> object from the <code>String</code> 0N/A * This constructor is equivalent to a call to the two-argument 0N/A * constructor with a <code>null</code> first argument. 0N/A * @param spec the <code>String</code> to parse as a URL. 0N/A * @exception MalformedURLException if no protocol is specified, or an 0N/A * unknown protocol is found, or <tt>spec</tt> is <tt>null</tt>. 0N/A * @see java.net.URL#URL(java.net.URL, java.lang.String) 0N/A * Creates a URL by parsing the given spec within a specified context. 0N/A * The new URL is created from the given context URL and the spec 0N/A * argument as described in 0N/A * RFC2396 "Uniform Resource Identifiers : Generic * Syntax" : 0N/A * <scheme>://<authority><path>?<query>#<fragment> 0N/A * </pre></blockquote> 0N/A * The reference is parsed into the scheme, authority, path, query and 0N/A * fragment parts. If the path component is empty and the scheme, 0N/A * authority, and query components are undefined, then the new URL is a 0N/A * reference to the current document. Otherwise, the fragment and query 0N/A * parts present in the spec are used in the new URL. 0N/A * If the scheme component is defined in the given spec and does not match 0N/A * the scheme of the context, then the new URL is created as an absolute 0N/A * URL based on the spec alone. Otherwise the scheme component is inherited 0N/A * from the context URL. 0N/A * If the authority component is present in the spec then the spec is 0N/A * treated as absolute and the spec authority and path will replace the 0N/A * context authority and path. If the authority component is absent in the 0N/A * spec then the authority of the new URL will be inherited from the 0N/A * If the spec's path component begins with a slash character 0N/A * "/" then the 0N/A * path is treated as absolute and the spec path replaces the context path. 0N/A * Otherwise, the path is treated as a relative path and is appended to the 0N/A * context path, as described in RFC2396. Also, in this case, 0N/A * the path is canonicalized through the removal of directory 0N/A * changes made by occurences of ".." and ".". 0N/A * For a more detailed description of URL parsing, refer to RFC2396. 0N/A * @param context the context in which to parse the specification. 0N/A * @param spec the <code>String</code> to parse as a URL. 0N/A * @exception MalformedURLException if no protocol is specified, or an 0N/A * unknown protocol is found, or <tt>spec</tt> is <tt>null</tt>. 0N/A * @see java.net.URL#URL(java.lang.String, java.lang.String, 0N/A * int, java.lang.String) 0N/A * @see java.net.URLStreamHandler 0N/A * @see java.net.URLStreamHandler#parseURL(java.net.URL, 0N/A * java.lang.String, int, int) 0N/A * Creates a URL by parsing the given spec with the specified handler 0N/A * within a specified context. If the handler is null, the parsing 0N/A * occurs as with the two argument constructor. 0N/A * @param context the context in which to parse the specification. 0N/A * @param spec the <code>String</code> to parse as a URL. 0N/A * @param handler the stream handler for the URL. 0N/A * @exception MalformedURLException if no protocol is specified, or an 0N/A * unknown protocol is found, or <tt>spec</tt> is <tt>null</tt>. 0N/A * @exception SecurityException 0N/A * if a security manager exists and its 0N/A * <code>checkPermission</code> method doesn't allow 0N/A * specifying a stream handler. 0N/A * @see java.net.URL#URL(java.lang.String, java.lang.String, 0N/A * int, java.lang.String) 0N/A * @see java.net.URLStreamHandler 0N/A * @see java.net.URLStreamHandler#parseURL(java.net.URL, 0N/A * java.lang.String, int, int) 0N/A // Check for permission to specify a handler 0N/A limit--;
//eliminate trailing whitespace 0N/A start++;
// eliminate leading whitespace 0N/A /* we're assuming this is a ref relative to the context URL. 0N/A * This means protocols cannot start w/ '#', but we must parse 0N/A * ref URL's like: "hello:there" w/ a ':' in them. 0N/A // Only use our context if the protocols match. 0N/A // inherit the protocol handler from the context 0N/A // if not specified to the constructor 0N/A // If the context is a hierarchical URL scheme and the spec 0N/A // contains a matching scheme then maintain backwards 0N/A // compatibility and treat it as if the spec didn't contain 0N/A // the scheme; see 5.2.3 of RFC2396 0N/A // Get the protocol handler if not specified or the protocol 0N/A // of the context could not be used 0N/A * Handle special case inheritance of query and fragment 0N/A * implied by RFC2396 section 5.2.2. 0N/A * Returns true if specified string is a valid protocol name. 0N/A for (
int i =
1; i <
len; i++) {
0N/A * Checks for permission to specify a stream handler. 0N/A * Sets the fields of the URL. This is not a public method so that 0N/A * only URLStreamHandlers can modify URL fields. URLs are 0N/A * otherwise constant. 0N/A * @param protocol the name of the protocol to use 0N/A * @param host the name of the host 0N/A @param port the port number on the host 0N/A * @param file the file on the host 0N/A * @param ref the internal reference in the URL 0N/A synchronized (
this) {
0N/A /* This is very important. We must recompute this after the 0N/A * URL has been changed. */ 0N/A * Sets the specified 8 fields of the URL. This is not a public method so 0N/A * that only URLStreamHandlers can modify URL fields. URLs are otherwise 0N/A * @param protocol the name of the protocol to use 0N/A * @param host the name of the host 0N/A * @param port the port number on the host 0N/A * @param authority the authority part for the url 0N/A * @param userInfo the username and password 0N/A * @param path the file on the host 0N/A * @param ref the internal reference in the URL 0N/A * @param query the query part of this URL 0N/A synchronized (
this) {
0N/A /* This is very important. We must recompute this after the 0N/A * URL has been changed. */ 0N/A * Gets the query part of this <code>URL</code>. 0N/A * @return the query part of this <code>URL</code>, 0N/A * or <CODE>null</CODE> if one does not exist 0N/A * Gets the path part of this <code>URL</code>. 0N/A * @return the path part of this <code>URL</code>, or an 0N/A * empty string if one does not exist 0N/A * Gets the userInfo part of this <code>URL</code>. 0N/A * @return the userInfo part of this <code>URL</code>, or 0N/A * <CODE>null</CODE> if one does not exist 0N/A * Gets the authority part of this <code>URL</code>. 0N/A * @return the authority part of this <code>URL</code> 0N/A * Gets the port number of this <code>URL</code>. 0N/A * @return the port number, or -1 if the port is not set 0N/A * Gets the default port number of the protocol associated 0N/A * with this <code>URL</code>. If the URL scheme or the URLStreamHandler 0N/A * for the URL do not define a default port number, 0N/A * then -1 is returned. 0N/A * @return the port number 0N/A * Gets the protocol name of this <code>URL</code>. 0N/A * @return the protocol of this <code>URL</code>. 0N/A * Gets the host name of this <code>URL</code>, if applicable. 0N/A * The format of the host conforms to RFC 2732, i.e. for a 0N/A * literal IPv6 address, this method will return the IPv6 address 0N/A * enclosed in square brackets (<tt>'['</tt> and <tt>']'</tt>). 0N/A * @return the host name of this <code>URL</code>. 0N/A * Gets the file name of this <code>URL</code>. 0N/A * The returned file portion will be 0N/A * the same as <CODE>getPath()</CODE>, plus the concatenation of 0N/A * the value of <CODE>getQuery()</CODE>, if any. If there is 0N/A * no query portion, this method and <CODE>getPath()</CODE> will 0N/A * return identical results. 0N/A * @return the file name of this <code>URL</code>, 0N/A * or an empty string if one does not exist 0N/A * Gets the anchor (also known as the "reference") of this 0N/A * @return the anchor (also known as the "reference") of this 0N/A * <code>URL</code>, or <CODE>null</CODE> if one does not exist 0N/A * Compares this URL for equality with another object.<p> 0N/A * If the given object is not a URL then this method immediately returns 0N/A * <code>false</code>.<p> 0N/A * Two URL objects are equal if they have the same protocol, reference 0N/A * equivalent hosts, have the same port number on the host, and the same 0N/A * file and fragment of the file.<p> 0N/A * Two hosts are considered equivalent if both host names can be resolved 0N/A * into the same IP addresses; else if either host name can't be 0N/A * resolved, the host names must be equal without regard to case; or both 0N/A * host names equal to null.<p> 0N/A * Since hosts comparison requires name resolution, this operation is a 0N/A * blocking operation. <p> 0N/A * Note: The defined behavior for <code>equals</code> is known to 0N/A * be inconsistent with virtual hosting in HTTP. 0N/A * @param obj the URL to compare against. 0N/A * @return <code>true</code> if the objects are the same; 0N/A * <code>false</code> otherwise. 0N/A * Creates an integer suitable for hash table indexing.<p> 0N/A * The hash code is based upon all the URL components relevant for URL 0N/A * comparison. As such, this operation is a blocking operation.<p> 0N/A * @return a hash code for this <code>URL</code>. 0N/A * Compares two URLs, excluding the fragment component.<p> 0N/A * Returns <code>true</code> if this <code>URL</code> and the 0N/A * <code>other</code> argument are equal without taking the 0N/A * fragment component into consideration. 0N/A * @param other the <code>URL</code> to compare against. 0N/A * @return <code>true</code> if they reference the same remote object; 0N/A * <code>false</code> otherwise. 0N/A * Constructs a string representation of this <code>URL</code>. The 0N/A * string is created by calling the <code>toExternalForm</code> 0N/A * method of the stream protocol handler for this object. 0N/A * @return a string representation of this object. 0N/A * @see java.net.URL#URL(java.lang.String, java.lang.String, int, 0N/A * @see java.net.URLStreamHandler#toExternalForm(java.net.URL) 0N/A * Constructs a string representation of this <code>URL</code>. The 0N/A * string is created by calling the <code>toExternalForm</code> 0N/A * method of the stream protocol handler for this object. 0N/A * @return a string representation of this object. 0N/A * @see java.net.URL#URL(java.lang.String, java.lang.String, 0N/A * int, java.lang.String) 0N/A * @see java.net.URLStreamHandler#toExternalForm(java.net.URL) 0N/A * Returns a {@link java.net.URI} equivalent to this URL. 0N/A * This method functions in the same way as <code>new URI (this.toString())</code>. 0N/A * <p>Note, any URL instance that complies with RFC 2396 can be converted 0N/A * to a URI. However, some URLs that are not strictly in compliance 0N/A * can not be converted to a URI. 0N/A * @exception URISyntaxException if this URL is not formatted strictly according to 0N/A * to RFC2396 and cannot be converted to a URI. 0N/A * @return a URI instance equivalent to this URL. 0N/A * Returns a {@link java.net.URLConnection URLConnection} instance that 0N/A * represents a connection to the remote object referred to by the 0N/A * <P>A new instance of {@linkplain java.net.URLConnection URLConnection} is 0N/A * created every time when invoking the 0N/A * {@linkplain java.net.URLStreamHandler#openConnection(URL) 0N/A * URLStreamHandler.openConnection(URL)} method of the protocol handler for 0N/A * <P>It should be noted that a URLConnection instance does not establish 0N/A * the actual network connection on creation. This will happen only when 0N/A * calling {@linkplain java.net.URLConnection#connect() URLConnection.connect()}.</P> 0N/A * <P>If for the URL's protocol (such as HTTP or JAR), there 0N/A * exists a public, specialized URLConnection subclass belonging 0N/A * to one of the following packages or one of their subpackages: 0N/A * java.lang, java.io, java.util, java.net, the connection 0N/A * returned will be of that subclass. For example, for HTTP an 0N/A * HttpURLConnection will be returned, and for JAR a 0N/A * JarURLConnection will be returned.</P> 0N/A * @return a {@link java.net.URLConnection URLConnection} linking 0N/A * @exception IOException if an I/O exception occurs. 0N/A * @see java.net.URL#URL(java.lang.String, java.lang.String, 0N/A * int, java.lang.String) 0N/A * Same as {@link #openConnection()}, except that the connection will be 0N/A * made through the specified proxy; Protocol handlers that do not 0N/A * support proxing will ignore the proxy parameter and make a 0N/A * normal connection. 0N/A * Invoking this method preempts the system's default ProxySelector 0N/A * @param proxy the Proxy through which this connection 0N/A * will be made. If direct connection is desired, 0N/A * Proxy.NO_PROXY should be specified. 0N/A * @return a <code>URLConnection</code> to the URL. 0N/A * @exception IOException if an I/O exception occurs. 0N/A * @exception SecurityException if a security manager is present 0N/A * and the caller doesn't have permission to connect 0N/A * @exception IllegalArgumentException will be thrown if proxy is null, 0N/A * or proxy has the wrong type 0N/A * @exception UnsupportedOperationException if the subclass that 0N/A * implements the protocol handler doesn't support 0N/A * @see java.net.URL#URL(java.lang.String, java.lang.String, 0N/A * int, java.lang.String) 0N/A * @see java.net.URLConnection 0N/A * @see java.net.URLStreamHandler#openConnection(java.net.URL, 1495N/A // Create a copy of Proxy as a security measure 0N/A * Opens a connection to this <code>URL</code> and returns an 0N/A * <code>InputStream</code> for reading from that connection. This 0N/A * method is a shorthand for: 0N/A * openConnection().getInputStream() 0N/A * </pre></blockquote> 0N/A * @return an input stream for reading from the URL connection. 0N/A * @exception IOException if an I/O exception occurs. 0N/A * @see java.net.URL#openConnection() 0N/A * @see java.net.URLConnection#getInputStream() 0N/A * Gets the contents of this URL. This method is a shorthand for: 0N/A * openConnection().getContent() 0N/A * </pre></blockquote> 0N/A * @return the contents of this URL. 0N/A * @exception IOException if an I/O exception occurs. 0N/A * @see java.net.URLConnection#getContent() 0N/A * Gets the contents of this URL. This method is a shorthand for: 0N/A * openConnection().getContent(Class[]) 0N/A * </pre></blockquote> 0N/A * @param classes an array of Java types 0N/A * @return the content object of this URL that is the first match of 0N/A * the types specified in the classes array. 0N/A * null if none of the requested types are supported. 0N/A * @exception IOException if an I/O exception occurs. 0N/A * @see java.net.URLConnection#getContent(Class[]) 0N/A * The URLStreamHandler factory. 0N/A * Sets an application's <code>URLStreamHandlerFactory</code>. 0N/A * This method can be called at most once in a given Java Virtual 0N/A *<p> The <code>URLStreamHandlerFactory</code> instance is used to 0N/A *construct a stream protocol handler from a protocol name. 0N/A * <p> If there is a security manager, this method first calls 0N/A * the security manager's <code>checkSetFactory</code> method 0N/A * to ensure the operation is allowed. 0N/A * This could result in a SecurityException. 0N/A * @param fac the desired factory. 0N/A * @exception Error if the application has already set a factory. 0N/A * @exception SecurityException if a security manager exists and its 0N/A * <code>checkSetFactory</code> method doesn't allow 0N/A * @see java.net.URL#URL(java.lang.String, java.lang.String, 0N/A * int, java.lang.String) 0N/A * @see java.net.URLStreamHandlerFactory 0N/A * @see SecurityManager#checkSetFactory 0N/A throw new Error(
"factory already defined");
0N/A * A table of protocol handlers. 5426N/A // special case the gopher protocol, disabled by default 5426N/A // package name of the JDK implementation protocol handlers 0N/A * Returns the Stream Handler. 0N/A * @param protocol the protocol to use 0N/A // Use the factory (if any) 0N/A // Try java protocol handler 0N/A // REMIND: decide whether to allow the "null" class prefix 5426N/A // do not try to instantiate the JDK gopher handler 5426N/A // unless the system property had been explicitly set 0N/A // any number of exceptions can get thrown here 0N/A // Check again with hashtable just in case another 0N/A // thread created a handler since we last checked 0N/A // Check with factory if another thread set a 0N/A // factory since our last check 0N/A // The handler from the factory must be given more 0N/A // importance. Discard the default handler that 0N/A // this thread created. 0N/A // Insert this handler into the hashtable 0N/A * WriteObject is called to save the state of the URL to an 0N/A * ObjectOutputStream. The handler is not saved since it is 0N/A * specific to this system. 0N/A * @serialData the default write object value. When read back in, 0N/A * the reader must ensure that calling getURLStreamHandler with 0N/A * the protocol variable returns a valid URLStreamHandler and 0N/A * throw an IOException if it does not. 0N/A * readObject is called to restore the state of the URL from the 0N/A * stream. It reads the components of the URL and finds the local 0N/A // Construct authority part 0N/A // Handle hosts with userInfo in them 0N/A // Construct user info part 0N/A // Construct path and query part 0N/A // Fix: only do this if hierarchical?