Oracle Fusion Middleware Java API Reference for Oracle Data Visualization Components
11g Release 2 (11.1.2.0.0)

E17492-01

oracle.dss.util
Class Timer

java.lang.Object
  extended by oracle.dss.util.Timer
All Implemented Interfaces:
ErrorHandlerCallback

public class Timer
extends java.lang.Object
implements ErrorHandlerCallback

For internal use only. Application developers should not use this
 Support for basic timer profiling.
This is very similar to XPTIMER in X4WTOOLS. It allows the user to create timers which measure interval and total time. The timers can be started, restarted, stopped and checked at various intervals. Options are also provided to control the debug output.
Available Options: OPTION_DATE: Show date stamp OPTION_TIME: Show time stamp OPTION_INTERVAL: Show interval time (in milliseconds) OPTION_TOTAL: Show total time (in milliseconds) OPTION_NAME: Show timer name OPTION_ALL: Turn on all options OPTION_DATE: Show date stamp options OPTION_DEFAULT: Show default options (interval, total, name) It is also possible to set the indent level to make output easier to read.

Field Summary
static int INDENT_SPACES
           
static int OPTION_ALL
          Show all options.
static int OPTION_DATE
          Show date stamp.
static int OPTION_DATE_TIME
          Show date stamp options.
static int OPTION_DEFAULT
          Show default options.
static int OPTION_INTERVAL
          Show interval time (in milliseconds).
static int OPTION_NAME
          Show timer name.
static int OPTION_TIME
          Show time stamp.
static int OPTION_TOTAL
          Show total time (in milliseconds).
static java.lang.String TIMER_NOT_STARTED
           
 
Constructor Summary
Timer()
           Default constructor for Timer class.
Example: Timer timer = new Timer ();
Timer(java.lang.String strName)
           Constructor for Timer class.
Example: Timer timer = new Timer ("My Timer!");
Timer(java.lang.String strName, long lOptions)
           Constructor for Timer class.
Example: Timer timer = new Timer ("My Timer!", OPTION_DEFAULT);
 
Method Summary
 void addErrorHandler(ErrorHandler errorHandler)
          Adds an ErrorHandler object to this DefaultBuilderContext object.
 java.lang.String formatDateTime(java.util.Date date, int nStyle, java.util.Locale locale)
           Formats the time/date based on timer formatting options.
Example: formatTimeDate (date);
protected  boolean formatOutput(java.lang.String strState, long lInterval, java.lang.String strDescription, java.util.Date date)
           Formats timer output string.
Example: formatOutput ("This is my starting timer!");
 ErrorHandler getErrorHandler()
          Retrieves an error handler.
 int getIndentLevel()
           Retrieves the output indent level.
Example: int nIndentLevel = getIndentLevel();
 int getIndentSpaces()
           Retrieves the number of spaces per indent.
Example: int nIndentSpaces = getIndentSpaces();
 java.util.Date getLastDate()
           Retrieves the last timer date.
Example: Date date = getLastDate();
 java.lang.String getName()
           Retrieves the timer name.
Example: String strName = getName();
 long getOptions()
           Retrieves the formatting options bitmask.
Example: long lOptions = getOptions();
 java.io.PrintWriter getPrintWriter()
           Retrieves the PrintWriter used to output timer results.
Example: PrintWriter printWriter = getPrintWriter();
 long getTotal()
           Retrieves the total time in milleseconds since the timer was started.
Example: long lTotal = getTotal();
 boolean interval(java.lang.String strDescription)
           Determines timer interval since the last timer event.
Example: interval ("My timer!");
 boolean isEnabled()
           Specifies whether timer is enabled.
Example: boolean bIsEnabled = isEnabled();
 boolean isStarted()
           Determines if timer has been started.
Example: boolean bStarted = isStarted();
static void main(java.lang.String[] argv)
           Timer testing code.
 void removeErrorHandler()
          Overrides a previously set ErrorHandler object in this DefaultBuilderContext object with a default one.
 boolean restart(java.lang.String strDescription)
           Restarts a stopped timer and retains the total time.
Example: restart ("My timer!");
 void setEnabled(boolean bEnabled)
           Retrieves whether timer is enabled.
Example: setEnabled (true);
 void setIndentLevel(int nIndentLevel)
           Specifies the output indent level.
Example: setIndentLevel (3);
 void setIndentSpaces(int nIndentSpaces)
           Specifies the number of spaces per indent.
Example: setIndentSpaces (5);
protected  void setLastDate(java.util.Date date)
           Specifies the last timer date.
Example: setLastDate (date);
 void setName(java.lang.String strName)
           Specifies the timer name.
Example: setName (strName);
 void setOptions(long lOptions)
           Specifies the output formatting options bitmask.
Example: setOptions (OPTION_TIME_STAMP);
 void setPrintWriter(java.io.PrintWriter printWriter)
           Specifies the PrintWriter used to output timer results.
Defaults to System.out
Example: setPrintWriter (printWriter);
protected  void setStarted(boolean bStarted)
           Determines if timer has been started.
Example: setStarted (true);
protected  void setTotal(long lTime)
           Specifies the total time since timer was started.
Example: setTotal(lTime);
 boolean start(java.lang.String strDescription)
           Starts the timer.
Example: start ("My timer!");
 boolean stop(java.lang.String strDescription)
           Stops the timer and outputs final interval.
Example: stop ("My timer!");
protected  long updateTimer()
           Updates the timer, returning interval.
Example: updateTimer ();
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPTION_DATE

public static final int OPTION_DATE
Show date stamp.

See Also:
Constant Field Values

OPTION_TIME

public static final int OPTION_TIME
Show time stamp.

See Also:
Constant Field Values

OPTION_INTERVAL

public static final int OPTION_INTERVAL
Show interval time (in milliseconds).

See Also:
Constant Field Values

OPTION_TOTAL

public static final int OPTION_TOTAL
Show total time (in milliseconds).

See Also:
Constant Field Values

OPTION_NAME

public static final int OPTION_NAME
Show timer name.

See Also:
Constant Field Values

OPTION_ALL

public static final int OPTION_ALL
Show all options.

See Also:
OPTION_DATE, OPTION_TIME, OPTION_INTERVAL, OPTION_TOTAL, OPTION_NAME, Constant Field Values

OPTION_DATE_TIME

public static final int OPTION_DATE_TIME
Show date stamp options.

See Also:
OPTION_DATE, OPTION_TIME, Constant Field Values

OPTION_DEFAULT

public static final int OPTION_DEFAULT
Show default options.

See Also:
OPTION_INTERVAL, OPTION_TOTAL, OPTION_NAME, Constant Field Values

INDENT_SPACES

public static final int INDENT_SPACES
See Also:
Constant Field Values

TIMER_NOT_STARTED

public static final java.lang.String TIMER_NOT_STARTED
See Also:
Constant Field Values
Constructor Detail

Timer

public Timer()
 Default constructor for Timer class.
Example: Timer timer = new Timer ();


Timer

public Timer(java.lang.String strName)
 Constructor for Timer class.
Example: Timer timer = new Timer ("My Timer!");

Parameters:
strName - A String which represents the timer name.

Timer

public Timer(java.lang.String strName,
             long lOptions)
 Constructor for Timer class.
Example: Timer timer = new Timer ("My Timer!", OPTION_DEFAULT);

Parameters:
strName - A String which represents the timer name.
lOptions - A long which represents the output formatting options bitmask
See Also:
OPTION_DATE, OPTION_TIME, OPTION_INTERVAL, OPTION_TOTAL, OPTION_NAME, OPTION_ALL, OPTION_DATE, OPTION_DEFAULT
Method Detail

main

public static void main(java.lang.String[] argv)
 Timer testing code.
 


getPrintWriter

public java.io.PrintWriter getPrintWriter()
 Retrieves the PrintWriter used to output timer results.
Example: PrintWriter printWriter = getPrintWriter();

Returns:
PrintWriter which determines where to output timer results.

setPrintWriter

public void setPrintWriter(java.io.PrintWriter printWriter)
 Specifies the PrintWriter used to output timer results.
Defaults to System.out
Example: setPrintWriter (printWriter);

Parameters:
printWriter - A PrintWriter which is used to output timer results.

getName

public java.lang.String getName()
 Retrieves the timer name.
Example: String strName = getName();

Returns:
String which represents the timer name.

setName

public void setName(java.lang.String strName)
 Specifies the timer name.
Example: setName (strName);

Parameters:
strName - A String which represents the timer name.

isEnabled

public boolean isEnabled()
 Specifies whether timer is enabled.
Example: boolean bIsEnabled = isEnabled();

Returns:
boolean which is true when the timer is enabled and false otherwise.

setEnabled

public void setEnabled(boolean bEnabled)
 Retrieves whether timer is enabled.
Example: setEnabled (true);

Parameters:
bEnabled - A boolean which is true when the timer is enabled and false otherwise.

getIndentLevel

public int getIndentLevel()
 Retrieves the output indent level.
Example: int nIndentLevel = getIndentLevel();

Returns:
int which represents the output indent level.

setIndentLevel

public void setIndentLevel(int nIndentLevel)
 Specifies the output indent level.
Example: setIndentLevel (3);

Parameters:
nIndent - A int which presents the output indent level.

getIndentSpaces

public int getIndentSpaces()
 Retrieves the number of spaces per indent.
Example: int nIndentSpaces = getIndentSpaces();

Returns:
int which represents the number of spaces per indent.

setIndentSpaces

public void setIndentSpaces(int nIndentSpaces)
 Specifies the number of spaces per indent.
Example: setIndentSpaces (5);

Parameters:
nIndentSpaces - A int which represents the number of spaces per indent.

getOptions

public long getOptions()
 Retrieves the formatting options bitmask.
Example: long lOptions = getOptions();

Returns:
long which represents the output formatting options.
See Also:
OPTION_DATE, OPTION_TIME, OPTION_INTERVAL, OPTION_TOTAL, OPTION_NAME, OPTION_ALL, OPTION_DATE, OPTION_DEFAULT

setOptions

public void setOptions(long lOptions)
 Specifies the output formatting options bitmask.
Example: setOptions (OPTION_TIME_STAMP);

Parameters:
lOptions - A long which represents the output format options bitmask.
See Also:
OPTION_DATE, OPTION_TIME, OPTION_INTERVAL, OPTION_TOTAL, OPTION_NAME, OPTION_ALL, OPTION_DATE, OPTION_DEFAULT

getLastDate

public java.util.Date getLastDate()
 Retrieves the last timer date.
Example: Date date = getLastDate();

Returns:
Date representing the last timer date.

getTotal

public long getTotal()
 Retrieves the total time in milleseconds since the timer was started.
Example: long lTotal = getTotal();

Returns:
long which represents the number of milliseconds since the timer was started.

isStarted

public boolean isStarted()
 Determines if timer has been started.
Example: boolean bStarted = isStarted();

Returns:
boolean which is true if the timer has been started and false otherwise.

start

public boolean start(java.lang.String strDescription)
 Starts the timer.
Example: start ("My timer!");

Parameters:
strDescription - A String which represents the description to associate with the timer.
Returns:
boolean which is true if successful and false otherwise.

interval

public boolean interval(java.lang.String strDescription)
 Determines timer interval since the last timer event.
Example: interval ("My timer!");

Parameters:
strDescription - A String which presents the description to associate with this event.
Returns:
boolean which is true if successful and false otherwise.

stop

public boolean stop(java.lang.String strDescription)
 Stops the timer and outputs final interval.
Example: stop ("My timer!");

Parameters:
strDescription - A String which presents the description to associate with this event.
Returns:
boolean which is true if successful and false otherwise.

restart

public boolean restart(java.lang.String strDescription)
 Restarts a stopped timer and retains the total time.
Example: restart ("My timer!");

Parameters:
strDescription - A String which presents the description to associate with this event.
Returns:
boolean which is true if successful and false otherwise.
Throws:
Exception - if timer has not been started.

formatDateTime

public java.lang.String formatDateTime(java.util.Date date,
                                       int nStyle,
                                       java.util.Locale locale)
 Formats the time/date based on timer formatting options.
Example: formatTimeDate (date);

Parameters:
date - A Date to format.
nStyle - A int which represents the Date style.
locale - A Locale which represents the Date locale.
Returns:
String which represents the formatted date string.
See Also:
DateFormat

addErrorHandler

public void addErrorHandler(ErrorHandler errorHandler)
Adds an ErrorHandler object to this DefaultBuilderContext object. The ErrorHandler object will be called when the visual component traps an error from other parts of the system.

Specified by:
addErrorHandler in interface ErrorHandlerCallback
Parameters:
errorHandler - The ErrorHandler object.

removeErrorHandler

public void removeErrorHandler()
Overrides a previously set ErrorHandler object in this DefaultBuilderContext object with a default one.

Specified by:
removeErrorHandler in interface ErrorHandlerCallback

getErrorHandler

public ErrorHandler getErrorHandler()
Retrieves an error handler.

Returns:
ErrorHandler representing the error handler.

formatOutput

protected boolean formatOutput(java.lang.String strState,
                               long lInterval,
                               java.lang.String strDescription,
                               java.util.Date date)
 Formats timer output string.
Example: formatOutput ("This is my starting timer!");

Parameters:
strState - A String which represents the timer state.
lInterval - A long which represents the timer interval.
strDescription - A String which represents the description.
date - A Date which represents the date to display.
Returns:
boolean which is true if successful and false otherwise.

setTotal

protected void setTotal(long lTime)
 Specifies the total time since timer was started.
Example: setTotal(lTime);

Parameters:
lTime - A long which represents the total time since timer was started.

setStarted

protected void setStarted(boolean bStarted)
 Determines if timer has been started.
Example: setStarted (true);

Parameters:
bStarted - A boolean which is true if the timer has been started and false otherwise.

setLastDate

protected void setLastDate(java.util.Date date)
 Specifies the last timer date.
Example: setLastDate (date);

Parameters:
date - A Date which represents the last date.

updateTimer

protected long updateTimer()
 Updates the timer, returning interval.
Example: updateTimer ();

Returns:
long which represents the timer interval.
Throws:
Exception - if timer has not been started.

Oracle Fusion Middleware Java API Reference for Oracle Data Visualization Components
11g Release 2 (11.1.2.0.0)

E17492-01

Copyright © 1997, 2011, Oracle. All rights reserved.