Package org.openehr.utils.message
Class MessageLogger
- java.lang.Object
-
- org.openehr.utils.message.MessageLogger
-
public class MessageLogger extends java.lang.ObjectA 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 voidadd(MessageDescriptor errorDescriptor)Generic add method for adding a message of type debug, info, warning, or error to the cache.voidaddDebug(java.lang.String message)voidaddDebugWithLocation(java.lang.String aLocation, java.lang.String aMessage)Adds a debug message to cache.voidaddError(MessageCode code, java.lang.Object... args)voidaddErrorWithLocation(MessageCode aCode, java.lang.String aLocation, java.lang.Object... args)Adds an error to this error cache and sets the error flag to true.voidaddInfo(MessageCode code, java.lang.Object... args)voidaddInfoWithLocation(MessageCode aCode, java.lang.String aLocation, java.lang.Object... args)Adds a warning to this error cache and sets the hasInfo flag to true.voidaddWarning(MessageCode code, java.lang.Object... args)voidaddWarningWithLocation(MessageCode aCode, java.lang.String aLocation, java.lang.Object... args)Adds a warning to this error cache and sets the hasWarning flag to true.voidappend(MessageLogger other)Adds all items in the error cache of other onto this error cache.voidclear()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_INFOjava.util.List<MessageDescriptor>getMessageList()java.util.List<MessageCode>getWarningCodes()Returns all messages of type ERROR_TYPE_WARNINGbooleanhasError(MessageCode aCode)True if there has been an error recorded with code `a_code'booleanhasErrors()Returns true if this error cache has errorsbooleanhasErrorsOrWarnings()Returns true if this error cache has either error or warning messages.booleanhasInfo()Returns true if this error cache has info-level messages.booleanhasInfo(MessageCode aCode)True if there has been an error recorded with code `a_code'booleanhasMatchingError(MessageCode aCode)True if there has been an error whose code starts with code `a_code'booleanhasMatchingWarning(MessageCode aCode)True if there has been a warning whose code starts with code `a_code'booleanhasWarning(MessageCode aCode)True if there has been an error recorded with code `a_code'booleanhasWarnings()Returns true if this error cache has warnings.booleanisEmpty()Returns true if this error cache is empty.MessageDescriptorlastAdded()Returns the last message added to the error cache.intsize()Returns the number of messages in this error cache.java.lang.StringtoString()Generate stringified version of contents, with newlines inserted after each entryjava.lang.StringtoStringFiltered(boolean includeErrors, boolean includeWarnings, boolean includeInfo)Generate filtered stringified version of contents, with newlines inserted after each entry
-
-
-
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.
-
getMessageList
public java.util.List<MessageDescriptor> getMessageList()
-
toString
public java.lang.String toString()
Generate stringified version of contents, with newlines inserted after each entry- Overrides:
toStringin classjava.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:
-
-