    All Packages    This Package    Previous    Next

# Class net.www.html.URL

    java.lang.Object
       |
       +----net.www.html.URL

public class URL
extends Object

Class URL represents a Uniform Reference Locator -- a textual reference to an object on the World Wide Web. The public instance variables contains the broken apart fields of the parsed url.

##

content_aiff
content_anymap
content_basic
content_bcpio
content_bitmap
content_cpio
content_dvi
content_gif
content_graymap
content_gtar
content_hdf
content_html
content_ief
content_jpeg
content_latex
content_man
content_me
content_movie
content_mpeg
content_ms
content_msvideo
content_netcdf
content_octet
content_oda
content_pdf
content_pixmap
content_plain
content_postscript
content_quicktime
content_rast
content_rfc822
content_rgb
content_richtext
content_setext
content_shar
content_source
content_sv4cpio
content_sv4crc
content_tar
content_tex
content_texinfo
content_tiff
content_troff
content_type
  Format of media, only valid after the stream has been opened
content_unknown
content_ustar
content_values
content_wav
content_xbitmap
content_xpixmap
content_xwindowdump
content_zip
file
  "File name" on that host
fromUrl
  only relevant if we're a post url
host
  Host name to which to connect
port
  Protocol port to connect to
postData
  only relevant if we're a post url
protocol
  What protocol to use (ftp, http, nntp, ...
ref
  # reference

##

URL(String, String, String)
  Create an absolute URL from the specified protocol, host, and file.
URL(URL, String, URL)
  Create a POST URL
URL(URL, String)
  Create a URL from the unparsed url in the context of the specified context.
URL(String)
  Create a URL from the unparsed absolute URL

##

New(String)
  Create an instance of a named class using a classloader that references this URL.
canCache()
  Returns true if the data associated with this URL can be cached.
classInit()
  The static initializer for this class must be completed before the static initializer for URLStreamHandler.
copyURL(URL)
  Copy another URL's "vital statistics" into us.
equals(Object)
  Compare two URLs.
flushClassLoader()
  Flush the classloader cache.
getContent()
  Get the object referred to by this URL.
getContent(InputStream, Observer)
  Get the object referred to by this URL.
getPort()
hashCode()
  Create an integer suitable for hash table indexing
isPostURL()
main(String[])
  A simple main program for testing: fetches the object referenced by this URL and prints it.
mimeToContent(String)
  Given a mime content type String (e.g.
openStream()
  Open an input stream to the object references by the URL.
openStreamInteractively()
  Similar to openStream except that it allows the stream handler to interact with the user to resolve certain problems.
sameFile(URL)
  Compare two URLs, excluding the "ref" field: sameFile is true if the true reference the same remote object, but not necessarily the same subpiece of that object.
setType(String)
  Force the content type of this URL to a specific value.
toExternalForm()
  Reverse the parsing of the URL.
toString()
  Convert to a human-readable form.

##

content_unknown

      public static String content_unknown

content_octet

      public static String content_octet

content_oda

      public static String content_oda

content_pdf

      public static String content_pdf

content_postscript

      public static String content_postscript

content_richtext

      public static String content_richtext

content_bcpio

      public static String content_bcpio

content_cpio

      public static String content_cpio

content_dvi

      public static String content_dvi

content_gtar

      public static String content_gtar

content_hdf

      public static String content_hdf

content_latex

      public static String content_latex

content_netcdf

      public static String content_netcdf

content_shar

      public static String content_shar

content_sv4cpio

      public static String content_sv4cpio

content_sv4crc

      public static String content_sv4crc

content_tar

      public static String content_tar

content_tex

      public static String content_tex

content_texinfo

      public static String content_texinfo

content_troff

      public static String content_troff

content_man

      public static String content_man

content_me

      public static String content_me

content_ms

      public static String content_ms

content_ustar

      public static String content_ustar

content_source

      public static String content_source

content_zip

      public static String content_zip

content_basic

      public static String content_basic

content_aiff

      public static String content_aiff

content_wav

      public static String content_wav

content_gif

      public static String content_gif

content_ief

      public static String content_ief

content_jpeg

      public static String content_jpeg

content_tiff

      public static String content_tiff

content_rast

      public static String content_rast

content_anymap

      public static String content_anymap

content_bitmap

      public static String content_bitmap

content_graymap

      public static String content_graymap

content_pixmap

      public static String content_pixmap

content_rgb

      public static String content_rgb

content_xbitmap

      public static String content_xbitmap

content_xpixmap

      public static String content_xpixmap

content_xwindowdump

      public static String content_xwindowdump

content_rfc822

      public static String content_rfc822

content_html

      public static String content_html

content_plain

      public static String content_plain

content_values

      public static String content_values

content_setext

      public static String content_setext

content_mpeg

      public static String content_mpeg

content_quicktime

      public static String content_quicktime

content_msvideo

      public static String content_msvideo

content_movie

      public static String content_movie

postData

      public String postData

  only relevant if we're a post url

fromUrl

      public URL fromUrl

  only relevant if we're a post url

protocol

      public String protocol

  What protocol to use (ftp, http, nntp, ... etc)

host

      public String host

  Host name to which to connect

file

      public String file

  "File name" on that host

ref

      public String ref

  # reference

port

      public int port

  Protocol port to connect to

content_type

      public String content_type

  Format of media, only valid after the stream has been opened

##

URL

      public URL(String p,
                 String h,
                 String f)

  Create an absolute URL from the specified protocol, host, and file.

URL

      public URL(URL url,
                 String post,
                 URL from)

  Create a POST URL

URL

      public URL(URL context,
                 String spec)

  Create a URL from the unparsed url in the context of the specified context. If spec is an absolute URL, cool, otherwise, parse it in terms of the context. Context may be null (indicating no context).

URL

      public URL(String spec)

  Create a URL from the unparsed absolute URL

##

classInit

      public static void classInit()

  The static initializer for this class must be completed before the static initializer for URLStreamHandler. Therefore we create a static method here that is explcitly called by the static initializer of URLStreamHeandler, thus guarrenteeing the correct order of initialization.

isPostURL

      public boolean isPostURL()

copyURL

      protected void copyURL(URL url)

  Copy another URL's "vital statistics" into us.
  Parameters:
    url - The URL to copy.

equals

      public boolean equals(Object o)

  Compare two URLs.
  Parameters:
    o - The URL to compare against.
  Returns:
    true iff they are equal, false otherwise.
  Overrides:
    equals in class Object

hashCode

      public int hashCode()

  Create an integer suitable for hash table indexing
  Overrides:
    hashCode in class Object

sameFile

      public boolean sameFile(URL other)

  Compare two URLs, excluding the "ref" field: sameFile is true if the true reference the same remote object, but not necessarily the same subpiece of that object.
  Parameters:
    other - The URL to compare against.
  Returns:
    true iff they are equal, false otherwise.

toString

      public String toString()

  Convert to a human-readable form.
  Returns:
    The textual representation.
  Overrides:
    toString in class Object

toExternalForm

      public String toExternalForm()

  Reverse the parsing of the URL.
  Returns:
    The textual representation of the fully qualified URL (ie. after the context and canonicalization have been applied).

getPort

      public int getPort()

openStream

      public InputStream openStream()

  Open an input stream to the object references by the URL. Invokes the appropriate protocol handler. Failure is indicated by throwing an exception. The act of opening this stream determines, in a protocol specific way, the content type of the object associated with this URL.
  Returns:
    The opened input stream. A value of null indicates that while the open was successful, there is no useful data provided by this protocol, it's done for side-effect only (the usual example is the "mailto" protocol).

openStreamInteractively

      public InputStream openStreamInteractively()

  Similar to openStream except that it allows the stream handler to interact with the user to resolve certain problems. For example, the http handler will prompt for a user name and password to handle authentication failures. In these cases, openStream would just toss an exception.

setType

      public void setType(String type)

  Force the content type of this URL to a specific value.
  Parameters:
    type - The content type to use. One of the content_* static variables in this class should be used. eg. setType(URL.content_html);

mimeToContent

      public String mimeToContent(String type)

  Given a mime content type String (e.g. image/x-gif) produce the internal URL type atom for that type.

canCache

      public boolean canCache()

  Returns true if the data associated with this URL can be cached.

getContent

      public Object getContent()

  Get the object referred to by this URL. For example, if it refers to an image the object will be some subclass if DIBitmap. The instanceof operator should be used to determine what kind of object was returned.
  Returns:
    the object that was fetched.

getContent

      public Object getContent(InputStream is,
                               Observer o)

  Get the object referred to by this URL. For example, if it refers to an image the object will be some subclass if DIBitmap. The instanceof operator should be used to determine what kind of object was returned.
  Parameters:
    is - the stream to the Object. It must have been created by an earlier call to openStream.
  Returns:
    the object that was fetched. If there is no handler for the object, a stream is returned (logically the unmodified original stream, but it may have had another stream layered on top of it). Generally the caller should prompt to save the file locally if they get a stream back.

main

      public static void main(String args[])

  A simple main program for testing: fetches the object referenced by this URL and prints it.

New

      public Object New(String clname)

  Create an instance of a named class using a classloader that references this URL. It is similar to new(clname) except that it specifies a URL to search.
  Parameters:
    clname - The name of the class.
  Returns:
    The new instance of the class.

flushClassLoader

      public static synchronized void flushClassLoader()

  Flush the classloader cache. This is only used when reloading a document which went we want to force the system to reload all the applets on that document. Flushing the cache is not the most efficient mechanism but it is the most expedient.

    All Packages    This Package    Previous    Next