Class MessageLog

  • Direct Known Subclasses:
    XmlMessageLog

    public class MessageLog
    extends java.lang.Object
    A simple class to handle logging messages and exceptions. A maximum message count size constraint can be set to clip messages after a certain number, but still keep incrementing a running total.

    In addition to logging messages, clients can also set a status message. This message may later used as the primary error message when reporting to the user.

    • Constructor Summary

      Constructors 
      Constructor Description
      MessageLog()  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void appendException​(java.lang.Throwable t)
      Appends the exception to the log
      void appendMsg​(int lineNum, java.lang.String message)
      Appends the message and line number to the log
      void appendMsg​(java.lang.String message)
      Appends the message to the log
      void appendMsg​(java.lang.String originator, java.lang.String message)
      Appends the message to the log
      void clear()
      Clears all messages from this log and resets the count
      void clearStatus()
      Clear status message
      void copyFrom​(MessageLog log)
      Copies the contents of one message log into this one
      void error​(java.lang.String originator, java.lang.String message)
      Deprecated.
      java.lang.String getStatus()
      Returns a stored status message
      boolean hasMessages()
      Returns true if this log has messages
      void setStatus​(java.lang.String status)
      Stores a status message that can be used elsewhere (i.e., populate warning dialogs)
      java.lang.String toString()  
      void write​(java.lang.Class<?> owner, java.lang.String messageHeader)
      Writes this log's contents to the application log
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • MessageLog

        public MessageLog()
    • Method Detail

      • copyFrom

        public void copyFrom​(MessageLog log)
        Copies the contents of one message log into this one
        Parameters:
        log - the log to copy from
      • appendMsg

        public void appendMsg​(java.lang.String message)
        Appends the message to the log
        Parameters:
        message - the message
      • appendMsg

        public void appendMsg​(java.lang.String originator,
                              java.lang.String message)
        Appends the message to the log
        Parameters:
        originator - the originator of the message
        message - the message
      • appendMsg

        public void appendMsg​(int lineNum,
                              java.lang.String message)
        Appends the message and line number to the log
        Parameters:
        lineNum - the line number that generated the message
        message - the message
      • appendException

        public void appendException​(java.lang.Throwable t)
        Appends the exception to the log
        Parameters:
        t - the exception to append to the log
      • error

        @Deprecated
        public void error​(java.lang.String originator,
                          java.lang.String message)
        Deprecated.
        Readable method for appending error messages to the log.

        Currently does nothing different than appendMsg(String, String).

        Parameters:
        originator - the originator of the message
        message - the message
      • hasMessages

        public boolean hasMessages()
        Returns true if this log has messages
        Returns:
        true if this log has messages
      • clear

        public void clear()
        Clears all messages from this log and resets the count
      • setStatus

        public void setStatus​(java.lang.String status)
        Stores a status message that can be used elsewhere (i.e., populate warning dialogs)
        Parameters:
        status - the status message
      • clearStatus

        public void clearStatus()
        Clear status message
      • getStatus

        public java.lang.String getStatus()
        Returns a stored status message
        Returns:
        stored status message
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • write

        public void write​(java.lang.Class<?> owner,
                          java.lang.String messageHeader)
        Writes this log's contents to the application log
        Parameters:
        owner - the owning class whose name will appear in the log message
        messageHeader - the message header that will appear before the log messages