Class MessageLogger


  • public class MessageLogger
    extends java.lang.Object
    A cache of debug-, info-, warning-, or error-level messages that are generated by a process such as the validation of an OpenEHR model load and configuration.
    • Constructor Summary

      Constructors 
      Constructor Description
      MessageLogger()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(MessageDescriptor errorDescriptor)
      Generic add method for adding a message of type debug, info, warning, or error to the cache.
      void addDebug​(java.lang.String message)  
      void addDebugWithLocation​(java.lang.String aLocation, java.lang.String aMessage)
      Adds a debug message to cache.
      void addError​(MessageCode code, java.lang.Object... args)  
      void addErrorWithLocation​(MessageCode aCode, java.lang.String aLocation, java.lang.Object... args)
      Adds an error to this error cache and sets the error flag to true.
      void addInfo​(MessageCode code, java.lang.Object... args)  
      void addInfoWithLocation​(MessageCode aCode, java.lang.String aLocation, java.lang.Object... args)
      Adds a warning to this error cache and sets the hasInfo flag to true.
      void addWarning​(MessageCode code, java.lang.Object... args)  
      void addWarningWithLocation​(MessageCode aCode, java.lang.String aLocation, java.lang.Object... args)
      Adds a warning to this error cache and sets the hasWarning flag to true.
      void append​(MessageLogger other)
      Adds all items in the error cache of other onto this error cache.
      void clear()
      Clears the error message cache and resets all flags to false.
      java.util.List<MessageCode> getErrorCodes()
      Returns all messages of type ERROR_TYPE_ERROR.
      java.util.List<MessageCode> getInfoCodes()
      Returns all messages of type ERROR_TYPE_INFO
      java.util.List<MessageDescriptor> getMessageList()  
      java.util.List<MessageCode> getWarningCodes()
      Returns all messages of type ERROR_TYPE_WARNING
      boolean hasError​(MessageCode aCode)
      True if there has been an error recorded with code `a_code'
      boolean hasErrors()
      Returns true if this error cache has errors
      boolean hasErrorsOrWarnings()
      Returns true if this error cache has either error or warning messages.
      boolean hasInfo()
      Returns true if this error cache has info-level messages.
      boolean hasInfo​(MessageCode aCode)
      True if there has been an error recorded with code `a_code'
      boolean hasMatchingError​(MessageCode aCode)
      True if there has been an error whose code starts with code `a_code'
      boolean hasMatchingWarning​(MessageCode aCode)
      True if there has been a warning whose code starts with code `a_code'
      boolean hasWarning​(MessageCode aCode)
      True if there has been an error recorded with code `a_code'
      boolean hasWarnings()
      Returns true if this error cache has warnings.
      boolean isEmpty()
      Returns true if this error cache is empty.
      MessageDescriptor lastAdded()
      Returns the last message added to the error cache.
      int size()
      Returns the number of messages in this error cache.
      java.lang.String toString()
      Generate stringified version of contents, with newlines inserted after each entry
      java.lang.String toStringFiltered​(boolean includeErrors, boolean includeWarnings, boolean includeInfo)
      Generate filtered stringified version of contents, with newlines inserted after each entry
      • Methods inherited from class java.lang.Object

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

      • MessageLogger

        public MessageLogger()
    • Method Detail

      • lastAdded

        public MessageDescriptor lastAdded()
        Returns the last message added to the error cache.
        Returns:
      • getErrorCodes

        public java.util.List<MessageCode> getErrorCodes()
        Returns all messages of type ERROR_TYPE_ERROR.
        Returns:
      • getWarningCodes

        public java.util.List<MessageCode> getWarningCodes()
        Returns all messages of type ERROR_TYPE_WARNING
        Returns:
      • getInfoCodes

        public java.util.List<MessageCode> getInfoCodes()
        Returns all messages of type ERROR_TYPE_INFO
        Returns:
      • isEmpty

        public boolean isEmpty()
        Returns true if this error cache is empty.
        Returns:
      • hasErrors

        public boolean hasErrors()
        Returns true if this error cache has errors
        Returns:
      • hasWarnings

        public boolean hasWarnings()
        Returns true if this error cache has warnings.
        Returns:
      • hasInfo

        public boolean hasInfo()
        Returns true if this error cache has info-level messages.
        Returns:
      • hasErrorsOrWarnings

        public boolean hasErrorsOrWarnings()
        Returns true if this error cache has either error or warning messages.
        Returns:
      • hasError

        public boolean hasError​(MessageCode aCode)
        True if there has been an error recorded with code `a_code'
        Parameters:
        aCode -
        Returns:
      • hasWarning

        public boolean hasWarning​(MessageCode aCode)
        True if there has been an error recorded with code `a_code'
        Parameters:
        aCode -
        Returns:
      • hasInfo

        public boolean hasInfo​(MessageCode aCode)
        True if there has been an error recorded with code `a_code'
        Parameters:
        aCode -
        Returns:
      • hasMatchingError

        public boolean hasMatchingError​(MessageCode aCode)
        True if there has been an error whose code starts with code `a_code'
        Parameters:
        aCode -
        Returns:
      • hasMatchingWarning

        public boolean hasMatchingWarning​(MessageCode aCode)
        True if there has been a warning whose code starts with code `a_code'
        Parameters:
        aCode -
        Returns:
      • addError

        public void addError​(MessageCode code,
                             java.lang.Object... args)
      • addWarning

        public void addWarning​(MessageCode code,
                               java.lang.Object... args)
      • addInfo

        public void addInfo​(MessageCode code,
                            java.lang.Object... args)
      • addDebug

        public void addDebug​(java.lang.String message)
      • addErrorWithLocation

        public void addErrorWithLocation​(MessageCode aCode,
                                         java.lang.String aLocation,
                                         java.lang.Object... args)
        Adds an error to this error cache and sets the error flag to true.
        Parameters:
        aCode -
        aLocation -
        args -
      • addWarningWithLocation

        public void addWarningWithLocation​(MessageCode aCode,
                                           java.lang.String aLocation,
                                           java.lang.Object... args)
        Adds a warning to this error cache and sets the hasWarning flag to true.
        Parameters:
        aCode -
        aLocation -
        args -
      • addInfoWithLocation

        public void addInfoWithLocation​(MessageCode aCode,
                                        java.lang.String aLocation,
                                        java.lang.Object... args)
        Adds a warning to this error cache and sets the hasInfo flag to true.
        Parameters:
        aCode -
        aLocation -
        args -
      • addDebugWithLocation

        public void addDebugWithLocation​(java.lang.String aLocation,
                                         java.lang.String aMessage)
        Adds a debug message to cache.
        Parameters:
        aLocation -
        aMessage -
      • add

        public void add​(MessageDescriptor errorDescriptor)
        Generic add method for adding a message of type debug, info, warning, or error to the cache.
        Parameters:
        errorDescriptor -
      • append

        public void append​(MessageLogger other)
        Adds all items in the error cache of other onto this error cache.
        Parameters:
        other -
      • clear

        public void clear()
        Clears the error message cache and resets all flags to false.
      • toString

        public java.lang.String toString()
        Generate stringified version of contents, with newlines inserted after each entry
        Overrides:
        toString in class java.lang.Object
        Returns:
      • toStringFiltered

        public java.lang.String toStringFiltered​(boolean includeErrors,
                                                 boolean includeWarnings,
                                                 boolean includeInfo)
        Generate filtered stringified version of contents, with newlines inserted after each entry
        Parameters:
        includeErrors -
        includeWarnings -
        includeInfo -
        Returns:
      • size

        public int size()
        Returns the number of messages in this error cache.
        Returns: