org.eclipse.jetty.util.resource

## Class URLResource

- java.lang.Object
- - org.eclipse.jetty.util.resource.Resource
  - - org.eclipse.jetty.util.resource.URLResource

- All Implemented Interfaces:
    ResourceFactory
  Direct Known Subclasses:
    FileResource, JarResource

      public class URLResource
      extends Resource

  Abstract resource class.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected URLConnection` | `_connection`
    `protected InputStream` | `_in`
    `protected URL` | `_url`
    `protected String` | `_urlString`

    - ### Fields inherited from class org.eclipse.jetty.util.resource.Resource

      `__defaultUseCaches`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `URLResource(URL url, URLConnection connection)`
    `protected` | `URLResource(URL url, URLConnection connection, boolean useCaches)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Resource` | `addPath(String path)` Returns the resource contained inside the current resource with the given name
    `protected boolean` | `checkConnection()`
    `boolean` | `delete()` Deletes the given resource
    `boolean` | `equals(Object o)`
    `boolean` | `exists()` Returns true if the represented resource exists.
    `File` | `getFile()` Returns an File representing the given resource or NULL if this is not possible.
    `InputStream` | `getInputStream()` Returns an input stream to the resource
    `String` | `getName()` Returns the name of the resource
    `OutputStream` | `getOutputStream()` Returns an output stream to the resource
    `URL` | `getURL()` Returns an URL representing the given resource
    `boolean` | `getUseCaches()`
    `int` | `hashCode()`
    `boolean` | `isContainedIn(Resource containingResource)`
    `boolean` | `isDirectory()` Returns true if the respresenetd resource is a container/directory.
    `long` | `lastModified()` Returns the last modified time
    `long` | `length()` Return the length of the resource
    `String[]` | `list()` Returns a list of resource names contained in the given resource
    `void` | `release()` Release any resources held by the resource.
    `boolean` | `renameTo(Resource dest)` Rename the given resource
    `String` | `toString()`

    - ### Methods inherited from class org.eclipse.jetty.util.resource.Resource

      `copyTo, encode, finalize, getAlias, getAssociate, getDefaultUseCaches, getListHTML, getResource, getURI, getWeakETag, isContainedIn, newClassPathResource, newClassPathResource, newResource, newResource, newResource, newResource, newResource, newSystemResource, setAssociate, setDefaultUseCaches, toURL, writeTo`

    - ### Methods inherited from class java.lang.Object

      `clone, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _url

          protected URL _url

    - #### _urlString

          protected String _urlString

    - #### _connection

          protected URLConnection _connection

    - #### _in

          protected InputStream _in

  - ### Constructor Detail

    - #### URLResource

          protected URLResource(URL url,
                     URLConnection connection)

    - #### URLResource

          protected URLResource(URL url,
                     URLConnection connection,
                     boolean useCaches)

  - ### Method Detail

    - #### checkConnection

          protected boolean checkConnection()

    - #### release

          public void release()

      Release any resources held by the resource.
      Specified by:
        `release` in class `Resource`

    - #### exists

          public boolean exists()

      Returns true if the represented resource exists.
      Specified by:
        `exists` in class `Resource`

    - #### isDirectory

          public boolean isDirectory()

      Returns true if the respresenetd resource is a container/directory. If the resource is not a file, resources ending with "/" are considered directories.
      Specified by:
        `isDirectory` in class `Resource`

    - #### lastModified

          public long lastModified()

      Returns the last modified time
      Specified by:
        `lastModified` in class `Resource`

    - #### length

          public long length()

      Return the length of the resource
      Specified by:
        `length` in class `Resource`

    - #### getURL

          public URL getURL()

      Returns an URL representing the given resource
      Specified by:
        `getURL` in class `Resource`

    - #### getFile

          public File getFile()
                       throws IOException

      Returns an File representing the given resource or NULL if this is not possible.
      Specified by:
        `getFile` in class `Resource`
      Throws:
        `IOException`

    - #### getName

          public String getName()

      Returns the name of the resource
      Specified by:
        `getName` in class `Resource`

    - #### getInputStream

          public InputStream getInputStream()
                                     throws IOException

      Returns an input stream to the resource
      Specified by:
        `getInputStream` in class `Resource`
      Throws:
        `IOException`

    - #### getOutputStream

          public OutputStream getOutputStream()
                                       throws IOException,
                                              SecurityException

      Returns an output stream to the resource
      Specified by:
        `getOutputStream` in class `Resource`
      Throws:
        `IOException`
        `SecurityException`

    - #### delete

          public boolean delete()
                         throws SecurityException

      Deletes the given resource
      Specified by:
        `delete` in class `Resource`
      Throws:
        `SecurityException`

    - #### renameTo

          public boolean renameTo(Resource dest)
                           throws SecurityException

      Rename the given resource
      Specified by:
        `renameTo` in class `Resource`
      Throws:
        `SecurityException`

    - #### list

          public String[] list()

      Returns a list of resource names contained in the given resource
      Specified by:
        `list` in class `Resource`

    - #### addPath

          public Resource addPath(String path)
                           throws IOException,
                                  MalformedURLException

      Returns the resource contained inside the current resource with the given name
      Specified by:
        `addPath` in class `Resource`
      Parameters:
        `path` - The path segment to add, which should be encoded by the encode method.
      Throws:
        `IOException`
        `MalformedURLException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### getUseCaches

          public boolean getUseCaches()

    - #### isContainedIn

          public boolean isContainedIn(Resource containingResource)
                                throws MalformedURLException

      Specified by:
        `isContainedIn` in class `Resource`
      Throws:
        `MalformedURLException`

Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.