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(String csvResources)` Instantiates a new resource collection.
`ResourceCollection(String[] resources)` Instantiates a new resource collection.

### Method Summary

Methods
`Resource` `addPath(String path)` Returns the resource contained inside the current resource with the given name.
`void` `copyTo(File destination)`
`boolean` `delete()` Deletes the given resource
`boolean` `exists()` Returns true if the respresened resource exists.
`protected Object` `findResource(String path)`
`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
`Resource[]` `getResources()` Retrieves the resource collection's resources.
`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
`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(String csvResources)` Sets the resources as string of comma-separated values.
`String` `toString()`

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

`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, 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(String[] resources)

Instantiates a new resource collection.

Parameters:
  `resources` - the resource strings to be added to collection

#### ResourceCollection

    public ResourceCollection(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(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(String path)
                     throws IOException,
                            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:
  `IOException`
  `MalformedURLException`

#### findResource

    protected Object findResource(String path)
                           throws IOException,
                                  MalformedURLException

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

#### delete

    public boolean delete()
                   throws SecurityException

Description copied from class: `Resource`
Deletes the given resource

Specified by:
  `delete` in class `Resource`
Throws:
  `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 File getFile()
                 throws 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:
  `IOException`

#### getInputStream

    public InputStream getInputStream()
                               throws IOException

Description copied from class: `Resource`
Returns an input stream to the resource

Specified by:
  `getInputStream` in class `Resource`
Throws:
  `IOException`

#### getName

    public String getName()

Description copied from class: `Resource`
Returns the name of the resource

Specified by:
  `getName` in class `Resource`

#### getOutputStream

    public OutputStream getOutputStream()
                                 throws IOException,
                                        SecurityException

Description copied from class: `Resource`
Returns an output stream to the resource

Specified by:
  `getOutputStream` in class `Resource`
Throws:
  `IOException`
  `SecurityException`

#### getURL

    public 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 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 SecurityException

Description copied from class: `Resource`
Rename the given resource

Specified by:
  `renameTo` in class `Resource`
Throws:
  `SecurityException`

#### copyTo

    public void copyTo(File destination)
                throws IOException

Overrides:
  `copyTo` in class `Resource`
Throws:
  `IOException`

#### toString

    public String toString()

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

#### isContainedIn

    public boolean isContainedIn(Resource r)
                          throws MalformedURLException

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