org.norther.tammi.core.cache
Class BufferedResource

java.lang.Object
  extended by org.norther.tammi.core.cache.PlainResource
      extended by org.norther.tammi.core.cache.BufferedResource
All Implemented Interfaces:
Serializable, EventListener, CacheListener, Resource

public class BufferedResource
extends PlainResource

A buffered implementation of CachedResource maintaining content.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
BufferedResource(String name, Object src)
          Constructs a new resource.
BufferedResource(String name, Object src, boolean keep)
          Constructs a new resource with a keep lost flag.
BufferedResource(String name, Object src, byte[] content)
          Constructs a new resource with ready-made content.
 
Method Summary
 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.
 void release()
          Releases the cached resource.
 void setSizeLimit(int limit)
          Sets a size limit for a resource.
 
Methods inherited from class org.norther.tammi.core.cache.PlainResource
activated, expired, getCheckInterval, getContents, getName, getPath, getSizeLimit, getSource, isDeleteOnRelease, isValid, passivated, setCheckInterval, setDeleteOnRelease, setPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferedResource

public BufferedResource(String name,
                        Object src)
Constructs a new resource.

Parameters:
name - the name.
src - the source.

BufferedResource

public BufferedResource(String name,
                        Object src,
                        boolean keep)
Constructs a new resource with a keep lost flag.

Parameters:
name - the name.
src - the source.
keep - the keep lost flag.

BufferedResource

public BufferedResource(String name,
                        Object src,
                        byte[] content)
Constructs a new resource with ready-made content.

Parameters:
name - the name.
src - the source.
content - the content.
Method Detail

getLength

public long getLength()
Description copied from interface: Resource
Gets the length of the resource.

Specified by:
getLength in interface Resource
Overrides:
getLength in class PlainResource
Returns:
the resource length or -1 if not known.

getLastModified

public long getLastModified()
Description copied from interface: Resource
Gets the resource modification time.

Specified by:
getLastModified in interface Resource
Overrides:
getLastModified in class PlainResource
Returns:
the resource modification time.

setSizeLimit

public void setSizeLimit(int limit)
Description copied from interface: Resource
Sets a size limit for a resource.

Specified by:
setSizeLimit in interface Resource
Overrides:
setSizeLimit in class PlainResource
Parameters:
limit - a limit for a resource size in bytes (-1 = unlimited).

getInputStream

public InputStream getInputStream()
                           throws IOException
Description copied from interface: Resource
Gets the resource as a stream.

Specified by:
getInputStream in interface Resource
Overrides:
getInputStream in class PlainResource
Returns:
the resource as a stream.
Throws:
IOException - on I/O errors.

getContents

public byte[] getContents()
                   throws IOException
Description copied from interface: Resource
Gets the contents of the resource as bytes.

Specified by:
getContents in interface Resource
Overrides:
getContents in class PlainResource
Returns:
the resource contents as bytes.
Throws:
IOException - on I/O errors.

release

public void release()
Description copied from interface: Resource
Releases the cached resource.

Specified by:
release in interface Resource
Overrides:
release in class PlainResource


Copyright © 2004 The Norther Organization. All rights reserved.