Class Diagnostic

java.lang.Object
ca.spatial.util.Diagnostic

public abstract class Diagnostic extends Object
This class is a pure static class that is used to handle error messages. The simulation model will call the methods in this class when information needs to be reported. The messages will be displayed on the console or presented in a popup window, depending on how the options are set.

There are six levels of increasing message severity: DEBUG, INFORMATION, STATUS, WARNING, ERROR and FATAL. The application programs will indicate the severity of the message. The setSeverity(int) method will establish the threshold that below which messages will be ignored. Messages that are displayed are written to the console, and optionally displayed in a popup window. The default value of the severity indicator is INFORMATION. To change the use a line similer to the following:

   Diagnostic.setSeverity(Diagnostic.WARNING);
 

The setGuiMode(int) method will control if a popup window will display the message. Any messages below the severity of this setting will not display in a popup. The default value of the setGuiMode setting is WARNING.

Some messages are repetitive, and these can be ignored using the options in the popup window. Batch mode programs can also ignore repetitive messages by setting the setOnceOnly(boolean) flag. This will cause repetitive messages that are not being displayed in a popup window to not display more than the first instance of the message. A useful batch mode setting would be:

   Diagnostic.setGuiMode(Diagnostic.ERROR);
   Diagnostic.setOnceOnly(true);
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
     
    static int
     
    static int
     
    static int
     
    static int
     
    static int
     
    static int
     
    static int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    debug​(int level, String message)
    Display a debug message using the default format
    static String
    This routine will encode a string using HTML-safe characters.
    static void
    error​(String message)
    Display an error message using the default format
    static void
    error​(String message, Throwable th)
     
    static void
    fatal​(String message)
    Display a fatal message using the default format and exit
    static void
    fatal​(String message, Throwable th)
     
    static String
     
    static int
    Get the debug verbosity level.
    static int
    Get the current value of the GUI display mode.
    static boolean
    getOnceOnly​(int level)
    Determine if OnceOnly display mode will be used for a given message severity level.
    static int
    Get the current message suppression level.
    static void
    information​(String message)
    Display an information message using the default format
    static boolean
    Are debugging messages requested?
    static int
    message​(int sLevel, String message, Object[] options)
    Display a message using the specified severity level, and also provide a list of option buttons.
    static int
    message​(int sLevel, String message, Throwable th, Object[] options)
    Display a message using the specified severity level, and also provide a list of option buttons.
    static void
    setDebugLevel​(int level)
    Control the amount of debugging information to be display.
    static void
    setGuiMode​(int level)
    Set the level at which messages will be displayed using the GUI popup dialog.
    static void
    setOnceOnly​(boolean mode)
    Set a flag that indicates that repetative messages should only be displayed once.
    static void
    setSeverity​(int level)
    Set the level at which messages will be displayed or ignored.
    static void
    status​(String message)
    Display an information message using the default format
    static void
    warning​(String message)
    Display a warning message using the default format
    static void
    warning​(String message, Throwable th)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Diagnostic

      public Diagnostic()
  • Method Details

    • setGuiMode

      public static void setGuiMode(int level)
      Set the level at which messages will be displayed using the GUI popup dialog. The choices are (in order of increasing severity) DEBUG, INFORMATION, WARNING, ERROR and FATAL. A popup window will be used to display all message that are at the same or higher level of severity of the setting that is used.

      For example, setting the vallue of

      Diagnostic.setSeverity(Diagnostic.ERROR);
      will prevent warning messages from popping up and blocking the model progress. To reset the behaviour to the initial default use
      Diagnostic.setSeverity(Diagnostic.WARNING);
    • getGuiMode

      public static int getGuiMode()
      Get the current value of the GUI display mode.
    • setSeverity

      public static void setSeverity(int level)
      Set the level at which messages will be displayed or ignored. The choices are (in order of increasing severity) DEBUG, INFORMATION, WARNING, ERROR and FATAL. Any messages that are of less severity than the provided value will be suppressed. These messages will be printed on the console. In addition, messages can also be displayed in a popup window, and will pause the model. Popup messages are controlled using the setGuiMode(int) method.
    • getSeverity

      public static int getSeverity()
      Get the current message suppression level.
    • setDebugLevel

      public static void setDebugLevel(int level)
      Control the amount of debugging information to be display. If messages of DEBUG severity are displayed, then this method will control the amount of debug data that is emitted. This is generally only useful for program debugging.
    • getDebugLevel

      public static int getDebugLevel()
      Get the debug verbosity level.
    • isDebug

      public static boolean isDebug()
      Are debugging messages requested?
    • setOnceOnly

      public static void setOnceOnly(boolean mode)
      Set a flag that indicates that repetative messages should only be displayed once. If the message is of a lower severity than the gui display level, and the OnceOnly flag is set, then the message will not be repeated. This is useful for batch mode operation to squelch the display of hundreds of lines of similar output, while not totally limiting warning messages.
    • getOnceOnly

      public static boolean getOnceOnly(int level)
      Determine if OnceOnly display mode will be used for a given message severity level.
    • fatal

      public static void fatal(String message)
      Display a fatal message using the default format and exit
    • fatal

      public static void fatal(String message, Throwable th)
    • error

      public static void error(String message)
      Display an error message using the default format
    • error

      public static void error(String message, Throwable th)
    • warning

      public static void warning(String message)
      Display a warning message using the default format
    • warning

      public static void warning(String message, Throwable th)
    • status

      public static void status(String message)
      Display an information message using the default format
    • information

      public static void information(String message)
      Display an information message using the default format
    • debug

      public static void debug(int level, String message)
      Display a debug message using the default format
    • message

      public static int message(int sLevel, String message, Object[] options)
      Display a message using the specified severity level, and also provide a list of option buttons. The value returned from this function will indicate the button that was selected.
    • message

      public static int message(int sLevel, String message, Throwable th, Object[] options)
      Display a message using the specified severity level, and also provide a list of option buttons. The value returned from this function will indicate the button that was selected.
    • encodeHTMLString

      public static String encodeHTMLString(String text)
      This routine will encode a string using HTML-safe characters. Angle brackets (< and >) will change to &lt; and &gt; and quotes and line breaks are also handled.
    • getAllCauses

      public static String getAllCauses(Throwable th)