KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jorphan > timer > ITimer


1 // $Header: /home/cvs/jakarta-jmeter/src/jorphan/org/apache/jorphan/timer/ITimer.java,v 1.3 2004/02/11 23:57:23 sebb Exp $
2
/*
3  * Copyright 2002-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 package org.apache.jorphan.timer;
20
21 /**
22  * A simple interface for measuring time intervals. An instance of this goes
23  * through the following lifecycle states:
24  * <dl>
25  * <dt><em>ready</em></dt>
26  * <dd>timer is ready to start a new measurement</dd>
27  * <dt><em>started</em></dt>
28  * <dd>timer has recorded the starting time interval point</dd>
29  * <dt><em>stopped</em></dt>
30  * <dd>timer has recorded the ending time interval point</dd>
31  * </dl>
32  * See individual methods for details.
33  * <p>
34  * If this library has been compiled with
35  * {@link ITimerConstants#DO_STATE_CHECKS} set to 'true' the implementation
36  * will enforce this lifecycle model and throw IllegalStateException when it
37  * is violated.
38  *
39  * @author <a HREF="mailto:vroubtsov@illinoisalumni.org">Vlad Roubtsov</a>
40  * @author Originally published in <a HREF="http://www.javaworld.com/javaworld/javaqa/2003-01/01-qa-0110-timing.html">JavaWorld</a>
41  * @version $Revision: 1.3 $
42  */

43 public interface ITimer
44 {
45     /**
46      * Starts a new time interval and advances this timer instance to 'started'
47      * state. This method can be called from 'ready' state only.
48      */

49     void start ();
50     
51     /**
52      * Terminates the current time interval and advances this timer instance to
53      * 'stopped' state. Interval duration will be available via
54      * {@link #getDuration()} method. This method can be called from 'started'
55      * state only.
56      */

57     void stop ();
58     
59     /**
60      * Returns the duration of the time interval that elapsed between the last
61      * calls to {@link #start()} and {@link #stop()}. This method can be called
62      * any number of times from 'stopped' state and will return the same value
63      * each time.
64      *
65      * @return interval duration in milliseconds
66      */

67     double getDuration ();
68     
69     /**
70      * This method can be called from any state and will reset this timer
71      * instance back to 'ready' state.
72      */

73     void reset ();
74
75 }
76
Popular Tags