org.norther.tammi.core.cache
Class AbstractResource<T>

java.lang.Object
  extended by org.norther.tammi.core.cache.AbstractResource<T>
Type Parameters:
T - the resource type.
All Implemented Interfaces:
Resource<T>
Direct Known Subclasses:
AbstractResourceResolver.ResolvedResource, FileResource, LobResource, URLResource, VoidResource

public abstract class AbstractResource<T>
extends Object
implements Resource<T>

An abstract implementation of Resource.

Version:
$Id: AbstractResource.java,v 1.9 2010/01/13 21:39:07 cvsimp Exp $
Author:
Ilkka Priha

Constructor Summary
AbstractResource(String name, T src)
          Constructs a new resource.
 
Method Summary
 boolean equals(Object other)
           
 long getCheckInterval()
          Gets the interval of checking validity of the resource.
 long getLastModified()
          Gets the resource modification time.
protected abstract  long getModified()
          Gets the resource modification time.
 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.
 T getSource()
          Gets the source of the resource.
 String getVersionTag()
          Gets the version tag of the resource.
 int hashCode()
           
 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.
 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, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.cache.Resource
getInputStream, getLength, isValid, release
 

Constructor Detail

AbstractResource

public AbstractResource(String name,
                        T src)
Constructs a new resource.

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

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getName

public String getName()
Description copied from interface: Resource
Gets the name of the resource.

Specified by:
getName in interface Resource<T>
Returns:
the resource name.

getPath

public String getPath()
Description copied from interface: Resource
Gets the path of the resource.

Specified by:
getPath in interface Resource<T>
Returns:
the path of the resource.

setPath

public void setPath(String path)
Description copied from interface: Resource
Sets the path of the resource.

Specified by:
setPath in interface Resource<T>
Parameters:
path - the path of the resource.

getSource

public T getSource()
Description copied from interface: Resource
Gets the source of the resource.

Specified by:
getSource in interface Resource<T>
Returns:
the resurce source.

getVersionTag

public String getVersionTag()
Description copied from interface: Resource
Gets the version tag of the resource.

Specified by:
getVersionTag in interface Resource<T>
Returns:
the resource tag.

getLastModified

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

Specified by:
getLastModified in interface Resource<T>
Returns:
the resource modification time.

getCheckInterval

public long getCheckInterval()
Description copied from interface: Resource
Gets the interval of checking validity of the resource.

Specified by:
getCheckInterval in interface Resource<T>
Returns:
the check interval in milliseconds.

setCheckInterval

public void setCheckInterval(long msecs)
Description copied from interface: Resource
Sets the interval of checking validity of the resource.

Specified by:
setCheckInterval in interface Resource<T>
Parameters:
msecs - the check interval in milliseconds (-1 = only once).

isExpireAfterAccess

public boolean isExpireAfterAccess()
Description copied from interface: Resource
Checks whether the resource should be expired after it has been accessed.

Specified by:
isExpireAfterAccess in interface Resource<T>
Returns:
true if to be expired, false otherwise.

setExpireAfterAccess

public void setExpireAfterAccess(boolean flag)
Description copied from interface: Resource
Sets whether the resource should be expired after it has been accessed.

Specified by:
setExpireAfterAccess in interface Resource<T>
Parameters:
flag - true if to be expired, false otherwise.

isDeleteOnRelease

public boolean isDeleteOnRelease()
Description copied from interface: Resource
Checks whether the resource source should be deleted on release.

Specified by:
isDeleteOnRelease in interface Resource<T>
Returns:
true if to be deleted, false otherwise.

setDeleteOnRelease

public void setDeleteOnRelease(boolean flag)
Description copied from interface: Resource
Sets whether the resource source should be deleted on release.

Specified by:
setDeleteOnRelease in interface Resource<T>
Parameters:
flag - true if to be deleted, false otherwise.

getSizeLimit

public int getSizeLimit()
Description copied from interface: Resource
Gets the size limit for a cached resource.

Specified by:
getSizeLimit in interface Resource<T>
Returns:
the limit for a resource size in bytes.

setSizeLimit

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

Specified by:
setSizeLimit in interface Resource<T>
Parameters:
limit - a limit for a resource size in bytes (-1 = unlimited).

getModified

protected abstract long getModified()
Gets the resource modification time.

Returns:
the resource modification time.


Copyright © 2004 The Norther Organization. All rights reserved.