|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.kuali.rice.krad.util.MessageMap
public class MessageMap
Holds errors due to validation
Keys of map represent property paths, and value is a AutoPopulatingList that contains resource string keys (to retrieve the error message).
Note, prior to rice 0.9.4, this class implemented Map
. The implements has been removed as of
rice 0.9.4
Constructor Summary | |
---|---|
MessageMap()
|
|
MessageMap(MessageMap messageMap)
|
Method Summary | |
---|---|
void |
addGrowlMessage(GrowlMessage growl)
Add a growl to the message map |
void |
addGrowlMessage(String growlTitle,
String messageKey,
String... messageParameters)
Adds a growl (using the default theme) to the message map with the given title and message |
void |
addToErrorPath(String parentName)
Adds a string prefix to the error path. |
void |
clearErrorMessages()
|
void |
clearErrorPath()
Clears the errorPath. |
boolean |
containsKeyMatchingPattern(String pattern)
|
boolean |
containsMessageKey(String messageKey)
|
int |
countFieldMessages(String fieldName)
Returns the number of messages for the given field |
boolean |
doesPropertyHaveError(String key)
|
boolean |
equals(Object o)
|
boolean |
fieldHasMessage(String fieldName,
String errorKey)
Returns true if the named field has a message with the given errorKey |
Set<Map.Entry<String,List<ErrorMessage>>> |
getAllPropertiesAndErrors()
|
Set<String> |
getAllPropertiesWithErrors()
|
Set<String> |
getAllPropertiesWithInfo()
|
Set<String> |
getAllPropertiesWithWarnings()
|
int |
getErrorCount()
Counts the total number of error messages in the map |
Map<String,List<ErrorMessage>> |
getErrorMessages()
|
List<ErrorMessage> |
getErrorMessagesForProperty(String propertyName)
|
List<List<ErrorMessage>> |
getErrorMessagesForProperty(String propertyName,
boolean allowWildcard)
Gets a list of lists that represent errors that matched by the propertyName passed in (multiple lists because the wildcard can match multiple keys). |
List<String> |
getErrorPath()
This method returns the list that holds the error path values. |
List<GrowlMessage> |
getGrowlMessages()
Returns the list of growl messages (@{link GrowlMessage}) that have been added to the message map |
int |
getInfoCount()
Counts the total number of info messages in the map |
Map<String,List<ErrorMessage>> |
getInfoMessages()
|
List<ErrorMessage> |
getInfoMessagesForProperty(String propertyName)
|
List<List<ErrorMessage>> |
getInfoMessagesForProperty(String propertyName,
boolean allowWildcard)
Gets a list of lists that represent info messages that matched by the propertyName passed in (multiple lists because the wildcard can match multiple keys). |
String |
getKeyPath(String propertyName,
boolean prependFullErrorPath)
This is what's prepended to the beginning of the key. |
List<ErrorMessage> |
getMessages(String path)
|
int |
getNumberOfPropertiesWithErrors()
|
List<String> |
getPropertiesWithErrors()
|
List<String> |
getPropertiesWithInfo()
|
List<String> |
getPropertiesWithWarnings()
|
int |
getWarningCount()
Counts the total number of warning messages in the map |
Map<String,List<ErrorMessage>> |
getWarningMessages()
|
List<ErrorMessage> |
getWarningMessagesForProperty(String propertyName)
|
List<List<ErrorMessage>> |
getWarningMessagesForProperty(String propertyName,
boolean allowWildcard)
Gets a list of lists that represent warnings that matched by the propertyName passed in (multiple lists because the wildcard can match multiple keys). |
boolean |
hasErrors()
|
int |
hashCode()
|
boolean |
hasInfo()
|
boolean |
hasMessages()
|
boolean |
hasNoErrors()
|
boolean |
hasNoInfo()
|
boolean |
hasNoMessages()
|
boolean |
hasNoWarnings()
|
boolean |
hasWarnings()
|
void |
merge(Map<String,List<ErrorMessage>> messagesFrom,
Map<String,List<ErrorMessage>> messagesTo)
Takes one message map and merges it into another. |
void |
merge(MessageMap messageMap)
|
List<ErrorMessage> |
putError(String propertyName,
ErrorMessage message)
|
List<ErrorMessage> |
putError(String propertyName,
String errorKey,
String... errorParameters)
|
List<ErrorMessage> |
putErrorForSectionId(String sectionId,
ErrorMessage message)
|
List<ErrorMessage> |
putErrorForSectionId(String sectionId,
String errorKey,
String... errorParameters)
|
List<ErrorMessage> |
putErrorWithoutFullErrorPath(String propertyName,
ErrorMessage message)
|
List<ErrorMessage> |
putErrorWithoutFullErrorPath(String propertyName,
String errorKey,
String... errorParameters)
|
List<ErrorMessage> |
putInfo(String propertyName,
ErrorMessage message)
|
List<ErrorMessage> |
putInfo(String propertyName,
String messageKey,
String... messageParameters)
|
List<ErrorMessage> |
putInfoForSectionId(String sectionId,
ErrorMessage message)
|
List<ErrorMessage> |
putInfoForSectionId(String sectionId,
String messageKey,
String... messageParameters)
|
List<ErrorMessage> |
putInfoWithoutFullErrorPath(String propertyName,
ErrorMessage message)
|
List<ErrorMessage> |
putInfoWithoutFullErrorPath(String propertyName,
String messageKey,
String... messageParameters)
|
protected List<ErrorMessage> |
putMessageInMap(Map<String,List<ErrorMessage>> messagesMap,
String propertyName,
ErrorMessage errorMessage,
boolean prependFullErrorPath,
boolean escapeHtmlMessageParameters)
Adds an error message to the given message map, adjusting the error path and message parameters if necessary |
List<ErrorMessage> |
putWarning(String propertyName,
ErrorMessage message)
|
List<ErrorMessage> |
putWarning(String propertyName,
String messageKey,
String... messageParameters)
|
List<ErrorMessage> |
putWarningForSectionId(String sectionId,
ErrorMessage message)
|
List<ErrorMessage> |
putWarningForSectionId(String sectionId,
String messageKey,
String... messageParameters)
|
List<ErrorMessage> |
putWarningWithoutFullErrorPath(String propertyName,
ErrorMessage message)
|
List<ErrorMessage> |
putWarningWithoutFullErrorPath(String propertyName,
String messageKey,
String... messageParameters)
|
List<ErrorMessage> |
removeAllErrorMessagesForProperty(String property)
|
List<ErrorMessage> |
removeAllInfoMessagesForProperty(String property)
|
List<ErrorMessage> |
removeAllWarningMessagesForProperty(String property)
|
boolean |
removeFromErrorPath(String parentName)
Removes a string prefix from the error path. |
boolean |
replaceError(String propertyName,
String targetKey,
String replaceKey,
String... replaceParameters)
If any error messages with the key targetKey exist in this ErrorMap for the named property, those ErrorMessages will be replaced with a new ErrorMessage with the given replaceKey and replaceParameters. |
boolean |
replaceErrorWithoutFullErrorPath(String propertyName,
String targetKey,
String replaceKey,
String... replaceParameters)
If any error messages with the key targetKey exist in this ErrorMap for the named property, those ErrorMessages will be replaced with a new ErrorMessage with the given replaceKey and replaceParameters. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MessageMap()
public MessageMap(MessageMap messageMap)
Method Detail |
---|
public void merge(MessageMap messageMap)
public void merge(Map<String,List<ErrorMessage>> messagesFrom, Map<String,List<ErrorMessage>> messagesTo)
messagesFrom
- messagesTo
- TODO: This method is not thread-safe and should be private.public List<ErrorMessage> putError(String propertyName, String errorKey, String... errorParameters)
public List<ErrorMessage> putWarning(String propertyName, String messageKey, String... messageParameters)
public List<ErrorMessage> putInfo(String propertyName, String messageKey, String... messageParameters)
public List<ErrorMessage> putError(String propertyName, ErrorMessage message)
public List<ErrorMessage> putWarning(String propertyName, ErrorMessage message)
public List<ErrorMessage> putInfo(String propertyName, ErrorMessage message)
public List<ErrorMessage> putErrorWithoutFullErrorPath(String propertyName, String errorKey, String... errorParameters)
public List<ErrorMessage> putWarningWithoutFullErrorPath(String propertyName, String messageKey, String... messageParameters)
public List<ErrorMessage> putInfoWithoutFullErrorPath(String propertyName, String messageKey, String... messageParameters)
public List<ErrorMessage> putErrorWithoutFullErrorPath(String propertyName, ErrorMessage message)
public List<ErrorMessage> putWarningWithoutFullErrorPath(String propertyName, ErrorMessage message)
public List<ErrorMessage> putInfoWithoutFullErrorPath(String propertyName, ErrorMessage message)
public List<ErrorMessage> putErrorForSectionId(String sectionId, String errorKey, String... errorParameters)
public List<ErrorMessage> putWarningForSectionId(String sectionId, String messageKey, String... messageParameters)
public List<ErrorMessage> putInfoForSectionId(String sectionId, String messageKey, String... messageParameters)
public List<ErrorMessage> putErrorForSectionId(String sectionId, ErrorMessage message)
public List<ErrorMessage> putWarningForSectionId(String sectionId, ErrorMessage message)
public List<ErrorMessage> putInfoForSectionId(String sectionId, ErrorMessage message)
public void addGrowlMessage(String growlTitle, String messageKey, String... messageParameters)
growlTitle
- - title for the growlmessageKey
- - key for the message in resourcesmessageParameters
- - parameters for the messagepublic void addGrowlMessage(GrowlMessage growl)
growl
- - growl instance to addprotected List<ErrorMessage> putMessageInMap(Map<String,List<ErrorMessage>> messagesMap, String propertyName, ErrorMessage errorMessage, boolean prependFullErrorPath, boolean escapeHtmlMessageParameters)
messagesMap
- propertyName
- name of the property to add error undererrorMessage
- prependFullErrorPath
- true if you want the whole parent error path prepended, false otherwiseescapeHtmlMessageParameters
- whether to escape HTML characters in the message parameters, provides
protection against XSS attacks
public boolean replaceError(String propertyName, String targetKey, String replaceKey, String... replaceParameters)
propertyName
- name of the property where existing error will be replacedtargetKey
- error key of message to be replacedreplaceParameters
- zero or more string parameters for the replacement error message
public boolean replaceErrorWithoutFullErrorPath(String propertyName, String targetKey, String replaceKey, String... replaceParameters)
propertyName
- name of the property where existing error will be replacedtargetKey
- error key of message to be replacedreplaceParameters
- zero or more string parameters for the replacement error message
public boolean fieldHasMessage(String fieldName, String errorKey)
errorKey
- fieldName
-
public int countFieldMessages(String fieldName)
fieldName
-
public boolean containsMessageKey(String messageKey)
public int getErrorCount()
public int getWarningCount()
public int getInfoCount()
public List<ErrorMessage> getMessages(String path)
path
-
public void addToErrorPath(String parentName)
parentName
- public List<String> getErrorPath()
public boolean removeFromErrorPath(String parentName)
parentName
-
public void clearErrorPath()
public String getKeyPath(String propertyName, boolean prependFullErrorPath)
propertyName
- prependFullErrorPath
-
public List<String> getPropertiesWithErrors()
public List<String> getPropertiesWithWarnings()
public List<String> getPropertiesWithInfo()
public void clearErrorMessages()
public boolean doesPropertyHaveError(String key)
public boolean containsKeyMatchingPattern(String pattern)
pattern
- comma separated list of keys, optionally ending with * wildcardpublic Set<Map.Entry<String,List<ErrorMessage>>> getAllPropertiesAndErrors()
public List<ErrorMessage> getErrorMessagesForProperty(String propertyName)
public List<ErrorMessage> getWarningMessagesForProperty(String propertyName)
public List<ErrorMessage> getInfoMessagesForProperty(String propertyName)
public List<List<ErrorMessage>> getErrorMessagesForProperty(String propertyName, boolean allowWildcard)
propertyName
- allowWildcard
-
public List<List<ErrorMessage>> getWarningMessagesForProperty(String propertyName, boolean allowWildcard)
propertyName
- allowWildcard
-
public List<List<ErrorMessage>> getInfoMessagesForProperty(String propertyName, boolean allowWildcard)
propertyName
- allowWildcard
-
public boolean hasErrors()
public boolean hasNoErrors()
public boolean hasWarnings()
public boolean hasNoWarnings()
public boolean hasInfo()
public boolean hasNoInfo()
public boolean hasMessages()
public boolean hasNoMessages()
public Set<String> getAllPropertiesWithErrors()
public Set<String> getAllPropertiesWithWarnings()
public Set<String> getAllPropertiesWithInfo()
public List<ErrorMessage> removeAllErrorMessagesForProperty(String property)
public List<ErrorMessage> removeAllWarningMessagesForProperty(String property)
public List<ErrorMessage> removeAllInfoMessagesForProperty(String property)
public int getNumberOfPropertiesWithErrors()
public Map<String,List<ErrorMessage>> getErrorMessages()
public Map<String,List<ErrorMessage>> getWarningMessages()
public Map<String,List<ErrorMessage>> getInfoMessages()
public List<GrowlMessage> getGrowlMessages()
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |