org.mortbay.util

Class CachedResource

Implemented Interfaces:
Serializable

public class CachedResource
extends Resource

Cached resource class. This resource caches in memory the contents of another resource. The update() method must be called to check if the real resource has been modified.
Version:
$Id: CachedResource.java,v 1.6 2004/05/09 20:32:49 gregwilkins Exp $
Author:
Greg Wilkins (gregw)

Method Summary

Resource
addPath(String path)
Returns the resource contained inside the current resource with the given name
void
clear()
boolean
delete()
Deletes the given resource
boolean
equals(Object o)
boolean
exists()
Returns true if the respresened resource exists.
byte[]
getCachedData()
File
getFile()
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()
int
hashCode()
boolean
isDirectory()
boolean
isUptoDate()
long
lastModified()
long
length()
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
void
setCachedData(byte[] buf)
String
toString()
boolean
update()
void
writeTo(OutputStream os, long startByte, long count)

Methods inherited from class org.mortbay.util.Resource

addPath, cache, delete, encode, exists, finalize, getAlias, getAssociate, getFile, getInputStream, getListHTML, getName, getOutputStream, getURL, isDirectory, lastModified, length, list, newResource, newResource, newSystemResource, release, renameTo, setAssociate, writeTo

Method Details

addPath

public Resource addPath(String path)
            throws IOException,
                   MalformedURLException
Returns the resource contained inside the current resource with the given name
Overrides:
addPath in interface Resource

clear

public void clear()

delete

public boolean delete()
            throws SecurityException
Deletes the given resource
Overrides:
delete in interface Resource

equals

public boolean equals(Object o)

exists

public boolean exists()
Returns true if the respresened resource exists.
Overrides:
exists in interface Resource

getCachedData

public byte[] getCachedData()

getFile

public File getFile()
            throws IOException
Overrides:
getFile in interface Resource

getInputStream

public InputStream getInputStream()
            throws IOException
Returns an input stream to the resource
Overrides:
getInputStream in interface Resource

getName

public String getName()
Returns the name of the resource
Overrides:
getName in interface Resource

getOutputStream

public OutputStream getOutputStream()
            throws IOException,
                   SecurityException
Returns an output stream to the resource
Overrides:
getOutputStream in interface Resource

getURL

public URL getURL()
Overrides:
getURL in interface Resource

hashCode

public int hashCode()

isDirectory

public boolean isDirectory()
Overrides:
isDirectory in interface Resource

isUptoDate

public boolean isUptoDate()
            throws IOException

lastModified

public long lastModified()
Overrides:
lastModified in interface Resource

length

public long length()
Overrides:
length in interface Resource

list

public String[] list()
Returns a list of resource names contained in the given resource
Overrides:
list in interface Resource

release

public void release()
Release any resources held by the resource.
Overrides:
release in interface Resource

renameTo

public boolean renameTo(Resource dest)
            throws SecurityException
Rename the given resource
Overrides:
renameTo in interface Resource

setCachedData

public void setCachedData(byte[] buf)

toString

public String toString()

update

public boolean update()
            throws IOException

writeTo

public void writeTo(OutputStream os,
                    long startByte,
                    long count)
            throws IOException
Overrides:
writeTo in interface Resource

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.