站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 common API Documentation 英文版文档

StopWatch (JBoss/Common API) - JBoss 4.0.1 sp1 common API Documentation 英文版文档


org.jboss.util
Class StopWatch

java.lang.Object
  extended byorg.jboss.util.StopWatch
All Implemented Interfaces:
Cloneable, Serializable

public class StopWatch
extends Object
implements Serializable, Cloneable

Simulates a stop watch with a lap counter.

Version:
$Revision: 1.6 $
Author:
Jason Dillon
See Also:
Serialized Form

Field Summary
protected  int count
          The lap count
protected  boolean running
          Is the watch started
protected  long start
          Start time
protected  long stop
          Stop time
protected  long total
          Total time
 
Constructor Summary
StopWatch()
          Default constructor.
StopWatch(boolean running)
          Construct a StopWatch.
 
Method Summary
 Object clone()
          Return a cloned copy of this object.
 long getAverageLapTime()
          Get the average lap time since the watch was started.
 int getLapCount()
          Get the lap count.
 long getLapTime()
          Get the elapsed lap time since the watch was started.
 long getTime()
          Get the elapsed time since the watch was created or last reset.
 boolean isRunning()
          Check if the watch is running.
static StopWatch makeSynchronized(StopWatch watch)
          Return a synchronized stop watch.
 void reset()
          Reset the watch.
 void start()
          Start the watch.
 void start(boolean reset)
          Start the watch.
 long stop()
          Stop the watch.
 String toString()
          Return a string representation.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

total

protected long total
Total time


start

protected long start
Start time


stop

protected long stop
Stop time


count

protected int count
The lap count


running

protected boolean running
Is the watch started

Constructor Detail

StopWatch

public StopWatch()
Default constructor.


StopWatch

public StopWatch(boolean running)
Construct a StopWatch.

Parameters:
running - Start the watch
Method Detail

start

public void start(boolean reset)
Start the watch.

Parameters:
reset - True to reset the watch prior to starting.

start

public void start()
Start the watch.


stop

public long stop()
Stop the watch.

Returns:
Elapsed time or 0 if the watch was never started.

reset

public void reset()
Reset the watch.


getLapCount

public int getLapCount()
Get the lap count.

Returns:
The lap count.

getLapTime

public long getLapTime()
Get the elapsed lap time since the watch was started.

Returns:
Elapsed lap time or 0 if the watch was never started

getAverageLapTime

public long getAverageLapTime()
Get the average lap time since the watch was started.

Returns:
Average lap time since the watch was started.

getTime

public long getTime()
Get the elapsed time since the watch was created or last reset.

Returns:
Elapsed time or 0 if the watch was never started.

isRunning

public boolean isRunning()
Check if the watch is running.

Returns:
True if the watch is running.

toString

public String toString()
Return a string representation.


clone

public Object clone()
Return a cloned copy of this object.

Returns:
A cloned copy of this object.

makeSynchronized

public static StopWatch makeSynchronized(StopWatch watch)
Return a synchronized stop watch.

Parameters:
watch - StopWatch to synchronize.
Returns:
Synchronized stop watch.


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.