1 16 package org.springframework.webflow.execution.support; 17 18 import org.springframework.webflow.core.collection.AttributeMap; 19 import org.springframework.webflow.core.collection.CollectionUtils; 20 import org.springframework.webflow.execution.Event; 21 22 32 public class EventFactorySupport { 33 34 37 private static final String SUCCESS_EVENT_ID = "success"; 38 39 42 private static final String ERROR_EVENT_ID = "error"; 43 44 47 private static final String YES_EVENT_ID = "yes"; 48 49 52 private static final String NO_EVENT_ID = "no"; 53 54 57 private static final String NULL_EVENT_ID = "null"; 58 59 62 private static final String EXCEPTION_ATTRIBUTE_NAME = "exception"; 63 64 67 private static final String RESULT_ATTRIBUTE_NAME = "result"; 68 69 72 private String successEventId = SUCCESS_EVENT_ID; 73 74 77 private String errorEventId = ERROR_EVENT_ID; 78 79 82 private String yesEventId = YES_EVENT_ID; 83 84 87 private String noEventId = NO_EVENT_ID; 88 89 92 private String nullEventId = NULL_EVENT_ID; 93 94 97 private String exceptionAttributeName = EXCEPTION_ATTRIBUTE_NAME; 98 99 102 private String resultAttributeName = RESULT_ATTRIBUTE_NAME; 103 104 public String getSuccessEventId() { 105 return successEventId; 106 } 107 108 public void setSuccessEventId(String successEventId) { 109 this.successEventId = successEventId; 110 } 111 112 public String getErrorEventId() { 113 return errorEventId; 114 } 115 116 public void setErrorEventId(String errorEventId) { 117 this.errorEventId = errorEventId; 118 } 119 120 public String getYesEventId() { 121 return yesEventId; 122 } 123 124 public void setYesEventId(String yesEventId) { 125 this.yesEventId = yesEventId; 126 } 127 128 public String getNoEventId() { 129 return noEventId; 130 } 131 132 public void setNoEventId(String noEventId) { 133 this.noEventId = noEventId; 134 } 135 136 public String getNullEventId() { 137 return nullEventId; 138 } 139 140 public void setNullEventId(String nullEventId) { 141 this.nullEventId = nullEventId; 142 } 143 144 public String getExceptionAttributeName() { 145 return exceptionAttributeName; 146 } 147 148 public void setExceptionAttributeName(String exceptionAttributeName) { 149 this.exceptionAttributeName = exceptionAttributeName; 150 } 151 152 public String getResultAttributeName() { 153 return resultAttributeName; 154 } 155 156 public void setResultAttributeName(String resultAttributeName) { 157 this.resultAttributeName = resultAttributeName; 158 } 159 160 164 public Event success(Object source) { 165 return event(source, getSuccessEventId()); 166 } 167 168 175 public Event success(Object source, Object result) { 176 return event(source, getSuccessEventId(), getResultAttributeName(), result); 177 } 178 179 183 public Event error(Object source) { 184 return event(source, getErrorEventId()); 185 } 186 187 193 public Event error(Object source, Exception e) { 194 return event(source, getErrorEventId(), getExceptionAttributeName(), e); 195 } 196 197 201 public Event yes(Object source) { 202 return event(source, getYesEventId()); 203 } 204 205 209 public Event no(Object source) { 210 return event(source, getNoEventId()); 211 } 212 213 219 public Event event(Object source, boolean booleanResult) { 220 if (booleanResult) { 221 return yes(source); 222 } 223 else { 224 return no(source); 225 } 226 } 227 228 234 public Event event(Object source, String eventId) { 235 return new Event(source, eventId, null); 236 } 237 238 246 public Event event(Object source, String eventId, AttributeMap attributes) { 247 return new Event(source, eventId, attributes); 248 } 249 250 259 public Event event(Object source, String eventId, String attributeName, Object attributeValue) { 260 return new Event(source, eventId, CollectionUtils.singleEntryMap(attributeName, attributeValue)); 261 } 262 } | Popular Tags |