1 16 package org.springframework.webflow.engine; 17 18 import java.util.Iterator ; 19 import java.util.LinkedList ; 20 import java.util.List ; 21 22 import org.springframework.core.style.StylerUtils; 23 import org.springframework.webflow.core.collection.CollectionUtils; 24 import org.springframework.webflow.execution.FlowExecutionException; 25 import org.springframework.webflow.execution.ViewSelection; 26 27 37 public class FlowExecutionExceptionHandlerSet { 38 39 42 private List exceptionHandlers = new LinkedList (); 43 44 50 public boolean add(FlowExecutionExceptionHandler exceptionHandler) { 51 if (contains(exceptionHandler)) { 52 return false; 53 } 54 return exceptionHandlers.add(exceptionHandler); 55 } 56 57 63 public boolean addAll(FlowExecutionExceptionHandler[] exceptionHandlers) { 64 return CollectionUtils.addAllNoDuplicates(this.exceptionHandlers, exceptionHandlers); 65 } 66 67 73 public boolean contains(FlowExecutionExceptionHandler exceptionHandler) { 74 return exceptionHandlers.contains(exceptionHandler); 75 } 76 77 83 public boolean remove(FlowExecutionExceptionHandler exceptionHandler) { 84 return exceptionHandlers.remove(exceptionHandler); 85 } 86 87 91 public int size() { 92 return exceptionHandlers.size(); 93 } 94 95 99 public FlowExecutionExceptionHandler[] toArray() { 100 return (FlowExecutionExceptionHandler[])exceptionHandlers.toArray(new FlowExecutionExceptionHandler[exceptionHandlers.size()]); 101 } 102 103 115 public ViewSelection handleException(FlowExecutionException exception, RequestControlContext context) { 116 Iterator it = exceptionHandlers.iterator(); 117 while (it.hasNext()) { 118 FlowExecutionExceptionHandler handler = (FlowExecutionExceptionHandler)it.next(); 119 if (handler.handles(exception)) { 120 ViewSelection result = handler.handle(exception, context); 121 if (result != null) { 122 return result; 123 } 124 } 126 } 127 return null; 128 } 129 130 public String toString() { 131 return StylerUtils.style(exceptionHandlers); 132 } 133 } | Popular Tags |