org.mortbay.util

Class CachedResource

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
ResourceaddPath(String path)
Returns the resource contained inside the current resource with the given name
voidclear()
booleandelete()
Deletes the given resource
booleanequals(Object o)
booleanexists()
Returns true if the respresened resource exists.
byte[]getCachedData()
FilegetFile()
InputStreamgetInputStream()
Returns an input stream to the resource
StringgetName()
Returns the name of the resource
OutputStreamgetOutputStream()
Returns an output stream to the resource
URLgetURL()
inthashCode()
booleanisDirectory()
booleanisUptoDate()
longlastModified()
longlength()
String[]list()
Returns a list of resource names contained in the given resource
voidrelease()
Release any resources held by the resource.
booleanrenameTo(Resource dest)
Rename the given resource
voidsetCachedData(byte[] buf)
StringtoString()
booleanupdate()
voidwriteTo(OutputStream os, long startByte, long count)

Method Detail

addPath

public Resource addPath(String path)
Returns the resource contained inside the current resource with the given name

clear

public void clear()

delete

public boolean delete()
Deletes the given resource

equals

public boolean equals(Object o)

exists

public boolean exists()
Returns true if the respresened resource exists.

getCachedData

public byte[] getCachedData()

getFile

public File getFile()

getInputStream

public InputStream getInputStream()
Returns an input stream to the resource

getName

public String getName()
Returns the name of the resource

getOutputStream

public OutputStream getOutputStream()
Returns an output stream to the resource

getURL

public URL getURL()

hashCode

public int hashCode()

isDirectory

public boolean isDirectory()

isUptoDate

public boolean isUptoDate()

lastModified

public long lastModified()

length

public long length()

list

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

release

public void release()
Release any resources held by the resource.

renameTo

public boolean renameTo(Resource dest)
Rename the given resource

setCachedData

public void setCachedData(byte[] buf)

toString

public String toString()

update

public boolean update()

writeTo

public void writeTo(OutputStream os, long startByte, long count)
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.