Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace use of Iterator with Java 5 foreach loops

Issues: SWF-1532
  • Loading branch information...
commit 34f4837ebd9c1afabd83e66d4086443c711adc1a 1 parent 22b018e
@philwebb philwebb authored
Showing with 112 additions and 254 deletions.
  1. +2 −4 spring-binding/src/main/java/org/springframework/binding/convert/converters/ArrayToCollection.java
  2. +1 −4 spring-binding/src/main/java/org/springframework/binding/convert/converters/CollectionToCollection.java
  3. +1 −4 spring-binding/src/main/java/org/springframework/binding/expression/el/DefaultELResolver.java
  4. +1 −4 spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMapper.java
  5. +3 −10 spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMappingResults.java
  6. +2 −7 spring-binding/src/main/java/org/springframework/binding/message/DefaultMessageContext.java
  7. +1 −4 spring-binding/src/main/java/org/springframework/binding/message/MessageContextErrors.java
  8. +1 −6 spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java
  9. +1 −4 spring-faces/src/main/java/org/springframework/faces/ui/AjaxViewRoot.java
  10. +7 −13 spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButtonRenderer.java
  11. +8 −19 spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandLinkRenderer.java
  12. +2 −5 spring-faces/src/main/java/org/springframework/faces/ui/resource/ResourceHelper.java
  13. +3 −3 spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextMessageDelegate.java
  14. +1 −3 spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesView.java
  15. +2 −7 spring-js/src/main/java/org/springframework/js/resource/ResourceServlet.java
  16. +1 −4 spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutionListenerLoaderFactoryBean.java
  17. +3 −5 spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalAttributeMap.java
  18. +1 −4 spring-webflow/src/main/java/org/springframework/webflow/definition/registry/FlowDefinitionRegistryImpl.java
  19. +3 −4 spring-webflow/src/main/java/org/springframework/webflow/engine/ActionList.java
  20. +6 −16 spring-webflow/src/main/java/org/springframework/webflow/engine/Flow.java
  21. +2 −5 spring-webflow/src/main/java/org/springframework/webflow/engine/FlowExecutionExceptionHandlerSet.java
  22. +4 −7 spring-webflow/src/main/java/org/springframework/webflow/engine/TransitionSet.java
  23. +3 −12 spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java
  24. +1 −4 spring-webflow/src/main/java/org/springframework/webflow/engine/builder/BinderConfiguration.java
  25. +1 −1  spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionImplFactory.java
  26. +30 −30 spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractModel.java
  27. +2 −5 spring-webflow/src/main/java/org/springframework/webflow/engine/support/TransitionCriteriaChain.java
  28. +2 −5 ...low/src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerHolder.java
  29. +4 −7 ...low/src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerLoader.java
  30. +2 −10 spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/FlowHandlerAdapter.java
  31. +2 −11 spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapter.java
  32. +1 −4 spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java
  33. +2 −4 spring-webflow/src/main/java/org/springframework/webflow/security/SecurityFlowExecutionListener.java
  34. +5 −14 spring-webflow/src/main/java/org/springframework/webflow/security/SecurityRule.java
  35. +1 −5 spring-webflow/src/test/java/org/springframework/webflow/config/FlowRegistryBeanDefinitionParserTests.java
View
6 spring-binding/src/main/java/org/springframework/binding/convert/converters/ArrayToCollection.java
@@ -19,7 +19,6 @@
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -101,8 +100,7 @@ public Object convertTargetToSourceClass(Object target, Class<?> sourceClass) th
Collection<?> collection = (Collection<?>) target;
Object array = Array.newInstance(sourceClass.getComponentType(), collection.size());
int i = 0;
- for (Iterator<?> it = collection.iterator(); it.hasNext(); i++) {
- Object value = it.next();
+ for (Object value : collection) {
if (value != null) {
ConversionExecutor converter;
if (elementConverter != null) {
@@ -113,7 +111,7 @@ public Object convertTargetToSourceClass(Object target, Class<?> sourceClass) th
}
value = converter.execute(value);
}
- Array.set(array, i, value);
+ Array.set(array, i++, value);
}
return array;
}
View
5 spring-binding/src/main/java/org/springframework/binding/convert/converters/CollectionToCollection.java
@@ -1,7 +1,6 @@
package org.springframework.binding.convert.converters;
import java.util.Collection;
-import java.util.Iterator;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.ConversionService;
@@ -54,9 +53,7 @@ public Object convertSourceToTargetClass(Object source, Class<?> targetClass) th
Collection targetCollection = CollectionFactory.createCollection(targetClass, DEFAULT_INITIAL_SIZE);
ConversionExecutor elementConverter = getElementConverter(source, (Class<? extends Collection<?>>) targetClass);
Collection sourceCollection = (Collection) source;
- Iterator it = sourceCollection.iterator();
- while (it.hasNext()) {
- Object value = it.next();
+ for (Object value : sourceCollection) {
if (elementConverter != null) {
value = elementConverter.execute(value);
}
View
5 spring-binding/src/main/java/org/springframework/binding/expression/el/DefaultELResolver.java
@@ -15,7 +15,6 @@
*/
package org.springframework.binding.expression.el;
-import java.util.Iterator;
import java.util.List;
import javax.el.ArrayELResolver;
@@ -91,9 +90,7 @@ public void setValue(ELContext context, Object base, Object property, Object val
private void configureResolvers(List<? extends ELResolver> customResolvers) {
if (customResolvers != null) {
- Iterator<? extends ELResolver> i = customResolvers.iterator();
- while (i.hasNext()) {
- ELResolver resolver = i.next();
+ for (ELResolver resolver : customResolvers) {
add(resolver);
}
}
View
5 spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMapper.java
@@ -16,7 +16,6 @@
package org.springframework.binding.mapping.impl;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -62,9 +61,7 @@ public MappingResults map(Object source, Object target) {
+ target.getClass().getName() + "]");
}
DefaultMappingContext context = new DefaultMappingContext(source, target);
- Iterator<DefaultMapping> it = mappings.iterator();
- while (it.hasNext()) {
- DefaultMapping mapping = it.next();
+ for (DefaultMapping mapping : mappings) {
mapping.map(context);
}
MappingResults results = context.getMappingResults();
View
13 spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMappingResults.java
@@ -17,7 +17,6 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.springframework.binding.mapping.MappingResult;
@@ -61,9 +60,7 @@ public Object getTarget() {
}
public boolean hasErrorResults() {
- Iterator<MappingResult> it = mappingResults.iterator();
- while (it.hasNext()) {
- MappingResult result = it.next();
+ for (MappingResult result : mappingResults) {
if (result.isError()) {
return true;
}
@@ -73,9 +70,7 @@ public boolean hasErrorResults() {
public List<MappingResult> getErrorResults() {
List<MappingResult> errorResults = new ArrayList<MappingResult>();
- Iterator<MappingResult> it = mappingResults.iterator();
- while (it.hasNext()) {
- MappingResult result = it.next();
+ for (MappingResult result : mappingResults) {
if (result.isError()) {
errorResults.add(result);
}
@@ -85,9 +80,7 @@ public boolean hasErrorResults() {
public List<MappingResult> getResults(MappingResultsCriteria criteria) {
List<MappingResult> results = new ArrayList<MappingResult>();
- Iterator<MappingResult> it = mappingResults.iterator();
- while (it.hasNext()) {
- MappingResult result = it.next();
+ for (MappingResult result : mappingResults) {
if (criteria.test(result)) {
results.add(result);
}
View
9 spring-binding/src/main/java/org/springframework/binding/message/DefaultMessageContext.java
@@ -18,7 +18,6 @@
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
@@ -88,9 +87,7 @@ public MessageSource getMessageSource() {
public Message[] getMessagesByCriteria(MessageCriteria criteria) {
List<Message> messages = new ArrayList<Message>();
- Iterator<List<Message>> it = sourceMessages.values().iterator();
- while (it.hasNext()) {
- List<Message> sourceMessages = it.next();
+ for (List<Message> sourceMessages : this.sourceMessages.values()) {
for (Message message : sourceMessages) {
if (criteria.test(message)) {
messages.add(message);
@@ -101,9 +98,7 @@ public MessageSource getMessageSource() {
}
public boolean hasErrorMessages() {
- Iterator<List<Message>> it = sourceMessages.values().iterator();
- while (it.hasNext()) {
- List<Message> sourceMessages = it.next();
+ for (List<Message> sourceMessages : this.sourceMessages.values()) {
for (Message message : sourceMessages) {
if (message.getSeverity() == Severity.ERROR) {
return true;
View
5 spring-binding/src/main/java/org/springframework/binding/message/MessageContextErrors.java
@@ -17,7 +17,6 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.springframework.binding.expression.Expression;
@@ -100,9 +99,7 @@ public void rejectValue(String field, String errorCode, Object[] errorArgs, Stri
}
public void addAllErrors(Errors errors) {
- Iterator<ObjectError> it = errors.getAllErrors().iterator();
- while (it.hasNext()) {
- ObjectError error = it.next();
+ for (ObjectError error : errors.getAllErrors()) {
MessageBuilder builder = new MessageBuilder().error().codes(error.getCodes()).args(error.getArguments())
.defaultText(error.getDefaultMessage());
if (error instanceof FieldError) {
View
7 spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java
@@ -18,7 +18,6 @@
import static org.springframework.faces.webflow.JsfRuntimeInformation.isAtLeastJsf12;
import static org.springframework.faces.webflow.JsfRuntimeInformation.isPortletRequest;
-import java.util.Iterator;
import java.util.Map;
import javax.faces.FactoryFinder;
@@ -89,11 +88,7 @@ protected void renderMergedOutputModel(Map<String, Object> model, HttpServletReq
}
private void populateRequestMap(FacesContext facesContext, Map<String, Object> model) {
- Iterator<String> i = model.keySet().iterator();
- while (i.hasNext()) {
- String key = i.next().toString();
- facesContext.getExternalContext().getRequestMap().put(key, model.get(key));
- }
+ facesContext.getExternalContext().getRequestMap().putAll(model);
}
private Lifecycle createFacesLifecycle() {
View
5 spring-faces/src/main/java/org/springframework/faces/ui/AjaxViewRoot.java
@@ -18,7 +18,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
@@ -266,9 +265,7 @@ private void broadCastEvents(FacesContext context, PhaseId phaseId) {
}
boolean abort = false;
int phaseIdOrdinal = phaseId.getOrdinal();
- Iterator<FacesEvent> i = events.iterator();
- while (i.hasNext()) {
- FacesEvent event = i.next();
+ for (FacesEvent event : events) {
int ordinal = event.getPhaseId().getOrdinal();
if (ordinal == PhaseId.ANY_PHASE.getOrdinal() || ordinal == phaseIdOrdinal) {
UIComponent source = event.getComponent();
View
20 spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButtonRenderer.java
@@ -20,7 +20,6 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import javax.faces.component.UIComponent;
@@ -37,7 +36,6 @@
* {@link Renderer} for the {@code <sf:commandButton>} tag.
*
* @author Jeremy Grelle
- *
*/
public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer {
@@ -46,17 +44,13 @@
private static String INPUT_TAG_NAME = "input";
static {
- List<String> tempList = new ArrayList<String>();
- tempList.addAll(Arrays.asList(HTML.STANDARD_ATTRIBUTES));
- tempList.addAll(Arrays.asList(HTML.BUTTON_ATTRIBUTES));
- tempList.addAll(Arrays.asList(HTML.COMMON_ELEMENT_EVENTS));
- tempList.addAll(Arrays.asList(HTML.KEYBOARD_EVENTS));
- tempList.addAll(Arrays.asList(HTML.MOUSE_EVENTS));
- ATTRIBUTES_TO_RENDER = new String[tempList.size()];
- ListIterator<String> i = tempList.listIterator();
- while (i.hasNext()) {
- ATTRIBUTES_TO_RENDER[i.nextIndex()] = i.next();
- }
+ List<String> attributes = new ArrayList<String>();
+ attributes.addAll(Arrays.asList(HTML.STANDARD_ATTRIBUTES));
+ attributes.addAll(Arrays.asList(HTML.BUTTON_ATTRIBUTES));
+ attributes.addAll(Arrays.asList(HTML.COMMON_ELEMENT_EVENTS));
+ attributes.addAll(Arrays.asList(HTML.KEYBOARD_EVENTS));
+ attributes.addAll(Arrays.asList(HTML.MOUSE_EVENTS));
+ ATTRIBUTES_TO_RENDER = attributes.toArray(new String[attributes.size()]);
}
private Map<String, RenderAttributeCallback> attributeCallbacks;
View
27 spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandLinkRenderer.java
@@ -22,7 +22,6 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import javax.faces.component.UIComponent;
@@ -58,24 +57,14 @@
private static String TAG_NAME_WHEN_DISABLED = "span";
static {
-
- List<String> tempList = new ArrayList<String>();
- tempList.addAll(Arrays.asList(HTML.STANDARD_ATTRIBUTES));
- tempList.addAll(Arrays.asList(HTML.COMMON_ELEMENT_EVENTS));
- tempList.addAll(Arrays.asList(HTML.KEYBOARD_EVENTS));
- tempList.addAll(Arrays.asList(HTML.MOUSE_EVENTS));
- ATTRIBUTES_TO_RENDER_WHEN_DISABLED = new String[tempList.size()];
- ListIterator<String> i = tempList.listIterator();
- while (i.hasNext()) {
- ATTRIBUTES_TO_RENDER_WHEN_DISABLED[i.nextIndex()] = i.next();
- }
-
- tempList.addAll(Arrays.asList(HTML.ANCHOR_ATTRIBUTES));
- ATTRIBUTES_TO_RENDER = new String[tempList.size()];
- i = tempList.listIterator();
- while (i.hasNext()) {
- ATTRIBUTES_TO_RENDER[i.nextIndex()] = i.next();
- }
+ List<String> attributes = new ArrayList<String>();
+ attributes.addAll(Arrays.asList(HTML.STANDARD_ATTRIBUTES));
+ attributes.addAll(Arrays.asList(HTML.COMMON_ELEMENT_EVENTS));
+ attributes.addAll(Arrays.asList(HTML.KEYBOARD_EVENTS));
+ attributes.addAll(Arrays.asList(HTML.MOUSE_EVENTS));
+ ATTRIBUTES_TO_RENDER_WHEN_DISABLED = attributes.toArray(new String[attributes.size()]);
+ attributes.addAll(Arrays.asList(HTML.ANCHOR_ATTRIBUTES));
+ ATTRIBUTES_TO_RENDER = attributes.toArray(new String[attributes.size()]);
}
private Map<String, RenderAttributeCallback> attributeCallbacks;
View
7 spring-faces/src/main/java/org/springframework/faces/ui/resource/ResourceHelper.java
@@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -92,10 +91,8 @@ public static void renderScriptLink(FacesContext facesContext, String scriptPath
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(SCRIPT_ELEMENT, null);
writer.writeAttribute("type", "text/javascript", null);
- Iterator<String> i = attributes.keySet().iterator();
- while (i.hasNext()) {
- String key = i.next();
- writer.writeAttribute(key, attributes.get(key), null);
+ for (Map.Entry<String, Object> entry : attributes.entrySet()) {
+ writer.writeAttribute(entry.getKey(), entry.getValue(), null);
}
String src = facesContext.getExternalContext().getRequestContextPath() + "/resources" + scriptPath;
writer.writeAttribute("src", src, null);
View
6 spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextMessageDelegate.java
@@ -95,9 +95,9 @@ public void addToFlowMessageContext(String clientId, FacesMessage message) {
return null;
}
FacesMessage.Severity max = FacesMessage.SEVERITY_INFO;
- Iterator<FacesMessage> i = getMessages();
- while (i.hasNext()) {
- FacesMessage message = i.next();
+ Iterator<FacesMessage> messages = getMessages();
+ while (messages.hasNext()) {
+ FacesMessage message = messages.next();
if (message.getSeverity().getOrdinal() > max.getOrdinal()) {
max = message.getSeverity();
}
View
4 spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesView.java
@@ -196,9 +196,7 @@ protected void addRuntimeAttributes(BasicTilesContainer container, Map<String, A
if (attributeContext.getCascadedAttributeNames() != null) {
attributeNames.addAll(attributeContext.getCascadedAttributeNames());
}
- Iterator<String> iterator = attributeNames.iterator();
- while (iterator.hasNext()) {
- String name = iterator.next();
+ for (String name : attributeNames) {
Attribute attr = attributeContext.getAttribute(name);
resultMap.put(name, attr);
}
View
9 spring-js/src/main/java/org/springframework/js/resource/ResourceServlet.java
@@ -25,7 +25,6 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.zip.GZIPOutputStream;
@@ -166,9 +165,7 @@ private OutputStream selectOutputStream(HttpServletRequest request, HttpServletR
private boolean matchesCompressedMimeTypes(String mimeType) {
PathMatcher pathMatcher = new AntPathMatcher();
- Iterator<String> compressedMimeTypesIt = compressedMimeTypes.iterator();
- while (compressedMimeTypesIt.hasNext()) {
- String compressedMimeType = compressedMimeTypesIt.next();
+ for (String compressedMimeType : compressedMimeTypes) {
if (pathMatcher.match(compressedMimeType, mimeType)) {
return true;
}
@@ -298,9 +295,7 @@ private boolean isAllowed(String resourcePath) {
return false;
}
PathMatcher pathMatcher = new AntPathMatcher();
- Iterator<String> allowedResourcePathsIt = allowedResourcePaths.iterator();
- while (allowedResourcePathsIt.hasNext()) {
- String pattern = allowedResourcePathsIt.next();
+ for (String pattern : allowedResourcePaths) {
if (pathMatcher.match(pattern, resourcePath)) {
return true;
}
View
5 spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutionListenerLoaderFactoryBean.java
@@ -15,7 +15,6 @@
*/
package org.springframework.webflow.config;
-import java.util.Iterator;
import java.util.Map;
import org.springframework.beans.factory.FactoryBean;
@@ -60,9 +59,7 @@ public void setListeners(Map<FlowExecutionListener, String> listenersWithCriteri
public void afterPropertiesSet() {
listenerLoader = new ConditionalFlowExecutionListenerLoader();
- Iterator<Map.Entry<FlowExecutionListener, String>> it = listenersWithCriteria.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry<FlowExecutionListener, String> entry = it.next();
+ for (Map.Entry<FlowExecutionListener, String> entry : listenersWithCriteria.entrySet()) {
FlowExecutionListener listener = entry.getKey();
String criteria = entry.getValue();
listenerLoader.addListener(listener, listenerCriteriaFactory.getListenerCriteria(criteria));
View
8 spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalAttributeMap.java
@@ -21,7 +21,6 @@
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.springframework.binding.collection.MapAccessor;
@@ -243,10 +242,9 @@ public V put(String attributeName, V attributeValue) {
if (attributes == null) {
return this;
}
- Iterator<String> it = attributes.asMap().keySet().iterator();
Map<String, V> internal = getMapInternal();
- while (it.hasNext()) {
- internal.remove(it.next());
+ for (String attribute : attributes.asMap().keySet()) {
+ internal.remove(attribute);
}
return this;
}
@@ -343,4 +341,4 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
public String toString() {
return StylerUtils.style(attributes);
}
-}
+}
View
5 ...ng-webflow/src/main/java/org/springframework/webflow/definition/registry/FlowDefinitionRegistryImpl.java
@@ -15,7 +15,6 @@
*/
package org.springframework.webflow.definition.registry;
-import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
@@ -108,9 +107,7 @@ public void registerFlowDefinition(FlowDefinition definition) {
}
public void destroy() {
- Iterator<FlowDefinitionHolder> it = flowDefinitions.values().iterator();
- while (it.hasNext()) {
- FlowDefinitionHolder holder = it.next();
+ for (FlowDefinitionHolder holder : flowDefinitions.values()) {
holder.destroy();
}
}
View
7 spring-webflow/src/main/java/org/springframework/webflow/engine/ActionList.java
@@ -150,13 +150,12 @@ public AnnotatedAction getAnnotated(int index) throws IndexOutOfBoundsException
* @param context the action execution request context
*/
public void execute(RequestContext context) {
- Iterator<Action> it = actions.iterator();
- while (it.hasNext()) {
- ActionExecutor.execute(it.next(), context);
+ for (Action action : actions) {
+ ActionExecutor.execute(action, context);
}
}
public String toString() {
return StylerUtils.style(actions);
}
-}
+}
View
22 spring-webflow/src/main/java/org/springframework/webflow/engine/Flow.java
@@ -16,7 +16,6 @@
package org.springframework.webflow.engine;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@@ -279,9 +278,7 @@ public int getStateCount() {
* @return true if yes, false otherwise
*/
public boolean containsState(String stateId) {
- Iterator<State> it = states.iterator();
- while (it.hasNext()) {
- State state = it.next();
+ for (State state : states) {
if (state.getId().equals(stateId)) {
return true;
}
@@ -337,9 +334,7 @@ public State getStateInstance(String stateId) throws IllegalArgumentException {
if (!StringUtils.hasText(stateId)) {
throw new IllegalArgumentException("The specified stateId is invalid: state identifiers must be non-blank");
}
- Iterator<State> it = states.iterator();
- while (it.hasNext()) {
- State state = it.next();
+ for (State state : states) {
if (state.getId().equals(stateId)) {
return state;
}
@@ -356,9 +351,8 @@ public State getStateInstance(String stateId) throws IllegalArgumentException {
public String[] getStateIds() {
String[] stateIds = new String[getStateCount()];
int i = 0;
- Iterator<State> it = states.iterator();
- while (it.hasNext()) {
- stateIds[i++] = it.next().getId();
+ for (State state : states) {
+ stateIds[i++] = state.getId();
}
return stateIds;
}
@@ -616,9 +610,7 @@ private void assertStartStateSet() {
}
private void createVariables(RequestContext context) {
- Iterator<FlowVariable> it = variables.values().iterator();
- while (it.hasNext()) {
- FlowVariable variable = it.next();
+ for (FlowVariable variable : variables.values()) {
if (logger.isDebugEnabled()) {
logger.debug("Creating " + variable);
}
@@ -627,9 +619,7 @@ private void createVariables(RequestContext context) {
}
public void restoreVariables(RequestContext context) {
- Iterator<FlowVariable> it = variables.values().iterator();
- while (it.hasNext()) {
- FlowVariable variable = it.next();
+ for (FlowVariable variable : variables.values()) {
if (logger.isDebugEnabled()) {
logger.debug("Restoring " + variable);
}
View
7 spring-webflow/src/main/java/org/springframework/webflow/engine/FlowExecutionExceptionHandlerSet.java
@@ -15,7 +15,6 @@
*/
package org.springframework.webflow.engine;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -105,9 +104,7 @@ public int size() {
* @return true if the exception was handled
*/
public boolean handleException(FlowExecutionException exception, RequestControlContext context) {
- Iterator<FlowExecutionExceptionHandler> it = exceptionHandlers.iterator();
- while (it.hasNext()) {
- FlowExecutionExceptionHandler handler = it.next();
+ for (FlowExecutionExceptionHandler handler : exceptionHandlers) {
if (handler.canHandle(exception)) {
handler.handle(exception, context);
return true;
@@ -119,4 +116,4 @@ public boolean handleException(FlowExecutionException exception, RequestControlC
public String toString() {
return StylerUtils.style(exceptionHandlers);
}
-}
+}
View
11 spring-webflow/src/main/java/org/springframework/webflow/engine/TransitionSet.java
@@ -108,9 +108,8 @@ public int size() {
public TransitionCriteria[] getTransitionCriterias() {
TransitionCriteria[] criterias = new TransitionCriteria[transitions.size()];
int i = 0;
- Iterator<Transition> it = transitions.iterator();
- while (it.hasNext()) {
- criterias[i++] = it.next().getMatchingCriteria();
+ for (Transition transition : transitions) {
+ criterias[i++] = transition.getMatchingCriteria();
}
return criterias;
}
@@ -121,9 +120,7 @@ public int size() {
* @return the transition, or null if no transition matches
*/
public Transition getTransition(RequestContext context) {
- Iterator<Transition> it = transitions.iterator();
- while (it.hasNext()) {
- Transition transition = it.next();
+ for (Transition transition : transitions) {
if (transition.matches(context)) {
return transition;
}
@@ -142,4 +139,4 @@ public boolean hasMatchingTransition(RequestContext context) {
public String toString() {
return StylerUtils.style(transitions);
}
-}
+}
View
15 spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java
@@ -16,7 +16,6 @@
package org.springframework.webflow.engine;
import java.io.IOException;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -254,9 +253,7 @@ public void exit(RequestControlContext context) {
// internal helpers
private void createVariables(RequestContext context) {
- Iterator<ViewVariable> it = variables.values().iterator();
- while (it.hasNext()) {
- ViewVariable variable = it.next();
+ for (ViewVariable variable : variables.values()) {
if (logger.isDebugEnabled()) {
logger.debug("Creating " + variable);
}
@@ -308,12 +305,9 @@ private void clearFlash(RequestContext context) {
}
private void restoreVariables(RequestContext context) {
- Iterator<ViewVariable> it = variables.values().iterator();
- while (it.hasNext()) {
- ViewVariable variable = it.next();
+ for (ViewVariable variable : variables.values()) {
if (logger.isDebugEnabled()) {
logger.debug("Restoring " + variable);
-
}
variable.restore(context);
}
@@ -336,12 +330,9 @@ private void updateHistory(RequestControlContext context) {
}
private void destroyVariables(RequestContext context) {
- Iterator<ViewVariable> it = variables.values().iterator();
- while (it.hasNext()) {
- ViewVariable variable = it.next();
+ for (ViewVariable variable : variables.values()) {
if (logger.isDebugEnabled()) {
logger.debug("Destroying " + variable);
-
}
variable.destroy(context);
}
View
5 spring-webflow/src/main/java/org/springframework/webflow/engine/builder/BinderConfiguration.java
@@ -1,6 +1,5 @@
package org.springframework.webflow.engine.builder;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -40,9 +39,7 @@ public void addBinding(Binding binding) {
* @return the binding
*/
public Binding getBinding(String name) {
- Iterator<Binding> it = bindings.iterator();
- while (it.hasNext()) {
- Binding binding = it.next();
+ for (Binding binding : bindings) {
if (name.equals(binding.getProperty())) {
return binding;
}
View
2  spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionImplFactory.java
@@ -170,4 +170,4 @@ public String toString() {
}
}
}
-}
+}
View
60 spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractModel.java
@@ -16,7 +16,6 @@
package org.springframework.webflow.engine.model;
import java.util.Collections;
-import java.util.Iterator;
import java.util.LinkedList;
/**
@@ -92,40 +91,41 @@ protected Model merge(Model child, Model parent) {
* @param addAtEnd if true new items will be added at the end of the list, otherwise the beginning
* @return the merged list
*/
- @SuppressWarnings("unchecked")
protected <T extends Model> LinkedList<T> merge(LinkedList<T> child, LinkedList<T> parent, boolean addAtEnd) {
if (child == null) {
- if (parent == null) {
- return null;
- } else {
- return copyList(parent);
- }
- } else if (parent == null) {
+ return copyList(parent);
+ }
+ if (parent == null) {
return child;
- } else {
- if (!addAtEnd) {
- parent = new LinkedList<T>(parent);
- Collections.reverse(parent);
+ }
+ if (!addAtEnd) {
+ parent = new LinkedList<T>(parent);
+ Collections.reverse(parent);
+ }
+ for (T element : parent) {
+ if (!mergeElement(child, element)) {
+ addElement(child, element, addAtEnd);
}
- for (Iterator<T> parentIt = parent.iterator(); parentIt.hasNext();) {
- Model parentElement = parentIt.next();
- boolean matchFound = false;
- for (Iterator<T> childIt = child.iterator(); !matchFound && childIt.hasNext();) {
- Model childElement = childIt.next();
- if (childElement.isMergeableWith(parentElement)) {
- matchFound = true;
- childElement.merge(parentElement);
- }
- }
- if (!matchFound) {
- if (addAtEnd) {
- child.addLast((T) parentElement.createCopy());
- } else {
- child.addFirst((T) parentElement.createCopy());
- }
- }
+ }
+ return child;
+ }
+
+ private <T extends Model> boolean mergeElement(LinkedList<T> child, T element) {
+ for (T childElement : child) {
+ if (childElement.isMergeableWith(element)) {
+ childElement.merge(element);
+ return true;
}
- return child;
+ }
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T extends Model> void addElement(LinkedList<T> child, T element, boolean addAtEnd) {
+ if (addAtEnd) {
+ child.addLast((T) element.createCopy());
+ } else {
+ child.addFirst((T) element.createCopy());
}
}
View
7 spring-webflow/src/main/java/org/springframework/webflow/engine/support/TransitionCriteriaChain.java
@@ -16,7 +16,6 @@
package org.springframework.webflow.engine.support;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -65,9 +64,7 @@ public TransitionCriteriaChain add(TransitionCriteria criteria) {
}
public boolean test(RequestContext context) {
- Iterator<TransitionCriteria> it = criteriaChain.iterator();
- while (it.hasNext()) {
- TransitionCriteria criteria = it.next();
+ for (TransitionCriteria criteria : criteriaChain) {
if (!criteria.test(context)) {
return false;
}
@@ -95,4 +92,4 @@ public static TransitionCriteria criteriaChainFor(Action[] actions) {
}
return chain;
}
-}
+}
View
7 .../src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerHolder.java
@@ -15,7 +15,6 @@
*/
package org.springframework.webflow.execution.factory;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -88,13 +87,11 @@ public boolean isCriteriaSetEmpty() {
* @return true if yes, false otherwise
*/
public boolean listenerAppliesTo(FlowDefinition flowDefinition) {
- Iterator<FlowExecutionListenerCriteria> it = criteriaSet.iterator();
- while (it.hasNext()) {
- FlowExecutionListenerCriteria criteria = it.next();
+ for (FlowExecutionListenerCriteria criteria : criteriaSet) {
if (criteria.appliesTo(flowDefinition)) {
return true;
}
}
return false;
}
-}
+}
View
11 .../src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerLoader.java
@@ -15,7 +15,6 @@
*/
package org.springframework.webflow.execution.factory;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -98,13 +97,11 @@ public void addListener(FlowExecutionListener listener, FlowExecutionListenerCri
* @return the holder, or null if not found
*/
private ConditionalFlowExecutionListenerHolder getHolder(FlowExecutionListener listener) {
- Iterator<ConditionalFlowExecutionListenerHolder> it = listeners.iterator();
- while (it.hasNext()) {
- ConditionalFlowExecutionListenerHolder next = it.next();
- if (next.getListener().equals(listener)) {
- return next;
+ for (ConditionalFlowExecutionListenerHolder holder : listeners) {
+ if (holder.getListener().equals(listener)) {
+ return holder;
}
}
return null;
}
-}
+}
View
12 spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/FlowHandlerAdapter.java
@@ -15,7 +15,6 @@
*/
package org.springframework.webflow.mvc.portlet;
-import java.util.Iterator;
import java.util.Map;
import javax.portlet.ActionRequest;
@@ -194,16 +193,9 @@ protected PortletExternalContext createPortletExternalContext(PortletRequest req
return null;
}
LocalAttributeMap<Object> inputMap = new LocalAttributeMap<Object>();
- Iterator<Map.Entry<String, String[]>> it = parameterMap.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry<String, String[]> entry = it.next();
- String name = entry.getKey();
+ for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
String[] values = entry.getValue();
- if (values.length == 1) {
- inputMap.put(name, values[0]);
- } else {
- inputMap.put(name, values);
- }
+ inputMap.put(entry.getKey(), values.length == 1 ? values[0] : values);
}
return inputMap;
}
View
13 spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapter.java
@@ -16,9 +16,7 @@
package org.springframework.webflow.mvc.servlet;
import java.io.IOException;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -241,16 +239,9 @@ protected String defaultGetFlowId(HttpServletRequest request) {
return null;
}
LocalAttributeMap<Object> inputMap = new LocalAttributeMap<Object>(parameterMap.size(), 1);
- Iterator<Map.Entry<String, String[]>> it = parameterMap.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, String[]> entry = it.next();
- String name = entry.getKey();
+ for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
String[] values = entry.getValue();
- if (values.length == 1) {
- inputMap.put(name, values[0]);
- } else {
- inputMap.put(name, values);
- }
+ inputMap.put(entry.getKey(), values.length == 1 ? values[0] : values);
}
return inputMap;
}
View
5 spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java
@@ -19,7 +19,6 @@
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -387,9 +386,7 @@ protected MappingResults bind(Object model) {
* @param model the model
*/
protected void addModelBindings(DefaultMapper mapper, Set<String> parameterNames, Object model) {
- Iterator<Binding> it = binderConfiguration.getBindings().iterator();
- while (it.hasNext()) {
- Binding binding = it.next();
+ for (Binding binding : binderConfiguration.getBindings()) {
String parameterName = binding.getProperty();
if (parameterNames.contains(parameterName)) {
addMapping(mapper, binding, model);
View
6 spring-webflow/src/main/java/org/springframework/webflow/security/SecurityFlowExecutionListener.java
@@ -17,7 +17,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import org.springframework.security.access.AccessDecisionManager;
@@ -118,9 +117,8 @@ protected void decide(SecurityRule rule, Object object) {
*/
protected Collection<ConfigAttribute> getConfigAttributes(SecurityRule rule) {
List<ConfigAttribute> configAttributes = new ArrayList<ConfigAttribute>();
- Iterator<String> attributeIt = rule.getAttributes().iterator();
- while (attributeIt.hasNext()) {
- configAttributes.add(new SecurityConfig(attributeIt.next()));
+ for (String attribute : rule.getAttributes()) {
+ configAttributes.add(new SecurityConfig(attribute));
}
return configAttributes;
}
View
19 spring-webflow/src/main/java/org/springframework/webflow/security/SecurityRule.java
@@ -15,10 +15,10 @@
*/
package org.springframework.webflow.security;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
+
+import org.springframework.util.StringUtils;
/**
* Encapsulates the rules for comparing security attributes
@@ -52,15 +52,7 @@
* @return comma separated String
*/
public static String securityAttributesToCommaDelimitedList(Collection<?> attributes) {
- StringBuilder attrs = new StringBuilder();
- Iterator<?> attributeIt = attributes.iterator();
- while (attributeIt.hasNext()) {
- if (attrs.length() != 0) {
- attrs.append(", ");
- }
- attrs.append(attributeIt.next());
- }
- return attrs.toString();
+ return StringUtils.collectionToDelimitedString(attributes, ", ");
}
/**
@@ -70,9 +62,8 @@ public static String securityAttributesToCommaDelimitedList(Collection<?> attrib
*/
public static Collection<String> commaDelimitedListToSecurityAttributes(String attributes) {
Collection<String> attrs = new HashSet<String>();
- Iterator<String> attributeIt = Arrays.asList(attributes.split(",")).iterator();
- while (attributeIt.hasNext()) {
- String attribute = attributeIt.next().trim();
+ for (String attribute : attributes.split(",")) {
+ attribute = attribute.trim();
if (!"".equals(attribute)) {
attrs.add(attribute);
}
View
6 spring-webflow/src/test/java/org/springframework/webflow/config/FlowRegistryBeanDefinitionParserTests.java
@@ -1,6 +1,5 @@
package org.springframework.webflow.config;
-import java.util.Iterator;
import java.util.Map;
import junit.framework.TestCase;
@@ -58,10 +57,7 @@ public void testRegistryFlowBuildersPopulatedWithAttributes() {
public void testDefaultFlowBuilderServices() {
Map<String, FlowBuilderServices> flowBuilderServicesBeans = context.getBeansOfType(FlowBuilderServices.class);
assertTrue(flowBuilderServicesBeans.size() > 0);
-
- Iterator<FlowBuilderServices> i = flowBuilderServicesBeans.values().iterator();
- while (i.hasNext()) {
- FlowBuilderServices builderServices = i.next();
+ for (FlowBuilderServices builderServices : flowBuilderServicesBeans.values()) {
assertNotNull(builderServices);
assertTrue(builderServices.getExpressionParser() instanceof SpringELExpressionParser);
assertTrue(builderServices.getViewFactoryCreator() instanceof MvcViewFactoryCreator);
Please sign in to comment.
Something went wrong with that request. Please try again.