Package adams.core
Class SimpleTimer
- java.lang.Object
-
- adams.core.SimpleTimer
-
public class SimpleTimer extends Object
Simple class for generating timings.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected static SimpleTimer
m_Singleton
the singleton.protected Long
m_Start
the start time in milliseconds.static String
PH_MSECS
the placeholder for milliseconds.static String
PH_MSECS_UNIT
the placeholder for milliseconds (with msec unit).static String
PH_SECS
the placeholder for seconds.static String
PH_SECS_UNIT
the placeholder for seconds (with sec unit).
-
Constructor Summary
Constructors Constructor Description SimpleTimer()
Initializes the timer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
expand(Class cls, String template)
Expands the placeholders in the template and returns the generated string.String
expand(Object obj, String template)
Expands the placeholders in the template and returns the generated string.String
expand(String template)
Expands the placeholders in the template and returns the generated string.static SimpleTimer
getSingleton()
Returns the global singleton.void
println(Class cls, String template)
Expands the placeholders in the template and outputs the generated string on stdout.void
println(Object obj, String template)
Expands the placeholders in the template and outputs the generated string on stdout.void
println(String template)
Expands the placeholders in the template and outputs the generated string on stdout.void
reset()
Resets the start time.
-
-
-
Field Detail
-
PH_MSECS
public static final String PH_MSECS
the placeholder for milliseconds.- See Also:
- Constant Field Values
-
PH_MSECS_UNIT
public static final String PH_MSECS_UNIT
the placeholder for milliseconds (with msec unit).- See Also:
- Constant Field Values
-
PH_SECS
public static final String PH_SECS
the placeholder for seconds.- See Also:
- Constant Field Values
-
PH_SECS_UNIT
public static final String PH_SECS_UNIT
the placeholder for seconds (with sec unit).- See Also:
- Constant Field Values
-
m_Start
protected Long m_Start
the start time in milliseconds.
-
m_Singleton
protected static SimpleTimer m_Singleton
the singleton.
-
-
Method Detail
-
reset
public void reset()
Resets the start time.
-
expand
public String expand(Object obj, String template)
Expands the placeholders in the template and returns the generated string.- Parameters:
obj
- the object's class to prefix the template withtemplate
- the template string- Returns:
- the expanded string
-
expand
public String expand(Class cls, String template)
Expands the placeholders in the template and returns the generated string.- Parameters:
cls
- the class to prefix the template withtemplate
- the template string- Returns:
- the expanded string
-
expand
public String expand(String template)
Expands the placeholders in the template and returns the generated string.- Parameters:
template
- the template string- Returns:
- the expanded string
-
println
public void println(Object obj, String template)
Expands the placeholders in the template and outputs the generated string on stdout.- Parameters:
obj
- the object's class to prefix the template withtemplate
- the template string
-
println
public void println(Class cls, String template)
Expands the placeholders in the template and outputs the generated string on stdout.- Parameters:
cls
- the class to prefix the template withtemplate
- the template string
-
println
public void println(String template)
Expands the placeholders in the template and outputs the generated string on stdout.- Parameters:
template
- the template string
-
getSingleton
public static SimpleTimer getSingleton()
Returns the global singleton.- Returns:
- the singleton
-
-