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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_COUNT
      The default number of messages to store before clipping.
    • Constructor Summary

      Constructors 
      Constructor Description
      MessageLog()
      Constructs a new message log using the default message count.
      MessageLog​(int maxSize)
      Constructs a new message log using the sepcified message count.
    • Method Summary

      All Methods Instance Methods Concrete 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 msg)
      Appends the message and line number to the log.
      void appendMsg​(java.lang.String msg)
      Appends the message to the log.
      void appendMsg​(java.lang.String originator, java.lang.String msg)  
      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)
      Readable method for appending error messages to the log.
      int getMsgCount()
      Returns the message count.
      java.lang.String getStatus()
      Returns a stored status message
      void setStatus​(java.lang.String status)
      Stores a status message that can be used elsewhere (i.e., populate warning dialogs)
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • MAX_COUNT

        public static final int MAX_COUNT
        The default number of messages to store before clipping.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MessageLog

        public MessageLog()
        Constructs a new message log using the default message count.
      • MessageLog

        public MessageLog​(int maxSize)
        Constructs a new message log using the sepcified message count.
        Parameters:
        maxSize - the maximum number of messages
    • 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 msg)
        Appends the message to the log.
        Parameters:
        msg - the message
      • appendMsg

        public void appendMsg​(java.lang.String originator,
                              java.lang.String msg)
      • appendMsg

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

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

        public int getMsgCount()
        Returns the message count.
        Returns:
        the message count
      • 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 -
      • 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
        See Also:
        Object.toString()
      • error

        public void error​(java.lang.String originator,
                          java.lang.String message)
        Readable method for appending error messages to the log. Currently does nothing different that appendMsg(String, String)
        Parameters:
        originator -
        message -