FileDocCategorySizeDatePackage
TimeStamp.javaAPI DocApache Tomcat 6.0.144220Fri Jul 20 04:20:32 BST 2007org.apache.tomcat.util.buf

TimeStamp

public final class TimeStamp extends Object implements Serializable
Main tool for object expiry. Marks creation and access time of an "expirable" object, and extra properties like "id", "valid", etc. Used for objects that expire - originally Sessions, but also Contexts, Servlets, cache - or any other object that expires.
author
Costin Manolache

Fields Summary
private long
creationTime
private long
lastAccessedTime
private long
thisAccessedTime
private boolean
isNew
private long
maxInactiveInterval
private boolean
isValid
MessageBytes
name
int
id
Object
parent
Constructors Summary
public TimeStamp()

    
      
    
Methods Summary
public longgetCreationTime()

	return creationTime;
    
public intgetId()
Each object can have an unique id, similar with name but providing faster access ( array vs. hashtable lookup )

	return id;
    
public longgetLastAccessedTime()

	return lastAccessedTime;
    
public longgetMaxInactiveInterval()
Inactive interval in millis - the time is computed in millis, convert to secs in the upper layer

	return maxInactiveInterval;
    
public MessageBytesgetName()
Return the "name" of the timestamp. This can be used to associate unique identifier with each timestamped object. The name is a MessageBytes - i.e. a modifiable byte[] or char[].

	if( name==null ) name=MessageBytes.newInstance();//lazy
	return name;
    
public java.lang.ObjectgetParent()

	return parent;
    
public longgetThisAccessedTime()

        return thisAccessedTime;
    
public booleanisNew()

	return isNew;
    
public booleanisValid()

	return isValid;
    
public voidrecycle()

	creationTime = 0L;
	lastAccessedTime = 0L;
	maxInactiveInterval = -1;
	isNew = true;
	isValid = false;
	id=-1;
	if( name!=null) name.recycle();
    
public voidsetCreationTime(long time)

	this.creationTime = time;
	this.lastAccessedTime = time;
	this.thisAccessedTime = time;
    
public voidsetId(int id)

	this.id=id;
    
public voidsetMaxInactiveInterval(long interval)

	maxInactiveInterval = interval;
    
public voidsetNew(boolean isNew)

	this.isNew = isNew;
    
public voidsetParent(java.lang.Object o)
Returns the owner of this stamp ( the object that is time-stamped ). For a

	parent=o;
    
public voidsetValid(boolean isValid)

	this.isValid = isValid;
    
public voidtouch(long time)
Access notification. This method takes a time parameter in order to allow callers to efficiently manage expensive calls to System.currentTimeMillis()

	this.lastAccessedTime = this.thisAccessedTime;
	this.thisAccessedTime = time;
	this.isNew=false;