org.omnaest.utils.time
Class DurationCapture

java.lang.Object
  extended by org.omnaest.utils.time.DurationCapture

public class DurationCapture
extends Object

A DurationCapture will measure time intervals.

Author:
Omnaest
See Also:
newInstance(), DurationCaptureTypeFactory

Nested Class Summary
static class DurationCapture.Interval
          Saves the interval points and their data like name and time.
protected static class DurationCapture.IntervalStatistic
          Internal class for statistical data calculated for the DurationCapture.Interval instances.
 
Field Summary
static Class<? extends DurationCapture> implementationForDurationClass
          Used by the factory method.
protected  Object intervalDefaultKey
           
protected  Map<Object,DurationCapture.Interval> intervalKeyToIntervalMap
           
 
Constructor Summary
protected DurationCapture()
          Use newInstance() for creating an instance of this class.
 
Method Summary
 String calculateIntervalStatisticLogMessage()
          Returns the collected statistical informations for the intervals durations.
protected  Map<Object,DurationCapture.IntervalStatistic> calculateIntervalStatisticMap()
          Calculates the statistical data for the interval and returns a map with the intervalKeys and a DurationCapture.IntervalStatistic instance.
protected  DurationCapture.Interval determineInterval(Object key)
          Returns an DurationCapture.Interval for the given key.
 long getDurationInMilliseconds()
          Returns the needed time between measurement start and stop in milliseconds.
 long getDurationInMilliseconds(Object intervalKey)
          Returns the needed time between measurement start and stop in milliseconds.
 long getInterimTimeInMilliseconds()
          Returns the time since starting the measurement and now in milliseconds.
 long getInterimTimeInMilliseconds(Object intervalKey)
          Returns the time since starting the measurement and now in milliseconds.
 List<Object> getIntervalKeyList()
          Returns all available DurationCapture.Interval keys.
protected  boolean hasDefaultInterval()
          Returns true, if there is an DurationCapture.Interval instance for the intervalDefaultKey.
static DurationCapture newInstance()
          Creates a new instance of this class.
 void resetTimer()
          Sets the timer of the default DurationCapture.Interval back to zero.
 void resetTimers()
          Resets the timer of all contained DurationCapture.Interval instances.
 DurationCapture startTimeMeasurement()
          Starts the measurement of time.
 DurationCapture startTimeMeasurement(Object intervalKey)
          Starts the time measurement which will relate to the given key.
 DurationCapture stopTimeMeasurement()
          Stops the measurement of the time for the default DurationCapture.Interval.
 DurationCapture stopTimeMeasurement(Object intervalKey)
          Stops the time measurement for the respective DurationCapture.Interval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

intervalKeyToIntervalMap

protected Map<Object,DurationCapture.Interval> intervalKeyToIntervalMap

intervalDefaultKey

protected Object intervalDefaultKey

implementationForDurationClass

public static Class<? extends DurationCapture> implementationForDurationClass
Used by the factory method.

See Also:
#createNewInstance
Constructor Detail

DurationCapture

protected DurationCapture()
Use newInstance() for creating an instance of this class.

Method Detail

startTimeMeasurement

public DurationCapture startTimeMeasurement(Object intervalKey)
Starts the time measurement which will relate to the given key.

Parameters:
intervalKey -
Returns:
this

determineInterval

protected DurationCapture.Interval determineInterval(Object key)
Returns an DurationCapture.Interval for the given key.

Parameters:
key -
Returns:

startTimeMeasurement

public DurationCapture startTimeMeasurement()
Starts the measurement of time.

Returns:

resetTimer

public void resetTimer()
Sets the timer of the default DurationCapture.Interval back to zero.


resetTimers

public void resetTimers()
Resets the timer of all contained DurationCapture.Interval instances.


stopTimeMeasurement

public DurationCapture stopTimeMeasurement()
Stops the measurement of the time for the default DurationCapture.Interval.

Returns:

stopTimeMeasurement

public DurationCapture stopTimeMeasurement(Object intervalKey)
Stops the time measurement for the respective DurationCapture.Interval.

Parameters:
intervalKey -
Returns:
this

calculateIntervalStatisticMap

protected Map<Object,DurationCapture.IntervalStatistic> calculateIntervalStatisticMap()
Calculates the statistical data for the interval and returns a map with the intervalKeys and a DurationCapture.IntervalStatistic instance.


getDurationInMilliseconds

public long getDurationInMilliseconds()
Returns the needed time between measurement start and stop in milliseconds.

Returns:
See Also:
getDurationInMilliseconds(Object)

getDurationInMilliseconds

public long getDurationInMilliseconds(Object intervalKey)
Returns the needed time between measurement start and stop in milliseconds.

Parameters:
intervalKey -
Returns:
See Also:
getDurationInMilliseconds()

getInterimTimeInMilliseconds

public long getInterimTimeInMilliseconds()
Returns the time since starting the measurement and now in milliseconds.

Returns:

getInterimTimeInMilliseconds

public long getInterimTimeInMilliseconds(Object intervalKey)
Returns the time since starting the measurement and now in milliseconds.

Returns:

hasDefaultInterval

protected boolean hasDefaultInterval()
Returns true, if there is an DurationCapture.Interval instance for the intervalDefaultKey.

Returns:

calculateIntervalStatisticLogMessage

public String calculateIntervalStatisticLogMessage()
Returns the collected statistical informations for the intervals durations.

Returns:

getIntervalKeyList

public List<Object> getIntervalKeyList()
Returns all available DurationCapture.Interval keys.

Returns:

newInstance

public static DurationCapture newInstance()
Creates a new instance of this class.

See Also:
implementationForDurationClass


Copyright © 2011. All Rights Reserved.