1 16 package org.springframework.webflow.engine; 17 18 import java.util.Arrays ; 19 import java.util.Iterator ; 20 import java.util.LinkedList ; 21 import java.util.List ; 22 23 import org.springframework.core.style.StylerUtils; 24 import org.springframework.webflow.execution.Action; 25 import org.springframework.webflow.execution.RequestContext; 26 27 40 public class ActionList { 41 42 45 private List actions = new LinkedList (); 46 47 53 public boolean add(Action action) { 54 return actions.add(action); 55 } 56 57 63 public boolean addAll(Action[] actions) { 64 if (actions == null) { 65 return false; 66 } 67 return this.actions.addAll(Arrays.asList(actions)); 68 } 69 70 75 public boolean contains(Action action) { 76 return actions.contains(action); 77 } 78 79 85 public boolean remove(Action action) { 86 return actions.remove(action); 87 } 88 89 93 public int size() { 94 return actions.size(); 95 } 96 97 102 public Action get(int index) throws IndexOutOfBoundsException { 103 return (Action)actions.get(index); 104 } 105 106 112 public AnnotatedAction getAnnotated(int index) throws IndexOutOfBoundsException { 113 Action action = get(index); 114 if (action instanceof AnnotatedAction) { 115 return (AnnotatedAction)action; 116 } 117 else { 118 return new AnnotatedAction(action); 120 } 121 } 122 123 126 public Iterator iterator() { 127 return actions.iterator(); 128 } 129 130 134 public Action[] toArray() { 135 return (Action[])actions.toArray(new Action[actions.size()]); 136 } 137 138 144 public AnnotatedAction[] toAnnotatedArray() { 145 AnnotatedAction[] annotatedActions = new AnnotatedAction[actions.size()]; 146 for (int i = 0; i < size(); i++) { 147 annotatedActions[i] = getAnnotated(i); 148 } 149 return annotatedActions; 150 } 151 152 157 public void execute(RequestContext context) { 158 Iterator it = actions.iterator(); 159 while (it.hasNext()) { 160 ActionExecutor.execute((Action)it.next(), context); 161 } 162 } 163 164 public String toString() { 165 return StylerUtils.style(actions); 166 } 167 } | Popular Tags |