Top Description Fields Constructors Methods
org.mortbay.resource

public Class ResourceCollection

extends Resource
Class Inheritance
Imports
java.io.File, .IOException, .InputStream, .OutputStream, java.net.MalformedURLException, .URL, java.util.ArrayList, .HashSet, .StringTokenizer, org.mortbay.util.URIUtil

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.
Author
dyu

Field Summary

Modifier and TypeField and Description
private Resource[]
Inherited from org.mortbay.resource.Resource:
__defaultUseCaches_associate

Constructor Summary

AccessConstructor and Description
public
public
public
public
ResourceCollection(String csvResources)

Method Summary

Modifier and TypeMethod and Description
public Resource

Returns:

The contained resource (found first) in the collection of resources
addPath
(String
The path segment to add
path
)

Implements abstract org.mortbay.resource.Resource.addPath.

Returns the resource contained inside the current resource with the given name.
public boolean
delete()

Implements abstract org.mortbay.resource.Resource.delete.

Deletes the given resource
public boolean
exists()

Implements abstract org.mortbay.resource.Resource.exists.

Returns true if the respresened resource exists.
protected Object

Returns:

the resource(file) if found, returns a list of resource dirs if its a dir, else null.
findResource
(String path)

public File
getFile()

Implements abstract org.mortbay.resource.Resource.getFile.

Returns an File representing the given resource or NULL if this is not possible.
public InputStream
getInputStream()

Implements abstract org.mortbay.resource.Resource.getInputStream.

Returns an input stream to the resource
public String
getName()

Implements abstract org.mortbay.resource.Resource.getName.

Returns the name of the resource
public OutputStream
getOutputStream()

Implements abstract org.mortbay.resource.Resource.getOutputStream.

Returns an output stream to the resource
public Resource[]

Returns:

the resource array
getResources
()

public URL
getURL()

Implements abstract org.mortbay.resource.Resource.getURL.

Returns an URL representing the given resource
public boolean
isDirectory()

Implements abstract org.mortbay.resource.Resource.isDirectory.

Returns true if the respresenetd resource is a container/directory.
public long
lastModified()

Implements abstract org.mortbay.resource.Resource.lastModified.

Returns the last modified time
public long
length()

Implements abstract org.mortbay.resource.Resource.length.

Return the length of the resource
public String[]

Returns:

The list of resource names(merged) contained in the collection of resources.
list
()

Implements abstract org.mortbay.resource.Resource.list.

Returns a list of resource names contained in the given resource The resource names are not URL encoded.
public void
release()

Implements abstract org.mortbay.resource.Resource.release.

Release any resources held by the resource.
public boolean
renameTo(Resource dest)

Implements abstract org.mortbay.resource.Resource.renameTo.

Rename the given resource
public void
setResources(Resource[]
Resource array
resources
)

public void
setResources(String[]
String array
resources
)

public void
setResources(String
Comma separated values
csvResources
)

public void
setResourcesAsCSV(String
Comma separated values
csvResources
)

public String

Returns:

the list of resources separated by a path separator
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.mortbay.resource.Resource:
encodefinalizegetAliasgetAssociategetDefaultUseCachesgetListHTMLnewClassPathResourcenewClassPathResourcenewResourcenewResourcenewResourcenewResourcenewSystemResourcesetAssociatesetDefaultUseCacheswriteTo

Field Detail

_resourcesback to summary
private Resource[] _resources

Constructor Detail

ResourceCollectionback to summary
public ResourceCollection()
ResourceCollectionback to summary
public ResourceCollection(Resource[] resources)
ResourceCollectionback to summary
public ResourceCollection(String[] resources)
ResourceCollectionback to summary
public ResourceCollection(String csvResources)

Method Detail

addPathback to summary
public Resource addPath(String path) throws IOException, MalformedURLException

Implements abstract org.mortbay.resource.Resource.addPath.

Doc from org.mortbay.resource.Resource.addPath.

Returns the resource contained inside the current resource with the given name.

Parameters
path:String

The path segment to add

Returns:Resource

The contained resource (found first) in the collection of resources

deleteback to summary
public boolean delete() throws SecurityException

Implements abstract org.mortbay.resource.Resource.delete.

Doc from org.mortbay.resource.Resource.delete.

Deletes the given resource

existsback to summary
public boolean exists()

Implements abstract org.mortbay.resource.Resource.exists.

Doc from org.mortbay.resource.Resource.exists.

Returns true if the respresened resource exists.

findResourceback to summary
protected Object findResource(String path) throws IOException, MalformedURLException
Returns:Object

the resource(file) if found, returns a list of resource dirs if its a dir, else null.

getFileback to summary
public File getFile() throws IOException

Implements abstract org.mortbay.resource.Resource.getFile.

Doc from org.mortbay.resource.Resource.getFile.

Returns an File representing the given resource or NULL if this is not possible.

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Implements abstract org.mortbay.resource.Resource.getInputStream.

Doc from org.mortbay.resource.Resource.getInputStream.

Returns an input stream to the resource

getNameback to summary
public String getName()

Implements abstract org.mortbay.resource.Resource.getName.

Doc from org.mortbay.resource.Resource.getName.

Returns the name of the resource

getOutputStreamback to summary
public OutputStream getOutputStream() throws IOException, SecurityException

Implements abstract org.mortbay.resource.Resource.getOutputStream.

Doc from org.mortbay.resource.Resource.getOutputStream.

Returns an output stream to the resource

getResourcesback to summary
public Resource[] getResources()
Returns:Resource[]

the resource array

getURLback to summary
public URL getURL()

Implements abstract org.mortbay.resource.Resource.getURL.

Doc from org.mortbay.resource.Resource.getURL.

Returns an URL representing the given resource

isDirectoryback to summary
public boolean isDirectory()

Implements abstract org.mortbay.resource.Resource.isDirectory.

Doc from org.mortbay.resource.Resource.isDirectory.

Returns true if the respresenetd resource is a container/directory. If the resource is not a file, resources ending with "/" are considered directories.

lastModifiedback to summary
public long lastModified()

Implements abstract org.mortbay.resource.Resource.lastModified.

Doc from org.mortbay.resource.Resource.lastModified.

Returns the last modified time

lengthback to summary
public long length()

Implements abstract org.mortbay.resource.Resource.length.

Doc from org.mortbay.resource.Resource.length.

Return the length of the resource

listback to summary
public String[] list()

Implements abstract org.mortbay.resource.Resource.list.

Doc from org.mortbay.resource.Resource.list.

Returns a list of resource names contained in the given resource The resource names are not URL encoded.

Returns:String[]

The list of resource names(merged) contained in the collection of resources.

releaseback to summary
public void release()

Implements abstract org.mortbay.resource.Resource.release.

Doc from org.mortbay.resource.Resource.release.

Release any resources held by the resource.

renameToback to summary
public boolean renameTo(Resource dest) throws SecurityException

Implements abstract org.mortbay.resource.Resource.renameTo.

Doc from org.mortbay.resource.Resource.renameTo.

Rename the given resource

setResourcesback to summary
public void setResources(Resource[] resources)
Parameters
resources:Resource[]

Resource array

setResourcesback to summary
public void setResources(String[] resources)
Parameters
resources:String[]

String array

setResourcesback to summary
public void setResources(String csvResources)
Parameters
csvResources:String

Comma separated values

setResourcesAsCSVback to summary
public void setResourcesAsCSV(String csvResources)
Parameters
csvResources:String

Comma separated values

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

the list of resources separated by a path separator