org.eclipse.jetty.util.resource

## Class ResourceCollection

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

- All Implemented Interfaces:
    ResourceFactory

      public class ResourceCollection
      extends Resource

  A collection of resources (dirs). Allows webapps to have multiple (static) sources. The first resource in the collection is the main resource. If a resource is not found in the main resource, it looks it up in the order the resources were constructed.

- - ### Field Summary

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

      `__defaultUseCaches`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ResourceCollection()` Instantiates an empty resource collection.
    `ResourceCollection(Resource... resources)` Instantiates a new resource collection.
    `ResourceCollection(java.lang.String csvResources)` Instantiates a new resource collection.
    `ResourceCollection(java.lang.String[] resources)` Instantiates a new resource collection.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Resource` | `addPath(java.lang.String path)` Returns the resource contained inside the current resource with the given name.
    `void` | `copyTo(java.io.File destination)`
    `boolean` | `delete()` Deletes the given resource
    `boolean` | `exists()` Returns true if the respresened resource exists.
    `protected java.lang.Object` | `findResource(java.lang.String path)`
    `java.io.File` | `getFile()` Returns an File representing the given resource or NULL if this is not possible.
    `java.io.InputStream` | `getInputStream()` Returns an input stream to the resource
    `java.lang.String` | `getName()` Returns the name of the resource
    `java.io.OutputStream` | `getOutputStream()` Returns an output stream to the resource
    `Resource[]` | `getResources()` Retrieves the resource collection's resources.
    `java.net.URL` | `getURL()` Returns an URL representing the given resource
    `boolean` | `isContainedIn(Resource r)`
    `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
    `java.lang.String[]` | `list()` Returns a list of resource names contained in the given resource The resource names are not URL encoded.
    `void` | `release()` Release any temporary resources held by the resource.
    `boolean` | `renameTo(Resource dest)` Rename the given resource
    `void` | `setResources(Resource[] resources)` Sets the resource collection's resources.
    `void` | `setResourcesAsCSV(java.lang.String csvResources)` Sets the resources as string of comma-separated values.
    `java.lang.String` | `toString()`

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

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

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

      `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ResourceCollection

          public ResourceCollection()

      Instantiates an empty resource collection. This constructor is used when configuring jetty-maven-plugin.

    - #### ResourceCollection

          public ResourceCollection(Resource... resources)

      Instantiates a new resource collection.
      Parameters:
        `resources` - the resources to be added to collection

    - #### ResourceCollection

          public ResourceCollection(java.lang.String[] resources)

      Instantiates a new resource collection.
      Parameters:
        `resources` - the resource strings to be added to collection

    - #### ResourceCollection

          public ResourceCollection(java.lang.String csvResources)

      Instantiates a new resource collection.
      Parameters:
        `csvResources` - the string containing comma-separated resource strings

  - ### Method Detail

    - #### getResources

          public Resource[] getResources()

      Retrieves the resource collection's resources.
      Returns:
        the resource array

    - #### setResources

          public void setResources(Resource[] resources)

      Sets the resource collection's resources.
      Parameters:
        `resources` - the new resource array

    - #### setResourcesAsCSV

          public void setResourcesAsCSV(java.lang.String csvResources)

      Sets the resources as string of comma-separated values. This method should be used when configuring jetty-maven-plugin.
      Parameters:
        `csvResources` - the comma-separated string containing one or more resource strings.

    - #### addPath

          public Resource addPath(java.lang.String path)
                           throws java.io.IOException,
                                  java.net.MalformedURLException

      Description copied from class: `Resource`
      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
      Returns:
        The contained resource (found first) in the collection of resources
      Throws:
        `java.io.IOException`
        `java.net.MalformedURLException`

    - #### findResource

          protected java.lang.Object findResource(java.lang.String path)
                                           throws java.io.IOException,
                                                  java.net.MalformedURLException

      Parameters:
        `path` -
      Returns:
        the resource(file) if found, returns a list of resource dirs if its a dir, else null.
      Throws:
        `java.io.IOException`
        `java.net.MalformedURLException`

    - #### delete

          public boolean delete()
                         throws java.lang.SecurityException

      Description copied from class: `Resource`
      Deletes the given resource
      Specified by:
        `delete` in class `Resource`
      Throws:
        `java.lang.SecurityException`

    - #### exists

          public boolean exists()

      Description copied from class: `Resource`
      Returns true if the respresened resource exists.
      Specified by:
        `exists` in class `Resource`

    - #### getFile

          public java.io.File getFile()
                               throws java.io.IOException

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

    - #### getInputStream

          public java.io.InputStream getInputStream()
                                             throws java.io.IOException

      Description copied from class: `Resource`
      Returns an input stream to the resource
      Specified by:
        `getInputStream` in class `Resource`
      Throws:
        `java.io.IOException`

    - #### getName

          public java.lang.String getName()

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

    - #### getOutputStream

          public java.io.OutputStream getOutputStream()
                                               throws java.io.IOException,
                                                      java.lang.SecurityException

      Description copied from class: `Resource`
      Returns an output stream to the resource
      Specified by:
        `getOutputStream` in class `Resource`
      Throws:
        `java.io.IOException`
        `java.lang.SecurityException`

    - #### getURL

          public java.net.URL getURL()

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

    - #### isDirectory

          public boolean isDirectory()

      Description copied from class: `Resource`
      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()

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

    - #### length

          public long length()

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

    - #### list

          public java.lang.String[] list()

      Description copied from class: `Resource`
      Returns a list of resource names contained in the given resource The resource names are not URL encoded.
      Specified by:
        `list` in class `Resource`
      Returns:
        The list of resource names(merged) contained in the collection of resources.

    - #### release

          public void release()

      Description copied from class: `Resource`
      Release any temporary resources held by the resource.
      Specified by:
        `release` in class `Resource`

    - #### renameTo

          public boolean renameTo(Resource dest)
                           throws java.lang.SecurityException

      Description copied from class: `Resource`
      Rename the given resource
      Specified by:
        `renameTo` in class `Resource`
      Throws:
        `java.lang.SecurityException`

    - #### copyTo

          public void copyTo(java.io.File destination)
                      throws java.io.IOException

      Overrides:
        `copyTo` in class `Resource`
      Throws:
        `java.io.IOException`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        the list of resources separated by a path separator

    - #### isContainedIn

          public boolean isContainedIn(Resource r)
                                throws java.net.MalformedURLException

      Specified by:
        `isContainedIn` in class `Resource`
      Throws:
        `java.net.MalformedURLException`

Copyright © 2013 FuseSource, Corp.. All Rights Reserved.