Class Trace


  • public final class Trace
    extends java.lang.Object
    This auto registering class is used to define trace areas and issue messages. The implementer defines an instances of the jfTrace class in the file scope to ensure all trace areas are available before run-time. These instances then are registered with the jfTraceHandler during its construction
      
      example:
     
                    Trace oDataTrace = new Trace("data", ResId.DataTraceHelp);
                    Trace oStringTrace new Trace("string" ResId.StringTraceHelp);
                    main(...)
                    {
                            TraceHandler oTraceHandler = new TraceHandler();
     
                            TraceHandler.registerTraceHandler(oTraceHandler);
     
                            // two ways to activate 
                            oTraceHandler.activate("data", 2);
                            oStringTrace.activate(3);
     
                            ...
                            oTraceHandler.trace(oDataTrace, 2, 27, "data msg"); // issue message
                            ...
                            oDataTrace.trace(2, 33, "string msg"); // issue message
                            ...
                    }
     
      
     
    • Constructor Summary

      Constructors 
      Constructor Description
      Trace​(java.lang.String sName, int nHelpId)
      Constructor Registers the trace with a global storage area.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activate​(int nLevel)
      Activates this trace section for the current thread
      void deactivate()
      Deactivates this trace section for the current thread
      int getHelpId()  
      java.lang.String getName()
      Returns the name of this trace section
      boolean isEnabled​(int nLevel)
      Check if this trace section is enabled on the current thread.
      static boolean isEnabled​(java.lang.String sName, int nLevel)
      Check if this trace section is enabled on the current thread
      void trace​(int nLevel, int nId, java.lang.String sMsg)
      Issues a trace message.
      void trace​(int nLevel, MsgFormatPos oMsg)
      Issues a trace message.
      static void trace​(java.lang.String sName, int nLevel, int nId, java.lang.String sMsg)
      Issues a trace message on the current thread.
      static void trace​(java.lang.String sName, int nLevel, MsgFormatPos oMsg)
      Issues a trace message.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Trace

        public Trace​(java.lang.String sName,
                     int nHelpId)
        Constructor Registers the trace with a global storage area.
        Parameters:
        sName - the name of the trace section for which the message will be issued
        nHelpId - the message Id associated with a one-line help message for this trace section.
    • Method Detail

      • isEnabled

        public static boolean isEnabled​(java.lang.String sName,
                                        int nLevel)
        Check if this trace section is enabled on the current thread
        Parameters:
        sName - - the name of the trace section for which the message will be issued
        nLevel - - the detail level of the messages allowed,
        Returns:
        true if this trace section is enabled on the current thread, else false
      • trace

        public static void trace​(java.lang.String sName,
                                 int nLevel,
                                 int nId,
                                 java.lang.String sMsg)
        Issues a trace message on the current thread.
        Parameters:
        sName - the name of the trace section for which the message will be issued
        nLevel - the detail level of the message, 1 for high level information, 3 for detailed information.
        nId - the message Id.
        sMsg - the message text.
      • trace

        public static void trace​(java.lang.String sName,
                                 int nLevel,
                                 MsgFormatPos oMsg)
        Issues a trace message.
        Parameters:
        sName - the name of the trace section for which the message will be issued
        nLevel - the detail level of the message, 1 for high level information, 3 for detailed information.
        oMsg - the message for the trace.
      • activate

        public void activate​(int nLevel)
        Activates this trace section for the current thread
        Parameters:
        nLevel - the detail level of the messages allowed, 1 for high level information, 3 for detailed information.
      • deactivate

        public void deactivate()
        Deactivates this trace section for the current thread
      • getHelpId

        public int getHelpId()
      • getName

        public java.lang.String getName()
        Returns the name of this trace section
        Returns:
        the name of this trace section
      • isEnabled

        public boolean isEnabled​(int nLevel)
        Check if this trace section is enabled on the current thread.
        Parameters:
        nLevel - the detail level of the messages allowed,
        Returns:
        true if this trace section is enabled on the current thread, else false
      • trace

        public void trace​(int nLevel,
                          int nId,
                          java.lang.String sMsg)
        Issues a trace message.
        Parameters:
        nLevel - the detail level of the message, 1 for high level information, 3 for detailed information.
        nId - the message Id.
        sMsg - the message text.
      • trace

        public void trace​(int nLevel,
                          MsgFormatPos oMsg)
        Issues a trace message.
        Parameters:
        nLevel - the detail level of the message, 1 for high level information, 3 for detailed information.
        oMsg - the message for the trace.