Rakesh API

org.rakeshv
Class Statistics

java.lang.Object
  extended by org.rakeshv.Statistics

public class Statistics
extends java.lang.Object

A simple value object used to store statistics about usage of resources.

The following shows the easiest way to use this class.

   import org.rakeshv.Statistics;

   ...

     // Instance member
     private Statistics statistics = new Statistics();

     ...

       // Within method
       statistics.update();

     ...
 

Copyright 2005 Rakesh Vidyadharan

Version:
$Id: ConnectionFactory.java,v 1.2 2005/10/29 22:27:38 rakesh Exp $
Author:
Rakesh Vidyadharan 2005-11-20

Field Summary
private  int accessCount
          The total number of times the resource has been accessed.
private  long lastAccess
          The time in milliseconds that represents the last time at which the resource was accessed.
 
Constructor Summary
Statistics()
          Default constructor.
Statistics(int accessCount, long lastAccess)
          Designated constructor.
Statistics(long lastAccess)
          Create a new instance of the class using the specified value for lastAccess.
 
Method Summary
 int getAccessCount()
          Returns accessCount.
 java.util.Date getLastAccess()
          Returns lastAccess as a Date object.
 void incrementAccessCount()
          Increment the value of accessCount
 void resetAccessCount()
          Reset the accessCount to 0.
protected  void setAccessCount(int accessCount)
          Set accessCount.
 void setLastAccess(java.util.Date date)
          Set the value of lastAccess using the specified date.
 void setLastAccess(long lastAccess)
          Set the value of lastAccess using the specified millisecond value.
 void update()
          Update the instance members to indicate that a resource has been accessed.
 void updateLastAccess()
          Update the lastAccess to the current time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

accessCount

private volatile int accessCount
The total number of times the resource has been accessed.

Note: No synchronisation is done while modifying the value of this field.


lastAccess

private volatile long lastAccess
The time in milliseconds that represents the last time at which the resource was accessed.

Note: No synchronisation is done while modifying the value of this field.

Constructor Detail

Statistics

public Statistics()
Default constructor. Initialises the instance members with default values.


Statistics

public Statistics(long lastAccess)
Create a new instance of the class using the specified value for lastAccess.

Parameters:
lastAccess - The millisecond value to use to initialise the lastAccess.

Statistics

public Statistics(int accessCount,
                  long lastAccess)
Designated constructor. Create a new instance of the class using the specified values.

Parameters:
accessCount - The number of times the resource has been accessed.
lastAccess - The millisecond value to use to initialise the lastAccess.
Method Detail

getLastAccess

public final java.util.Date getLastAccess()
Returns lastAccess as a Date object.

Returns:
Date A date value that represents the lastAccess time.

getAccessCount

public final int getAccessCount()
Returns accessCount.

Returns:
int The value/reference of/to accessCount.

incrementAccessCount

public final void incrementAccessCount()
Increment the value of accessCount


resetAccessCount

public final void resetAccessCount()
Reset the accessCount to 0.


setAccessCount

protected final void setAccessCount(int accessCount)
Set accessCount.

Parameters:
accessCount - The value to set.

setLastAccess

public final void setLastAccess(long lastAccess)
Set the value of lastAccess using the specified millisecond value.

Parameters:
lastAccess - The value in milliseconds to set.

setLastAccess

public final void setLastAccess(java.util.Date date)
Set the value of lastAccess using the specified date.

Parameters:
date - The date to use to set the value.

updateLastAccess

public final void updateLastAccess()
Update the lastAccess to the current time.


update

public final void update()
Update the instance members to indicate that a resource has been accessed.

See Also:
incrementAccessCount(), updateLastAccess()

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan