Replace use of Iterator with Java 5 foreach loops

Issues: SWF-1532
This commit is contained in:
Phillip Webb
2012-04-05 15:52:09 -07:00
parent 22b018e95a
commit 34f4837ebd
35 changed files with 113 additions and 255 deletions

View File

@@ -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() {

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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();
}