1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.util;
17
18 import java.io.Serializable;
19 import java.util.Iterator;
20 import java.util.List;
21 import java.util.Set;
22
23 import org.apache.struts.action.ActionMessage;
24 import org.apache.struts.action.ActionMessages;
25
26
27
28
29
30
31
32 public abstract class MessageContainer implements Serializable {
33 private MessageMap errorMap;
34
35 protected MessageContainer(MessageMap errorMap) {
36 this.errorMap = errorMap;
37 }
38
39
40
41
42
43
44
45 @Deprecated
46 protected ErrorMap getErrorMap() {
47 return new ErrorMap(errorMap);
48 }
49
50 protected MessageMap getMessageMap() {
51 return errorMap;
52 }
53
54 public ActionMessages getRequestMessages() {
55 ActionMessages requestErrors = new ActionMessages();
56 for (Iterator<String> iter = getMessagePropertyNames().iterator(); iter.hasNext();) {
57 String property = iter.next();
58 List errorList = (List) getMessagesForProperty(property);
59
60 for (Iterator iterator = errorList.iterator(); iterator.hasNext();) {
61 ErrorMessage errorMessage = (ErrorMessage) iterator.next();
62
63
64 requestErrors.add(property, new ActionMessage(errorMessage.getErrorKey(), errorMessage.getMessageParameters()));
65 }
66 }
67 return requestErrors;
68 }
69
70 public abstract int getMessageCount();
71
72 public abstract List<String> getMessagePropertyList();
73
74 protected abstract Set<String> getMessagePropertyNames();
75
76 protected abstract List getMessagesForProperty(String propertyName);
77 }