47 * <blockquote><pre> |
47 * <blockquote><pre> |
48 * http://www.example.com/docs/resource1.html |
48 * http://www.example.com/docs/resource1.html |
49 * </pre></blockquote> |
49 * </pre></blockquote> |
50 * <p> |
50 * <p> |
51 * The URL above indicates that the protocol to use is |
51 * The URL above indicates that the protocol to use is |
52 * <code>http</code> (HyperText Transfer Protocol) and that the |
52 * {@code http} (HyperText Transfer Protocol) and that the |
53 * information resides on a host machine named |
53 * information resides on a host machine named |
54 * <code>www.example.com</code>. The information on that host |
54 * {@code www.example.com}. The information on that host |
55 * machine is named <code>/docs/resource1.html</code>. The exact |
55 * machine is named {@code /docs/resource1.html}. The exact |
56 * meaning of this name on the host machine is both protocol |
56 * meaning of this name on the host machine is both protocol |
57 * dependent and host dependent. The information normally resides in |
57 * dependent and host dependent. The information normally resides in |
58 * a file, but it could be generated on the fly. This component of |
58 * a file, but it could be generated on the fly. This component of |
59 * the URL is called the <i>path</i> component. |
59 * the URL is called the <i>path</i> component. |
60 * <p> |
60 * <p> |
61 * A URL can optionally specify a "port", which is the |
61 * A URL can optionally specify a "port", which is the |
62 * port number to which the TCP connection is made on the remote host |
62 * port number to which the TCP connection is made on the remote host |
63 * machine. If the port is not specified, the default port for |
63 * machine. If the port is not specified, the default port for |
64 * the protocol is used instead. For example, the default port for |
64 * the protocol is used instead. For example, the default port for |
65 * <code>http</code> is <code>80</code>. An alternative port could be |
65 * {@code http} is {@code 80}. An alternative port could be |
66 * specified as: |
66 * specified as: |
67 * <blockquote><pre> |
67 * <blockquote><pre> |
68 * http://www.example.com:1080/docs/resource1.html |
68 * http://www.example.com:1080/docs/resource1.html |
69 * </pre></blockquote> |
69 * </pre></blockquote> |
70 * <p> |
70 * <p> |
71 * The syntax of <code>URL</code> is defined by <a |
71 * The syntax of {@code URL} is defined by <a |
72 * href="http://www.ietf.org/rfc/rfc2396.txt"><i>RFC 2396: Uniform |
72 * href="http://www.ietf.org/rfc/rfc2396.txt"><i>RFC 2396: Uniform |
73 * Resource Identifiers (URI): Generic Syntax</i></a>, amended by <a |
73 * Resource Identifiers (URI): Generic Syntax</i></a>, amended by <a |
74 * href="http://www.ietf.org/rfc/rfc2732.txt"><i>RFC 2732: Format for |
74 * href="http://www.ietf.org/rfc/rfc2732.txt"><i>RFC 2732: Format for |
75 * Literal IPv6 Addresses in URLs</i></a>. The Literal IPv6 address format |
75 * Literal IPv6 Addresses in URLs</i></a>. The Literal IPv6 address format |
76 * also supports scope_ids. The syntax and usage of scope_ids is described |
76 * also supports scope_ids. The syntax and usage of scope_ids is described |
218 * @serial |
218 * @serial |
219 */ |
219 */ |
220 private int hashCode = -1; |
220 private int hashCode = -1; |
221 |
221 |
222 /** |
222 /** |
223 * Creates a <code>URL</code> object from the specified |
223 * Creates a {@code URL} object from the specified |
224 * <code>protocol</code>, <code>host</code>, <code>port</code> |
224 * {@code protocol}, {@code host}, {@code port} |
225 * number, and <code>file</code>.<p> |
225 * number, and {@code file}.<p> |
226 * |
226 * |
227 * <code>host</code> can be expressed as a host name or a literal |
227 * {@code host} can be expressed as a host name or a literal |
228 * IP address. If IPv6 literal address is used, it should be |
228 * IP address. If IPv6 literal address is used, it should be |
229 * enclosed in square brackets (<tt>'['</tt> and <tt>']'</tt>), as |
229 * enclosed in square brackets ({@code '['} and {@code ']'}), as |
230 * specified by <a |
230 * specified by <a |
231 * href="http://www.ietf.org/rfc/rfc2732.txt">RFC 2732</a>; |
231 * href="http://www.ietf.org/rfc/rfc2732.txt">RFC 2732</a>; |
232 * However, the literal IPv6 address format defined in <a |
232 * However, the literal IPv6 address format defined in <a |
233 * href="http://www.ietf.org/rfc/rfc2373.txt"><i>RFC 2373: IP |
233 * href="http://www.ietf.org/rfc/rfc2373.txt"><i>RFC 2373: IP |
234 * Version 6 Addressing Architecture</i></a> is also accepted.<p> |
234 * Version 6 Addressing Architecture</i></a> is also accepted.<p> |
235 * |
235 * |
236 * Specifying a <code>port</code> number of <code>-1</code> |
236 * Specifying a {@code port} number of {@code -1} |
237 * indicates that the URL should use the default port for the |
237 * indicates that the URL should use the default port for the |
238 * protocol.<p> |
238 * protocol.<p> |
239 * |
239 * |
240 * If this is the first URL object being created with the specified |
240 * If this is the first URL object being created with the specified |
241 * protocol, a <i>stream protocol handler</i> object, an instance of |
241 * protocol, a <i>stream protocol handler</i> object, an instance of |
242 * class <code>URLStreamHandler</code>, is created for that protocol: |
242 * class {@code URLStreamHandler}, is created for that protocol: |
243 * <ol> |
243 * <ol> |
244 * <li>If the application has previously set up an instance of |
244 * <li>If the application has previously set up an instance of |
245 * <code>URLStreamHandlerFactory</code> as the stream handler factory, |
245 * {@code URLStreamHandlerFactory} as the stream handler factory, |
246 * then the <code>createURLStreamHandler</code> method of that instance |
246 * then the {@code createURLStreamHandler} method of that instance |
247 * is called with the protocol string as an argument to create the |
247 * is called with the protocol string as an argument to create the |
248 * stream protocol handler. |
248 * stream protocol handler. |
249 * <li>If no <code>URLStreamHandlerFactory</code> has yet been set up, |
249 * <li>If no {@code URLStreamHandlerFactory} has yet been set up, |
250 * or if the factory's <code>createURLStreamHandler</code> method |
250 * or if the factory's {@code createURLStreamHandler} method |
251 * returns <code>null</code>, then the constructor finds the |
251 * returns {@code null}, then the constructor finds the |
252 * value of the system property: |
252 * value of the system property: |
253 * <blockquote><pre> |
253 * <blockquote><pre> |
254 * java.protocol.handler.pkgs |
254 * java.protocol.handler.pkgs |
255 * </pre></blockquote> |
255 * </pre></blockquote> |
256 * If the value of that system property is not <code>null</code>, |
256 * If the value of that system property is not {@code null}, |
257 * it is interpreted as a list of packages separated by a vertical |
257 * it is interpreted as a list of packages separated by a vertical |
258 * slash character '<code>|</code>'. The constructor tries to load |
258 * slash character '{@code |}'. The constructor tries to load |
259 * the class named: |
259 * the class named: |
260 * <blockquote><pre> |
260 * <blockquote><pre> |
261 * <<i>package</i>>.<<i>protocol</i>>.Handler |
261 * <<i>package</i>>.<<i>protocol</i>>.Handler |
262 * </pre></blockquote> |
262 * </pre></blockquote> |
263 * where <<i>package</i>> is replaced by the name of the package |
263 * where <<i>package</i>> is replaced by the name of the package |
264 * and <<i>protocol</i>> is replaced by the name of the protocol. |
264 * and <<i>protocol</i>> is replaced by the name of the protocol. |
265 * If this class does not exist, or if the class exists but it is not |
265 * If this class does not exist, or if the class exists but it is not |
266 * a subclass of <code>URLStreamHandler</code>, then the next package |
266 * a subclass of {@code URLStreamHandler}, then the next package |
267 * in the list is tried. |
267 * in the list is tried. |
268 * <li>If the previous step fails to find a protocol handler, then the |
268 * <li>If the previous step fails to find a protocol handler, then the |
269 * constructor tries to load from a system default package. |
269 * constructor tries to load from a system default package. |
270 * <blockquote><pre> |
270 * <blockquote><pre> |
271 * <<i>system default package</i>>.<<i>protocol</i>>.Handler |
271 * <<i>system default package</i>>.<<i>protocol</i>>.Handler |
272 * </pre></blockquote> |
272 * </pre></blockquote> |
273 * If this class does not exist, or if the class exists but it is not a |
273 * If this class does not exist, or if the class exists but it is not a |
274 * subclass of <code>URLStreamHandler</code>, then a |
274 * subclass of {@code URLStreamHandler}, then a |
275 * <code>MalformedURLException</code> is thrown. |
275 * {@code MalformedURLException} is thrown. |
276 * </ol> |
276 * </ol> |
277 * |
277 * |
278 * <p>Protocol handlers for the following protocols are guaranteed |
278 * <p>Protocol handlers for the following protocols are guaranteed |
279 * to exist on the search path :- |
279 * to exist on the search path :- |
280 * <blockquote><pre> |
280 * <blockquote><pre> |
302 { |
302 { |
303 this(protocol, host, port, file, null); |
303 this(protocol, host, port, file, null); |
304 } |
304 } |
305 |
305 |
306 /** |
306 /** |
307 * Creates a URL from the specified <code>protocol</code> |
307 * Creates a URL from the specified {@code protocol} |
308 * name, <code>host</code> name, and <code>file</code> name. The |
308 * name, {@code host} name, and {@code file} name. The |
309 * default port for the specified protocol is used. |
309 * default port for the specified protocol is used. |
310 * <p> |
310 * <p> |
311 * This method is equivalent to calling the four-argument |
311 * This method is equivalent to calling the four-argument |
312 * constructor with the arguments being <code>protocol</code>, |
312 * constructor with the arguments being {@code protocol}, |
313 * <code>host</code>, <code>-1</code>, and <code>file</code>. |
313 * {@code host}, {@code -1}, and {@code file}. |
314 * |
314 * |
315 * No validation of the inputs is performed by this constructor. |
315 * No validation of the inputs is performed by this constructor. |
316 * |
316 * |
317 * @param protocol the name of the protocol to use. |
317 * @param protocol the name of the protocol to use. |
318 * @param host the name of the host. |
318 * @param host the name of the host. |
325 throws MalformedURLException { |
325 throws MalformedURLException { |
326 this(protocol, host, -1, file); |
326 this(protocol, host, -1, file); |
327 } |
327 } |
328 |
328 |
329 /** |
329 /** |
330 * Creates a <code>URL</code> object from the specified |
330 * Creates a {@code URL} object from the specified |
331 * <code>protocol</code>, <code>host</code>, <code>port</code> |
331 * {@code protocol}, {@code host}, {@code port} |
332 * number, <code>file</code>, and <code>handler</code>. Specifying |
332 * number, {@code file}, and {@code handler}. Specifying |
333 * a <code>port</code> number of <code>-1</code> indicates that |
333 * a {@code port} number of {@code -1} indicates that |
334 * the URL should use the default port for the protocol. Specifying |
334 * the URL should use the default port for the protocol. Specifying |
335 * a <code>handler</code> of <code>null</code> indicates that the URL |
335 * a {@code handler} of {@code null} indicates that the URL |
336 * should use a default stream handler for the protocol, as outlined |
336 * should use a default stream handler for the protocol, as outlined |
337 * for: |
337 * for: |
338 * java.net.URL#URL(java.lang.String, java.lang.String, int, |
338 * java.net.URL#URL(java.lang.String, java.lang.String, int, |
339 * java.lang.String) |
339 * java.lang.String) |
340 * |
340 * |
341 * <p>If the handler is not null and there is a security manager, |
341 * <p>If the handler is not null and there is a security manager, |
342 * the security manager's <code>checkPermission</code> |
342 * the security manager's {@code checkPermission} |
343 * method is called with a |
343 * method is called with a |
344 * <code>NetPermission("specifyStreamHandler")</code> permission. |
344 * {@code NetPermission("specifyStreamHandler")} permission. |
345 * This may result in a SecurityException. |
345 * This may result in a SecurityException. |
346 * |
346 * |
347 * No validation of the inputs is performed by this constructor. |
347 * No validation of the inputs is performed by this constructor. |
348 * |
348 * |
349 * @param protocol the name of the protocol to use. |
349 * @param protocol the name of the protocol to use. |
468 * changes made by occurences of ".." and ".". |
468 * changes made by occurences of ".." and ".". |
469 * <p> |
469 * <p> |
470 * For a more detailed description of URL parsing, refer to RFC2396. |
470 * For a more detailed description of URL parsing, refer to RFC2396. |
471 * |
471 * |
472 * @param context the context in which to parse the specification. |
472 * @param context the context in which to parse the specification. |
473 * @param spec the <code>String</code> to parse as a URL. |
473 * @param spec the {@code String} to parse as a URL. |
474 * @exception MalformedURLException if no protocol is specified, or an |
474 * @exception MalformedURLException if no protocol is specified, or an |
475 * unknown protocol is found, or <tt>spec</tt> is <tt>null</tt>. |
475 * unknown protocol is found, or {@code spec} is {@code null}. |
476 * @see java.net.URL#URL(java.lang.String, java.lang.String, |
476 * @see java.net.URL#URL(java.lang.String, java.lang.String, |
477 * int, java.lang.String) |
477 * int, java.lang.String) |
478 * @see java.net.URLStreamHandler |
478 * @see java.net.URLStreamHandler |
479 * @see java.net.URLStreamHandler#parseURL(java.net.URL, |
479 * @see java.net.URLStreamHandler#parseURL(java.net.URL, |
480 * java.lang.String, int, int) |
480 * java.lang.String, int, int) |
487 * Creates a URL by parsing the given spec with the specified handler |
487 * Creates a URL by parsing the given spec with the specified handler |
488 * within a specified context. If the handler is null, the parsing |
488 * within a specified context. If the handler is null, the parsing |
489 * occurs as with the two argument constructor. |
489 * occurs as with the two argument constructor. |
490 * |
490 * |
491 * @param context the context in which to parse the specification. |
491 * @param context the context in which to parse the specification. |
492 * @param spec the <code>String</code> to parse as a URL. |
492 * @param spec the {@code String} to parse as a URL. |
493 * @param handler the stream handler for the URL. |
493 * @param handler the stream handler for the URL. |
494 * @exception MalformedURLException if no protocol is specified, or an |
494 * @exception MalformedURLException if no protocol is specified, or an |
495 * unknown protocol is found, or <tt>spec</tt> is <tt>null</tt>. |
495 * unknown protocol is found, or {@code spec} is {@code null}. |
496 * @exception SecurityException |
496 * @exception SecurityException |
497 * if a security manager exists and its |
497 * if a security manager exists and its |
498 * <code>checkPermission</code> method doesn't allow |
498 * {@code checkPermission} method doesn't allow |
499 * specifying a stream handler. |
499 * specifying a stream handler. |
500 * @see java.net.URL#URL(java.lang.String, java.lang.String, |
500 * @see java.net.URL#URL(java.lang.String, java.lang.String, |
501 * int, java.lang.String) |
501 * int, java.lang.String) |
502 * @see java.net.URLStreamHandler |
502 * @see java.net.URLStreamHandler |
503 * @see java.net.URLStreamHandler#parseURL(java.net.URL, |
503 * @see java.net.URLStreamHandler#parseURL(java.net.URL, |
717 this.authority = authority; |
717 this.authority = authority; |
718 } |
718 } |
719 } |
719 } |
720 |
720 |
721 /** |
721 /** |
722 * Gets the query part of this <code>URL</code>. |
722 * Gets the query part of this {@code URL}. |
723 * |
723 * |
724 * @return the query part of this <code>URL</code>, |
724 * @return the query part of this {@code URL}, |
725 * or <CODE>null</CODE> if one does not exist |
725 * or <CODE>null</CODE> if one does not exist |
726 * @since 1.3 |
726 * @since 1.3 |
727 */ |
727 */ |
728 public String getQuery() { |
728 public String getQuery() { |
729 return query; |
729 return query; |
730 } |
730 } |
731 |
731 |
732 /** |
732 /** |
733 * Gets the path part of this <code>URL</code>. |
733 * Gets the path part of this {@code URL}. |
734 * |
734 * |
735 * @return the path part of this <code>URL</code>, or an |
735 * @return the path part of this {@code URL}, or an |
736 * empty string if one does not exist |
736 * empty string if one does not exist |
737 * @since 1.3 |
737 * @since 1.3 |
738 */ |
738 */ |
739 public String getPath() { |
739 public String getPath() { |
740 return path; |
740 return path; |
741 } |
741 } |
742 |
742 |
743 /** |
743 /** |
744 * Gets the userInfo part of this <code>URL</code>. |
744 * Gets the userInfo part of this {@code URL}. |
745 * |
745 * |
746 * @return the userInfo part of this <code>URL</code>, or |
746 * @return the userInfo part of this {@code URL}, or |
747 * <CODE>null</CODE> if one does not exist |
747 * <CODE>null</CODE> if one does not exist |
748 * @since 1.3 |
748 * @since 1.3 |
749 */ |
749 */ |
750 public String getUserInfo() { |
750 public String getUserInfo() { |
751 return userInfo; |
751 return userInfo; |
752 } |
752 } |
753 |
753 |
754 /** |
754 /** |
755 * Gets the authority part of this <code>URL</code>. |
755 * Gets the authority part of this {@code URL}. |
756 * |
756 * |
757 * @return the authority part of this <code>URL</code> |
757 * @return the authority part of this {@code URL} |
758 * @since 1.3 |
758 * @since 1.3 |
759 */ |
759 */ |
760 public String getAuthority() { |
760 public String getAuthority() { |
761 return authority; |
761 return authority; |
762 } |
762 } |
763 |
763 |
764 /** |
764 /** |
765 * Gets the port number of this <code>URL</code>. |
765 * Gets the port number of this {@code URL}. |
766 * |
766 * |
767 * @return the port number, or -1 if the port is not set |
767 * @return the port number, or -1 if the port is not set |
768 */ |
768 */ |
769 public int getPort() { |
769 public int getPort() { |
770 return port; |
770 return port; |
771 } |
771 } |
772 |
772 |
773 /** |
773 /** |
774 * Gets the default port number of the protocol associated |
774 * Gets the default port number of the protocol associated |
775 * with this <code>URL</code>. If the URL scheme or the URLStreamHandler |
775 * with this {@code URL}. If the URL scheme or the URLStreamHandler |
776 * for the URL do not define a default port number, |
776 * for the URL do not define a default port number, |
777 * then -1 is returned. |
777 * then -1 is returned. |
778 * |
778 * |
779 * @return the port number |
779 * @return the port number |
780 * @since 1.4 |
780 * @since 1.4 |
782 public int getDefaultPort() { |
782 public int getDefaultPort() { |
783 return handler.getDefaultPort(); |
783 return handler.getDefaultPort(); |
784 } |
784 } |
785 |
785 |
786 /** |
786 /** |
787 * Gets the protocol name of this <code>URL</code>. |
787 * Gets the protocol name of this {@code URL}. |
788 * |
788 * |
789 * @return the protocol of this <code>URL</code>. |
789 * @return the protocol of this {@code URL}. |
790 */ |
790 */ |
791 public String getProtocol() { |
791 public String getProtocol() { |
792 return protocol; |
792 return protocol; |
793 } |
793 } |
794 |
794 |
795 /** |
795 /** |
796 * Gets the host name of this <code>URL</code>, if applicable. |
796 * Gets the host name of this {@code URL}, if applicable. |
797 * The format of the host conforms to RFC 2732, i.e. for a |
797 * The format of the host conforms to RFC 2732, i.e. for a |
798 * literal IPv6 address, this method will return the IPv6 address |
798 * literal IPv6 address, this method will return the IPv6 address |
799 * enclosed in square brackets (<tt>'['</tt> and <tt>']'</tt>). |
799 * enclosed in square brackets ({@code '['} and {@code ']'}). |
800 * |
800 * |
801 * @return the host name of this <code>URL</code>. |
801 * @return the host name of this {@code URL}. |
802 */ |
802 */ |
803 public String getHost() { |
803 public String getHost() { |
804 return host; |
804 return host; |
805 } |
805 } |
806 |
806 |
807 /** |
807 /** |
808 * Gets the file name of this <code>URL</code>. |
808 * Gets the file name of this {@code URL}. |
809 * The returned file portion will be |
809 * The returned file portion will be |
810 * the same as <CODE>getPath()</CODE>, plus the concatenation of |
810 * the same as <CODE>getPath()</CODE>, plus the concatenation of |
811 * the value of <CODE>getQuery()</CODE>, if any. If there is |
811 * the value of <CODE>getQuery()</CODE>, if any. If there is |
812 * no query portion, this method and <CODE>getPath()</CODE> will |
812 * no query portion, this method and <CODE>getPath()</CODE> will |
813 * return identical results. |
813 * return identical results. |
814 * |
814 * |
815 * @return the file name of this <code>URL</code>, |
815 * @return the file name of this {@code URL}, |
816 * or an empty string if one does not exist |
816 * or an empty string if one does not exist |
817 */ |
817 */ |
818 public String getFile() { |
818 public String getFile() { |
819 return file; |
819 return file; |
820 } |
820 } |
821 |
821 |
822 /** |
822 /** |
823 * Gets the anchor (also known as the "reference") of this |
823 * Gets the anchor (also known as the "reference") of this |
824 * <code>URL</code>. |
824 * {@code URL}. |
825 * |
825 * |
826 * @return the anchor (also known as the "reference") of this |
826 * @return the anchor (also known as the "reference") of this |
827 * <code>URL</code>, or <CODE>null</CODE> if one does not exist |
827 * {@code URL}, or <CODE>null</CODE> if one does not exist |
828 */ |
828 */ |
829 public String getRef() { |
829 public String getRef() { |
830 return ref; |
830 return ref; |
831 } |
831 } |
832 |
832 |
833 /** |
833 /** |
834 * Compares this URL for equality with another object.<p> |
834 * Compares this URL for equality with another object.<p> |
835 * |
835 * |
836 * If the given object is not a URL then this method immediately returns |
836 * If the given object is not a URL then this method immediately returns |
837 * <code>false</code>.<p> |
837 * {@code false}.<p> |
838 * |
838 * |
839 * Two URL objects are equal if they have the same protocol, reference |
839 * Two URL objects are equal if they have the same protocol, reference |
840 * equivalent hosts, have the same port number on the host, and the same |
840 * equivalent hosts, have the same port number on the host, and the same |
841 * file and fragment of the file.<p> |
841 * file and fragment of the file.<p> |
842 * |
842 * |
880 } |
880 } |
881 |
881 |
882 /** |
882 /** |
883 * Compares two URLs, excluding the fragment component.<p> |
883 * Compares two URLs, excluding the fragment component.<p> |
884 * |
884 * |
885 * Returns <code>true</code> if this <code>URL</code> and the |
885 * Returns {@code true} if this {@code URL} and the |
886 * <code>other</code> argument are equal without taking the |
886 * {@code other} argument are equal without taking the |
887 * fragment component into consideration. |
887 * fragment component into consideration. |
888 * |
888 * |
889 * @param other the <code>URL</code> to compare against. |
889 * @param other the {@code URL} to compare against. |
890 * @return <code>true</code> if they reference the same remote object; |
890 * @return {@code true} if they reference the same remote object; |
891 * <code>false</code> otherwise. |
891 * {@code false} otherwise. |
892 */ |
892 */ |
893 public boolean sameFile(URL other) { |
893 public boolean sameFile(URL other) { |
894 return handler.sameFile(this, other); |
894 return handler.sameFile(this, other); |
895 } |
895 } |
896 |
896 |
897 /** |
897 /** |
898 * Constructs a string representation of this <code>URL</code>. The |
898 * Constructs a string representation of this {@code URL}. The |
899 * string is created by calling the <code>toExternalForm</code> |
899 * string is created by calling the {@code toExternalForm} |
900 * method of the stream protocol handler for this object. |
900 * method of the stream protocol handler for this object. |
901 * |
901 * |
902 * @return a string representation of this object. |
902 * @return a string representation of this object. |
903 * @see java.net.URL#URL(java.lang.String, java.lang.String, int, |
903 * @see java.net.URL#URL(java.lang.String, java.lang.String, int, |
904 * java.lang.String) |
904 * java.lang.String) |
1075 * The URLStreamHandler factory. |
1075 * The URLStreamHandler factory. |
1076 */ |
1076 */ |
1077 static URLStreamHandlerFactory factory; |
1077 static URLStreamHandlerFactory factory; |
1078 |
1078 |
1079 /** |
1079 /** |
1080 * Sets an application's <code>URLStreamHandlerFactory</code>. |
1080 * Sets an application's {@code URLStreamHandlerFactory}. |
1081 * This method can be called at most once in a given Java Virtual |
1081 * This method can be called at most once in a given Java Virtual |
1082 * Machine. |
1082 * Machine. |
1083 * |
1083 * |
1084 *<p> The <code>URLStreamHandlerFactory</code> instance is used to |
1084 *<p> The {@code URLStreamHandlerFactory} instance is used to |
1085 *construct a stream protocol handler from a protocol name. |
1085 *construct a stream protocol handler from a protocol name. |
1086 * |
1086 * |
1087 * <p> If there is a security manager, this method first calls |
1087 * <p> If there is a security manager, this method first calls |
1088 * the security manager's <code>checkSetFactory</code> method |
1088 * the security manager's {@code checkSetFactory} method |
1089 * to ensure the operation is allowed. |
1089 * to ensure the operation is allowed. |
1090 * This could result in a SecurityException. |
1090 * This could result in a SecurityException. |
1091 * |
1091 * |
1092 * @param fac the desired factory. |
1092 * @param fac the desired factory. |
1093 * @exception Error if the application has already set a factory. |
1093 * @exception Error if the application has already set a factory. |
1094 * @exception SecurityException if a security manager exists and its |
1094 * @exception SecurityException if a security manager exists and its |
1095 * <code>checkSetFactory</code> method doesn't allow |
1095 * {@code checkSetFactory} method doesn't allow |
1096 * the operation. |
1096 * the operation. |
1097 * @see java.net.URL#URL(java.lang.String, java.lang.String, |
1097 * @see java.net.URL#URL(java.lang.String, java.lang.String, |
1098 * int, java.lang.String) |
1098 * int, java.lang.String) |
1099 * @see java.net.URLStreamHandlerFactory |
1099 * @see java.net.URLStreamHandlerFactory |
1100 * @see SecurityManager#checkSetFactory |
1100 * @see SecurityManager#checkSetFactory |