com.ecyrd.speed4j
Class StopWatchFactory

java.lang.Object
  extended by com.ecyrd.speed4j.StopWatchFactory

public class StopWatchFactory
extends Object

Provides a friendly way to get yer StopWatches.

This class is not a singleton, which may surprise you.


Constructor Summary
StopWatchFactory(Log logger)
          Create a StopWatchFactory using the given Log.
 
Method Summary
static StopWatchFactory getDefault()
          Returns the default StopWatchFactory, which contains no Log configuration.
static StopWatchFactory getInstance(Log logger)
          Return new StopWatchFactory which uses the specified Log.
static StopWatchFactory getInstance(String loggerName)
          Returns a StopWatchFactory that has been configured previously.
 StopWatch getStopWatch()
          Return a StopWatch for an empty tag and empty message.
 StopWatch getStopWatch(String tag)
          Returns a StopWatch for the given tag and null message.
 StopWatch getStopWatch(String tag, String message)
          Returns a StopWatch for the given tag and given message.
static void shutdown()
          Shut down all StopWatchFactories.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StopWatchFactory

public StopWatchFactory(Log logger)
Create a StopWatchFactory using the given Log.

Parameters:
logger - The Log to use.
Method Detail

getStopWatch

public StopWatch getStopWatch()
Return a StopWatch for an empty tag and empty message.

Returns:
A configured StopWatch.

getStopWatch

public StopWatch getStopWatch(String tag)
Returns a StopWatch for the given tag and null message.

Parameters:
tag - Tag which identifies this StopWatch.
Returns:
A new StopWatch instance.

getStopWatch

public StopWatch getStopWatch(String tag,
                              String message)
Returns a StopWatch for the given tag and given message.

Parameters:
tag - Tag which identifies this StopWatch.
message - A free-form message.
Returns:
A new StopWatch.

getDefault

public static StopWatchFactory getDefault()
Returns the default StopWatchFactory, which contains no Log configuration.

Returns:
The default StopWatchFactory.

shutdown

public static void shutdown()
Shut down all StopWatchFactories. This method is useful to call to clean up any resources which might be usable.


getInstance

public static StopWatchFactory getInstance(Log logger)
Return new StopWatchFactory which uses the specified Log. You are fully responsible for this StopWatchFactory for now, i.e. shutdown() does not use this.

Parameters:
logger -
Returns:

getInstance

public static StopWatchFactory getInstance(String loggerName)
                                    throws ConfigurationException
Returns a StopWatchFactory that has been configured previously. May return null, if the factory has not been configured.

Parameters:
loggerName - name to search for.
Returns:
A factory, or null, if not found.
Throws:
ConfigurationException


Copyright © 2011. All Rights Reserved.