org.norther.tammi.core.cache
Interface Resource

All Known Implementing Classes:
AbstractResourceResolver.AbstractResource, BufferedResource, PlainResource

public interface Resource

An interface to resources.

Author:
Ilkka Priha

Method Summary
 long getCheckInterval()
          Gets the interval of checking validity of the resource.
 byte[] getContents()
          Gets the contents of the resource as bytes.
 InputStream getInputStream()
          Gets the resource as a stream.
 long getLastModified()
          Gets the resource modification time.
 long getLength()
          Gets the length of the resource.
 String getName()
          Gets the name of the resource.
 String getPath()
          Gets the path of the resource.
 int getSizeLimit()
          Gets the size limit for a cached resource.
 Object getSource()
          Gets the source of the resource.
 boolean isDeleteOnRelease()
          Checks whether the resource source should be deleted on release.
 boolean isValid()
          Checks whether the original resource is still valid.
 void release()
          Releases the cached resource.
 void setCheckInterval(long msecs)
          Sets the interval of checking validity of the resource.
 void setDeleteOnRelease(boolean flag)
          Sets whether the resource source should be deleted on release.
 void setPath(String path)
          Sets the path of the resource.
 void setSizeLimit(int limit)
          Sets a size limit for a resource.
 

Method Detail

getName

String getName()
Gets the name of the resource.

Returns:
the resource name.

getSource

Object getSource()
Gets the source of the resource.

Returns:
the resurce source.

getLength

long getLength()
Gets the length of the resource.

Returns:
the resource length or -1 if not known.

getLastModified

long getLastModified()
Gets the resource modification time.

Returns:
the resource modification time.

getCheckInterval

long getCheckInterval()
Gets the interval of checking validity of the resource.

Returns:
the check interval in milliseconds.

setCheckInterval

void setCheckInterval(long msecs)
Sets the interval of checking validity of the resource.

Parameters:
msecs - the check interval in milliseconds (-1 = only once).

isDeleteOnRelease

boolean isDeleteOnRelease()
Checks whether the resource source should be deleted on release.

Returns:
true if to be deleted, false otherwise.

setDeleteOnRelease

void setDeleteOnRelease(boolean flag)
Sets whether the resource source should be deleted on release.

Parameters:
flag - true if to be deleted, false otherwise.

getSizeLimit

int getSizeLimit()
Gets the size limit for a cached resource.

Returns:
the limit for a resource size in bytes.

setSizeLimit

void setSizeLimit(int limit)
Sets a size limit for a resource.

Parameters:
limit - a limit for a resource size in bytes (-1 = unlimited).

getPath

String getPath()
Gets the path of the resource.

Returns:
the path of the resource.

setPath

void setPath(String path)
Sets the path of the resource.

Parameters:
path - the path of the resource.

getInputStream

InputStream getInputStream()
                           throws IOException
Gets the resource as a stream.

Returns:
the resource as a stream.
Throws:
IOException - on I/O errors.

getContents

byte[] getContents()
                   throws IOException
Gets the contents of the resource as bytes.

Returns:
the resource contents as bytes.
Throws:
IOException - on I/O errors.

isValid

boolean isValid()
Checks whether the original resource is still valid.

Returns:
true for a valid resource, otherwise false.

release

void release()
Releases the cached resource.



Copyright © 2004 The Norther Organization. All rights reserved.