|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.norther.tammi.core.cache.BufferedResource<T>
T
- the resource type.public class BufferedResource<T>
A buffered implementation of Resource maintaining content.
Constructor Summary | |
---|---|
BufferedResource(Resource<? extends T> res)
Constructs a new resource. |
|
BufferedResource(Resource<? extends T> res,
boolean keep)
Constructs a new resource with a keep lost flag. |
|
BufferedResource(Resource<T> res,
byte[] content)
Constructs a new resource with ready-made content. |
Method Summary | |
---|---|
void |
activated(CachedEntryEvent event)
Notifies the object that it has been activated to the cache. |
void |
expired(CachedEntryEvent event)
Notifies the object that it has been expired from the cache. |
protected byte[] |
getBuffer()
Gets the byte buffer. |
long |
getCheckInterval()
Gets the interval of checking validity of the resource. |
protected byte[] |
getContents(InputStream in)
Gets the contents from the specified stream 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. |
Resource<? extends T> |
getResource()
Gets the buffered resource. |
int |
getSizeLimit()
Gets the size limit for a cached resource. |
T |
getSource()
Gets the source of the resource. |
String |
getVersionTag()
Gets the version tag of the resource. |
boolean |
isDeleteOnRelease()
Checks whether the resource source should be deleted on release. |
boolean |
isExpireAfterAccess()
Checks whether the resource should be expired after it has been accessed. |
boolean |
isValid()
Checks whether the original resource is still valid. |
void |
passivated(CachedEntryEvent event)
Notifies the object that it has been passivated from the cache. |
void |
release()
Releases the cached resource. |
void |
removed(CachedEntryEvent event)
Notifies the object that it has been removed from the cache. |
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 |
setExpireAfterAccess(boolean flag)
Sets whether the resource should be expired after it has been accessed. |
void |
setPath(String path)
Sets the path of the resource. |
void |
setSizeLimit(int limit)
Sets a size limit for a resource. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BufferedResource(Resource<? extends T> res)
res
- the resource.public BufferedResource(Resource<? extends T> res, boolean keep)
res
- the resource.keep
- the keep lost flag.public BufferedResource(Resource<T> res, byte[] content)
res
- the resource.content
- the content.Method Detail |
---|
public String getVersionTag()
Resource
getVersionTag
in interface Resource<T>
public String getName()
Resource
getName
in interface Resource<T>
public String getPath()
Resource
getPath
in interface Resource<T>
public void setPath(String path)
Resource
setPath
in interface Resource<T>
path
- the path of the resource.public T getSource()
Resource
getSource
in interface Resource<T>
public long getLength()
Resource
getLength
in interface Resource<T>
public long getLastModified()
Resource
getLastModified
in interface Resource<T>
public long getCheckInterval()
Resource
getCheckInterval
in interface Resource<T>
public void setCheckInterval(long msecs)
Resource
setCheckInterval
in interface Resource<T>
msecs
- the check interval in milliseconds (-1 = only once).public boolean isExpireAfterAccess()
Resource
isExpireAfterAccess
in interface Resource<T>
public void setExpireAfterAccess(boolean flag)
Resource
setExpireAfterAccess
in interface Resource<T>
flag
- true if to be expired, false otherwise.public boolean isDeleteOnRelease()
Resource
isDeleteOnRelease
in interface Resource<T>
public void setDeleteOnRelease(boolean flag)
Resource
setDeleteOnRelease
in interface Resource<T>
flag
- true if to be deleted, false otherwise.public int getSizeLimit()
Resource
getSizeLimit
in interface Resource<T>
public void setSizeLimit(int limit)
Resource
setSizeLimit
in interface Resource<T>
limit
- a limit for a resource size in bytes (-1 = unlimited).public InputStream getInputStream() throws IOException
Resource
getInputStream
in interface Resource<T>
IOException
- on I/O errors.public boolean isValid()
Resource
isValid
in interface Resource<T>
public void release()
Resource
release
in interface Resource<T>
public void expired(CachedEntryEvent event)
CacheListener
expired
in interface CacheListener
event
- the cached entry event.public void removed(CachedEntryEvent event)
CacheListener
removed
in interface CacheListener
event
- the cached entry event.public void passivated(CachedEntryEvent event)
CacheListener
passivated
in interface CacheListener
event
- the cached entry event.public void activated(CachedEntryEvent event)
CacheListener
activated
in interface CacheListener
event
- the cached entry event.public Resource<? extends T> getResource()
protected byte[] getBuffer() throws IOException
IOException
- on I/O errors.protected byte[] getContents(InputStream in) throws IOException
in
- the input stream to read from.
IOException
- on I/O errors.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |