org.apache.commons.lang.time
クラス StopWatch

java.lang.Object
  拡張org.apache.commons.lang.time.StopWatch

public class StopWatch
extends Object

StopWatch は時間調整のための簡易APIを提供します。

StopWatch provides a convenient API for timings.

このクラスのメソッドは不適当な要求に対する防御措置を行いません。 従って start の前に stop 、 suspend の前に resume 、 split の前に unsplit を呼ぶことが出来てしまいます。 このような場合の結果は不確定です。

The methods do not protect against inappropriate calls. Thus you can call stop before start, resume before suspend or unsplit before split. The results are indeterminate in these cases.

ストップウォッチをスタートさせるには start() をコールします。 その後、以下の事をすることが出来ます:

To start the watch, call {@link #start()}. At this point you can:

出力メソッド toString()getTime() は stop、 split、 suspend の後に呼ばれることを意図していますが、他の状態で呼ばれても適切な結果を返します。

It is intended that the output methods {@link #toString()} and {@link #getTime()} should only be called after stop, split or suspend, however a suitable result will be returned at other points.

導入されたバージョン:
2.0
バージョン:
$Id: StopWatch.java,v 1.1.1.1 2004/02/13 10:02:05 hioki Exp $
作成者:
Henri Yandell, Stephen Colebourne
翻訳者:
日置 聡
翻訳状況:
初稿(校正者募集中)
翻訳更新日:
2003/09/21

コンストラクタの概要
StopWatch()
          コンストラクタです。
 
メソッドの概要
 long getTime()
          ストップウォッチの経過時間を取得します。
 void reset()
          ストップウォッチをリセットします。
 void resume()
          一時停止されているストップウォッチの動作を再開します。
 void split()
          途中時間を取得します。
 void start()
          ストップウォッチをスタートします。
 void stop()
          ストップウォッチをストップします。
 void suspend()
          再開されるまでストップウォッチを一時停止します。
 String toString()
          ストップウォッチが計測した時間の概要の文字列表現を取得します。
 void unsplit()
          途中時間を削除します。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

コンストラクタの詳細

StopWatch

public StopWatch()

コンストラクタです。

Constructor.

メソッドの詳細

start

public void start()

ストップウォッチをスタートします。

Start the stopwatch.

このメソッドは以前の値をクリアし、新たな処理のセッションを開始します。

This method starts a new timing session, clearing any previous values.


stop

public void stop()

ストップウォッチをストップします。

Stop the stopwatch.

このメソッドは処理のセッションを終了し、時間の結果を取得できるようにします。

This method ends a new timing session, allowing the time to be retrieved.


reset

public void reset()

ストップウォッチをリセットします。

Reset the stopwatch.

このメソッドは内部の値をクリアし、このオブジェクトを再利用可能にします。

This method clears the internal values to allow the object to be reused.


split

public void split()

途中時間を取得します。

Split the time.

このメソッドはストップウォッチの停止時間を設定し時間の結果を取得できるようにします。 開始時間には影響を与えないため、unsplit() を呼ぶことによりストップウォッチの処理を再開することが出来ます。

This method sets the stop time of the watch to allow a time to be extracted. The start time is unaffected, enabling {@link #unsplit()} to contine the timing from the original start point.


unsplit

public void unsplit()

途中時間を削除します。

Remove a split.

このメソッドは停止時間をクリアします。 開始時間には影響を与えないためストップウォッチの処理を再開することが出来ます。

This method clears the stop time. The start time is unaffected, enabling timing from the original start point to continue.


suspend

public void suspend()

再開されるまでストップウォッチを一時停止します。

Suspend the stopwatch for later resumption.

このメソッドは再開されるまでストップウォッチを一時停止します。 ストップウォッチは suspend と resume の間の時間をトータルの時間に含めません。

This method suspends the watch until it is resumed. The watch will not include time between the suspend and resume calls in the total time.


resume

public void resume()

一時停止されているストップウォッチの動作を再開します。

Resume the stopwatch after a suspend.

このメソッドは一時停止されているストップウォッチの動作を再開します。 ストップウォッチは suspend と resume の間の時間をトータルの時間に含めません。

This method resumes the watch after it was suspended. The watch will not include time between the suspend and resume calls in the total time.


getTime

public long getTime()

ストップウォッチの経過時間を取得します。

Get the time on the stopwatch.

これは、start と最後の split との間、 start と end の間、 start とこのメソッドが呼ばれたタイミングの間のいずれかになります。

This is either the time between start and latest split, between start and stop, or the time between the start and the moment this method is called.

戻り値:
ミリセカンドで表現された時間
the time in milliseconds

toString

public String toString()

ストップウォッチが計測した時間の概要の文字列表現を取得します。

Gets a summary of the time that the stopwatch recorded as a string.

ISO8601 に近い、 時間::.ミリ秒 のフォーマットが使用されます。

The format used is ISO8601-like, hours:minutes:seconds.milliseconds.

戻り値:
計測時間を示す String
the time as a String


このドキュメントは、Ja-Jakartaにより訳されました。 コメントがある場合は report@jajakarta.orgまでお願いします。
Translated into Japanese by jajakarta.org. The original page is here.
Copyright (c) 2002-2003 - Apache Software Foundation