jclass
Class TimedObject

java.lang.Object
  |
  +--jclass.TimedObject
Direct Known Subclasses:
Entity, Message, NodeConnection, SimpleData, Timer

public class TimedObject
extends java.lang.Object
implements java.io.Serializable

Is a very simple class that includes a timestamp in it. Should be subclassed to do something really usefull.

Written: Radu Sion
Version: 0.11
Source: TimedObject.java

Visit Smart Software 

See Also:
Serialized Form

Field Summary
 long Created
          A object creation timestamp in ms that should be taken from a timebase that characterizes this object.
 
Constructor Summary
TimedObject()
          Constructor that initializes the internal creation timestamp to the absolute UTC time via System.currentTimeMillis().
TimedObject(long timestamp)
          Constructor that uses the provided parameter to initialize the creation time.
 
Method Summary
 long computeAge(long now)
          Computes the age of this object referring to a given moment in time.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Created

public long Created
A object creation timestamp in ms that should be taken from a timebase that characterizes this object. This may also be a absolute UTC time based in midnight Jan the 1st 1970.
Constructor Detail

TimedObject

public TimedObject()
Constructor that initializes the internal creation timestamp to the absolute UTC time via System.currentTimeMillis().

TimedObject

public TimedObject(long timestamp)
Constructor that uses the provided parameter to initialize the creation time. No parameter checkings are performed.
Parameters:
timestamp - Value used to init the internal creation timestamp
Method Detail

computeAge

public long computeAge(long now)
Computes the age of this object referring to a given moment in time. The moment should be after the creation of this object, otherwise the return will be negative.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object