/[classpath]/classpath/java/net/URL.java
ViewVC logotype

Diff of /classpath/java/net/URL.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by mkoch, Tue Nov 4 10:07:50 2003 UTC revision 1.23 by mkoch, Wed Nov 26 16:00:28 2003 UTC
# Line 56  import java.util.StringTokenizer; Line 56  import java.util.StringTokenizer;
56    * This final class represents an Internet Uniform Resource Locator (URL).    * This final class represents an Internet Uniform Resource Locator (URL).
57    * For details on the syntax of URL's and what they can be used for,    * For details on the syntax of URL's and what they can be used for,
58    * refer to RFC 1738, available from <a    * refer to RFC 1738, available from <a
59    * href="http://ds.internic.net/rfcs/rfc1738.txt">http://ds.internic.net/rfcs/rfc1738.txt</a>    * href="http://ds.internic.net/rfcs/rfc1738.txt">
60      * http://ds.internic.net/rfcs/rfc1738.txt</a>
61    * <p>    * <p>
62    * There are a great many protocols supported by URL's such as "http",    * There are a great many protocols supported by URL's such as "http",
63    * "ftp", and "file".  This object can handle any arbitrary URL for which    * "ftp", and "file".  This object can handle any arbitrary URL for which
# Line 73  import java.util.StringTokenizer; Line 74  import java.util.StringTokenizer;
74    * If this property is set, it is assumed to be a "|" separated list of    * If this property is set, it is assumed to be a "|" separated list of
75    * package names in which to attempt locating protocol handlers.  The    * package names in which to attempt locating protocol handlers.  The
76    * protocol handler is searched for by appending the string    * protocol handler is searched for by appending the string
77    * ".<protocol>.Handler" to each packed in the list until a hander is found.    * ".&lt;protocol&gt;.Handler" to each packed in the list until a hander is
78    * If a protocol handler is not found in this list of packages, or if the    * found. If a protocol handler is not found in this list of packages, or if
79    * property does not exist, then the default protocol handler of    * the property does not exist, then the default protocol handler of
80    * "gnu.java.net.<protocol>.Handler" is tried.  If this is    * "gnu.java.net.&lt;protocol&gt;.Handler" is tried.  If this is
81    * unsuccessful, a MalformedURLException is thrown.    * unsuccessful, a MalformedURLException is thrown.
82    * <p>    * <p>
83    * All of the constructor methods of URL attempt to load a protocol    * All of the constructor methods of URL attempt to load a protocol
# Line 310  public final class URL implements Serial Line 311  public final class URL implements Serial
311      this((URL) null, spec, (URLStreamHandler) null);      this((URL) null, spec, (URLStreamHandler) null);
312    }    }
313    
314    /*    /**
315     * This method parses a String representation of a URL within the     * This method parses a String representation of a URL within the
316     * context of an existing URL.  Principally this means that any     * context of an existing URL.  Principally this means that any
317     * fields not present the URL are inheritied from the context URL.     * fields not present the URL are inheritied from the context URL.
# Line 475  public final class URL implements Serial Line 476  public final class URL implements Serial
476    /**    /**
477     * Gets the contents of this URL     * Gets the contents of this URL
478     *     *
479       * @param classes The allow classes for the content object.
480       *
481       * @return a context object for this URL.
482       *
483     * @exception IOException If an error occurs     * @exception IOException If an error occurs
484     */     */
485    public final Object getContent (Class[] classes) throws IOException    public final Object getContent (Class[] classes) throws IOException
# Line 487  public final class URL implements Serial Line 492  public final class URL implements Serial
492     * Returns the file portion of the URL.     * Returns the file portion of the URL.
493     * Defined as <code>path[?query]</code>.     * Defined as <code>path[?query]</code>.
494     * Returns the empty string if there is no file portion.     * Returns the empty string if there is no file portion.
495       *
496       * @return The filename specified in this URL.
497     */     */
498    public String getFile()    public String getFile()
499    {    {
# Line 497  public final class URL implements Serial Line 504  public final class URL implements Serial
504     * Returns the path of the URL. This is the part of the file before any '?'     * Returns the path of the URL. This is the part of the file before any '?'
505     * character.     * character.
506     *     *
507       * @return The path specified in this URL.
508       *
509     * @since 1.3     * @since 1.3
510     */     */
511    public String getPath()    public String getPath()
# Line 507  public final class URL implements Serial Line 516  public final class URL implements Serial
516    
517    /**    /**
518     * Returns the authority of the URL     * Returns the authority of the URL
519       *
520       * @return The authority specified in this URL.
521     *     *
522     * @since 1.3     * @since 1.3
523     */     */
# Line 517  public final class URL implements Serial Line 528  public final class URL implements Serial
528    
529    /**    /**
530     * Returns the host of the URL     * Returns the host of the URL
531       *
532       * @return The host specified in this URL.
533     */     */
534    public String getHost()    public String getHost()
535    {    {
# Line 540  public final class URL implements Serial Line 553  public final class URL implements Serial
553    /**    /**
554     * Returns the default port of the URL. If the StreamHandler for the URL     * Returns the default port of the URL. If the StreamHandler for the URL
555     * protocol does not define a default port it returns -1.     * protocol does not define a default port it returns -1.
556       *
557       * @return The default port of the current protocol.
558     */     */
559    public int getDefaultPort()    public int getDefaultPort()
560    {    {
# Line 548  public final class URL implements Serial Line 563  public final class URL implements Serial
563    
564    /**    /**
565     * Returns the protocol of the URL     * Returns the protocol of the URL
566       *
567       * @return The specified protocol.
568     */     */
569    public String getProtocol()    public String getProtocol()
570    {    {
# Line 591  public final class URL implements Serial Line 608  public final class URL implements Serial
608    
609    /**    /**
610     * Returns a hashcode computed by the URLStreamHandler of this URL     * Returns a hashcode computed by the URLStreamHandler of this URL
611       *
612       * @return The hashcode for this URL.
613     */     */
614    public int hashCode()    public int hashCode()
615    {    {
# Line 606  public final class URL implements Serial Line 625  public final class URL implements Serial
625     * openConnection() method of the protocol handler     * openConnection() method of the protocol handler
626     *     *
627     * @return A URLConnection for this URL     * @return A URLConnection for this URL
628       *
629     * @exception IOException If an error occurs     * @exception IOException If an error occurs
630     */     */
631    public URLConnection openConnection() throws IOException    public URLConnection openConnection() throws IOException
# Line 617  public final class URL implements Serial Line 637  public final class URL implements Serial
637     * Opens a connection to this URL and returns an InputStream for reading     * Opens a connection to this URL and returns an InputStream for reading
638     * from that connection     * from that connection
639     *     *
640       * @return An <code>InputStream</code> for this URL.
641       *
642     * @exception IOException If an error occurs     * @exception IOException If an error occurs
643     */     */
644    public final InputStream openStream() throws IOException    public final InputStream openStream() throws IOException
# Line 673  public final class URL implements Serial Line 695  public final class URL implements Serial
695     * that only URLStreamHandlers can modify URL fields. URLs are otherwise     * that only URLStreamHandlers can modify URL fields. URLs are otherwise
696     * constant.     * constant.
697     *     *
698       * @param protocol The protocol name for this URL.
699       * @param host The hostname or IP address for this URL.
700       * @param port The port number of this URL.
701       * @param authority The authority of this URL.
702       * @param userInfo The user and password (if needed) of this URL.
703       * @param path The "path" portion of this URL.
704       * @param query The query of this URL.
705       * @param ref The anchor portion of this URL.
706       *
707     * @since 1.3     * @since 1.3
708     */     */
709    protected void set(String protocol, String host, int port,    protected void set(String protocol, String host, int port,
# Line 782  public final class URL implements Serial Line 813  public final class URL implements Serial
813          // to it, along with the JDK specified default as a last resort.          // to it, along with the JDK specified default as a last resort.
814          // Except in very unusual environments the JDK specified one shouldn't          // Except in very unusual environments the JDK specified one shouldn't
815          // ever be needed (or available).          // ever be needed (or available).
816          String ph_search_path = System.getProperty ("java.protocol.handler.pkgs");          String ph_search_path =
817              System.getProperty("java.protocol.handler.pkgs");
818    
819          // Tack our default package on at the ends.          // Tack our default package on at the ends.
820          if (ph_search_path != null)          if (ph_search_path != null)
# Line 795  public final class URL implements Serial Line 827  public final class URL implements Serial
827                    
828          do          do
829            {            {
830              String clsName = pkgPrefix.nextToken() + "." + protocol + ".Handler";              String clsName = (pkgPrefix.nextToken() + "."
831                                  + protocol + ".Handler");
832                    
833              try              try
834                {                {
# Line 808  public final class URL implements Serial Line 841  public final class URL implements Serial
841                }                }
842              catch (Exception e)              catch (Exception e)
843                {                {
844                  // Can't instantiate; handler still null, go on to next element.                  // Can't instantiate; handler still null,
845                    // go on to next element.
846                }                }
847            }            }
848          while ((! (ph instanceof URLStreamHandler))          while ((! (ph instanceof URLStreamHandler))

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26