Replace use of Iterator with Java 5 foreach loops
Issues: SWF-1532
This commit is contained in:
@@ -19,7 +19,6 @@ import java.lang.reflect.Array;
|
||||
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 class ArrayToCollection implements TwoWayConverter {
|
||||
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 class ArrayToCollection implements TwoWayConverter {
|
||||
}
|
||||
value = converter.execute(value);
|
||||
}
|
||||
Array.set(array, i, value);
|
||||
Array.set(array, i++, value);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
@@ -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 class CollectionToCollection implements Converter {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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 class DefaultELResolver extends CompositeELResolver {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 class DefaultMapper implements Mapper {
|
||||
+ 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();
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.binding.mapping.impl;
|
||||
|
||||
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 class DefaultMappingResults implements MappingResults {
|
||||
}
|
||||
|
||||
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 class DefaultMappingResults implements MappingResults {
|
||||
|
||||
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 class DefaultMappingResults implements MappingResults {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.binding.message;
|
||||
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 class DefaultMessageContext implements StateManageableMessageContext {
|
||||
|
||||
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 class DefaultMessageContext implements StateManageableMessageContext {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.binding.message;
|
||||
|
||||
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 class MessageContextErrors extends AbstractErrors {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.faces.mvc;
|
||||
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 @@ public class JsfView extends AbstractUrlBasedView {
|
||||
}
|
||||
|
||||
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() {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.faces.ui;
|
||||
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 @@ public class AjaxViewRoot extends DelegatingViewRoot {
|
||||
}
|
||||
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();
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.ArrayList;
|
||||
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 @@ import org.springframework.util.StringUtils;
|
||||
* {@link Renderer} for the {@code <sf:commandButton>} tag.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*
|
||||
*/
|
||||
public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer {
|
||||
|
||||
@@ -46,17 +44,13 @@ public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer
|
||||
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;
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.ArrayList;
|
||||
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 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
|
||||
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;
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.io.IOException;
|
||||
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 class ResourceHelper {
|
||||
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);
|
||||
|
||||
@@ -95,9 +95,9 @@ public class FlowFacesContextMessageDelegate {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -196,9 +196,7 @@ public class AjaxTilesView extends TilesView {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.net.URLConnection;
|
||||
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 @@ public class ResourceServlet extends HttpServletBean {
|
||||
|
||||
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 @@ public class ResourceServlet extends HttpServletBean {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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 @@ class FlowExecutionListenerLoaderFactoryBean implements FactoryBean<FlowExecutio
|
||||
|
||||
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));
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.io.ObjectOutputStream;
|
||||
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 class LocalAttributeMap<V> implements MutableAttributeMap<V>, Serializabl
|
||||
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 @@ public class LocalAttributeMap<V> implements MutableAttributeMap<V>, Serializabl
|
||||
public String toString() {
|
||||
return StylerUtils.style(attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry {
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
Iterator<FlowDefinitionHolder> it = flowDefinitions.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
FlowDefinitionHolder holder = it.next();
|
||||
for (FlowDefinitionHolder holder : flowDefinitions.values()) {
|
||||
holder.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,13 +150,12 @@ public class ActionList implements Iterable<Action> {
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 class Flow extends AnnotatedObject implements FlowDefinition {
|
||||
* @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 class Flow extends AnnotatedObject implements FlowDefinition {
|
||||
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 class Flow extends AnnotatedObject implements FlowDefinition {
|
||||
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 @@ public class Flow extends AnnotatedObject implements FlowDefinition {
|
||||
}
|
||||
|
||||
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 @@ public class Flow extends AnnotatedObject implements FlowDefinition {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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 class FlowExecutionExceptionHandlerSet {
|
||||
* @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 class FlowExecutionExceptionHandlerSet {
|
||||
public String toString() {
|
||||
return StylerUtils.style(exceptionHandlers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,9 +108,8 @@ public class TransitionSet implements Iterable<Transition> {
|
||||
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 class TransitionSet implements Iterable<Transition> {
|
||||
* @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 class TransitionSet implements Iterable<Transition> {
|
||||
public String toString() {
|
||||
return StylerUtils.style(transitions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 class ViewState extends TransitionableState {
|
||||
// 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 @@ public class ViewState extends TransitionableState {
|
||||
}
|
||||
|
||||
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 @@ public class ViewState extends TransitionableState {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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 class BinderConfiguration {
|
||||
* @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;
|
||||
}
|
||||
|
||||
@@ -170,4 +170,4 @@ public class FlowExecutionImplFactory implements FlowExecutionFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 @@ public abstract class AbstractModel implements Model {
|
||||
* @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;
|
||||
}
|
||||
if (!addAtEnd) {
|
||||
parent = new LinkedList<T>(parent);
|
||||
Collections.reverse(parent);
|
||||
}
|
||||
for (T element : parent) {
|
||||
if (!mergeElement(child, element)) {
|
||||
addElement(child, element, addAtEnd);
|
||||
}
|
||||
}
|
||||
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 false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends Model> void addElement(LinkedList<T> child, T element, boolean addAtEnd) {
|
||||
if (addAtEnd) {
|
||||
child.addLast((T) element.createCopy());
|
||||
} else {
|
||||
if (!addAtEnd) {
|
||||
parent = new LinkedList<T>(parent);
|
||||
Collections.reverse(parent);
|
||||
}
|
||||
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;
|
||||
child.addFirst((T) element.createCopy());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 class TransitionCriteriaChain implements TransitionCriteria {
|
||||
}
|
||||
|
||||
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 class TransitionCriteriaChain implements TransitionCriteria {
|
||||
}
|
||||
return chain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 @@ class ConditionalFlowExecutionListenerHolder {
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 class ConditionalFlowExecutionListenerLoader implements FlowExecutionList
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 @@ public class FlowHandlerAdapter extends PortletContentGenerator implements Handl
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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 @@ public class FlowHandlerAdapter extends WebContentGenerator implements HandlerAd
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.io.IOException;
|
||||
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 @@ public abstract class AbstractMvcView implements View {
|
||||
* @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);
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.webflow.security;
|
||||
|
||||
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 @@ public class SecurityFlowExecutionListener extends FlowExecutionListenerAdapter
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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 @@ public class SecurityRule {
|
||||
* @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 class SecurityRule {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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 class FlowRegistryBeanDefinitionParserTests extends TestCase {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user