summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorPer-Åke Minborg <minborg@speedment.com>2016-10-28 23:03:46 -0700
committerHenri Sara <hesara@vaadin.com>2016-11-05 04:35:59 +0200
commita7f33a05e76e575fe838fba3eeaa1b1e17be5e86 (patch)
tree6767e6911cf0027f5c85a3107d3cecf839d38972 /server
parenta1af515897aef4dcd95cef4b11db4d651247b5e7 (diff)
downloadvaadin-framework-a7f33a05e76e575fe838fba3eeaa1b1e17be5e86.tar.gz
vaadin-framework-a7f33a05e76e575fe838fba3eeaa1b1e17be5e86.zip
Replace implicit for-loop with foreach
Change-Id: I80b73b653e97904605dc62484a7448f3bfbf7233
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/server/ComponentSizeValidator.java5
-rw-r--r--server/src/main/java/com/vaadin/server/CompositeErrorMessage.java10
-rw-r--r--server/src/main/java/com/vaadin/server/Page.java9
-rw-r--r--server/src/main/java/com/vaadin/server/VaadinServlet.java6
-rw-r--r--server/src/main/java/com/vaadin/server/communication/ResourceWriter.java12
-rw-r--r--server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/CssLayout.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/CustomLayout.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/GridLayout.java9
-rw-r--r--server/src/main/java/com/vaadin/ui/TabSheet.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/Window.java3
13 files changed, 30 insertions, 59 deletions
diff --git a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java
index a4981a94b9..da8231eec9 100644
--- a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java
+++ b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java
@@ -518,9 +518,8 @@ public class ComponentSizeValidator implements Serializable {
*/
private static boolean formHasNonRelativeWidthComponent(Component form) {
HasComponents parent = (HasComponents) form;
- for (Iterator<Component> iterator = parent.iterator(); iterator
- .hasNext();) {
- if (!hasRelativeWidth(iterator.next())) {
+ for (Component aParent : parent) {
+ if (!hasRelativeWidth(aParent)) {
return true;
}
}
diff --git a/server/src/main/java/com/vaadin/server/CompositeErrorMessage.java b/server/src/main/java/com/vaadin/server/CompositeErrorMessage.java
index f96bcbac27..6d6a775a1b 100644
--- a/server/src/main/java/com/vaadin/server/CompositeErrorMessage.java
+++ b/server/src/main/java/com/vaadin/server/CompositeErrorMessage.java
@@ -62,9 +62,8 @@ public class CompositeErrorMessage extends AbstractErrorMessage {
super(null);
setErrorLevel(ErrorLevel.INFORMATION);
- for (final Iterator<? extends ErrorMessage> i = errorMessages
- .iterator(); i.hasNext();) {
- addErrorMessage(i.next());
+ for (ErrorMessage errorMessage : errorMessages) {
+ addErrorMessage(errorMessage);
}
if (getCauses().isEmpty()) {
@@ -107,13 +106,12 @@ public class CompositeErrorMessage extends AbstractErrorMessage {
public String toString() {
String retval = "[";
int pos = 0;
- for (final Iterator<ErrorMessage> i = getCauses().iterator(); i
- .hasNext();) {
+ for (ErrorMessage errorMessage : getCauses()) {
if (pos > 0) {
retval += ",";
}
pos++;
- retval += i.next().toString();
+ retval += errorMessage.toString();
}
retval += "]";
diff --git a/server/src/main/java/com/vaadin/server/Page.java b/server/src/main/java/com/vaadin/server/Page.java
index 35fc6b96e8..d4eb2432f0 100644
--- a/server/src/main/java/com/vaadin/server/Page.java
+++ b/server/src/main/java/com/vaadin/server/Page.java
@@ -821,9 +821,8 @@ public class Page implements Serializable {
public void paintContent(PaintTarget target) throws PaintException {
if (!openList.isEmpty()) {
- for (final Iterator<OpenResource> i = openList.iterator(); i
- .hasNext();) {
- (i.next()).paintContent(target);
+ for (OpenResource anOpenList : openList) {
+ (anOpenList).paintContent(target);
}
openList.clear();
}
@@ -831,9 +830,7 @@ public class Page implements Serializable {
// Paint notifications
if (notifications != null) {
target.startTag("notifications");
- for (final Iterator<Notification> it = notifications.iterator(); it
- .hasNext();) {
- final Notification n = it.next();
+ for (final Notification n : notifications) {
target.startTag("notification");
if (n.getCaption() != null) {
target.addAttribute(
diff --git a/server/src/main/java/com/vaadin/server/VaadinServlet.java b/server/src/main/java/com/vaadin/server/VaadinServlet.java
index 13713dcc54..b3fa527360 100644
--- a/server/src/main/java/com/vaadin/server/VaadinServlet.java
+++ b/server/src/main/java/com/vaadin/server/VaadinServlet.java
@@ -661,8 +661,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
public static String stripSpecialChars(String themeName) {
StringBuilder sb = new StringBuilder();
char[] charArray = themeName.toCharArray();
- for (int i = 0; i < charArray.length; i++) {
- char c = charArray[i];
+ for (char c : charArray) {
if (!CHAR_BLACKLIST.contains(c)) {
sb.append(c);
}
@@ -1451,8 +1450,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
StringBuilder safe = new StringBuilder();
char[] charArray = unsafe.toCharArray();
- for (int i = 0; i < charArray.length; i++) {
- char c = charArray[i];
+ for (char c : charArray) {
if (isSafe(c)) {
safe.append(c);
} else {
diff --git a/server/src/main/java/com/vaadin/server/communication/ResourceWriter.java b/server/src/main/java/com/vaadin/server/communication/ResourceWriter.java
index be83bf7185..2cfc489c11 100644
--- a/server/src/main/java/com/vaadin/server/communication/ResourceWriter.java
+++ b/server/src/main/java/com/vaadin/server/communication/ResourceWriter.java
@@ -21,7 +21,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.io.Writer;
-import java.util.Iterator;
+import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -29,7 +29,6 @@ import com.vaadin.server.JsonPaintTarget;
import com.vaadin.server.LegacyCommunicationManager;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.UI;
-import java.nio.charset.StandardCharsets;
/**
* Serializes resources to JSON. Currently only used for {@link CustomLayout}
@@ -65,9 +64,8 @@ public class ResourceWriter implements Serializable {
writer.write("{");
int resourceIndex = 0;
- for (final Iterator<Object> i = target.getUsedResources().iterator(); i
- .hasNext();) {
- final String resource = (String) i.next();
+ for (Object o : target.getUsedResources()) {
+ final String resource = (String) o;
InputStream is = null;
try {
is = ui.getSession().getService().getThemeResourceAsStream(ui,
@@ -84,13 +82,13 @@ public class ResourceWriter implements Serializable {
final StringBuffer layout = new StringBuffer();
try (InputStreamReader r = new InputStreamReader(is,
- StandardCharsets.UTF_8)) {
+ StandardCharsets.UTF_8)) {
final char[] buffer = new char[20000];
int charsRead = 0;
while ((charsRead = r.read(buffer)) > 0) {
layout.append(buffer, 0, charsRead);
}
- } catch (final java.io.IOException e) {
+ } catch (final IOException e) {
// FIXME: Handle exception
getLogger().log(Level.INFO, "Resource transfer failed", e);
}
diff --git a/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java
index 4e7bc93713..5e5fd8a81e 100644
--- a/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java
+++ b/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java
@@ -348,17 +348,15 @@ public class ServerRpcHandler implements Serializable {
}
}
- for (int i = 0; i < invocations.size(); i++) {
- MethodInvocation invocation = invocations.get(i);
-
+ for (MethodInvocation invocation : invocations) {
final ClientConnector connector = connectorTracker
.getConnector(invocation.getConnectorId());
if (connector == null) {
getLogger().log(Level.WARNING,
"Received RPC call for unknown connector with id {0} (tried to invoke {1}.{2})",
- new Object[] { invocation.getConnectorId(),
+ new Object[]{invocation.getConnectorId(),
invocation.getInterfaceName(),
- invocation.getMethodName() });
+ invocation.getMethodName()});
continue;
}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java b/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java
index 8c10027cc4..9740dff68a 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java
@@ -72,8 +72,8 @@ public abstract class AbstractComponentContainer extends AbstractComponent
}
// Removes all component
- for (final Iterator<Component> i = l.iterator(); i.hasNext();) {
- removeComponent(i.next());
+ for (Component aL : l) {
+ removeComponent(aL);
}
}
@@ -90,9 +90,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
components.add(i.next());
}
- for (final Iterator<Component> i = components.iterator(); i
- .hasNext();) {
- final Component c = i.next();
+ for (final Component c : components) {
source.removeComponent(c);
addComponent(c);
}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
index 3ab5e32d18..f4fadeacfb 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
@@ -211,10 +211,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout
int oldLocation = -1;
int newLocation = -1;
int location = 0;
- for (final Iterator<Component> i = components.iterator(); i
- .hasNext();) {
- final Component component = i.next();
-
+ for (final Component component : components) {
if (component == oldComponent) {
oldLocation = location;
}
diff --git a/server/src/main/java/com/vaadin/ui/CssLayout.java b/server/src/main/java/com/vaadin/ui/CssLayout.java
index d4daf67419..da88a442a7 100644
--- a/server/src/main/java/com/vaadin/ui/CssLayout.java
+++ b/server/src/main/java/com/vaadin/ui/CssLayout.java
@@ -268,10 +268,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
int oldLocation = -1;
int newLocation = -1;
int location = 0;
- for (final Iterator<Component> i = components.iterator(); i
- .hasNext();) {
- final Component component = i.next();
-
+ for (final Component component : components) {
if (component == oldComponent) {
oldLocation = location;
}
diff --git a/server/src/main/java/com/vaadin/ui/CustomLayout.java b/server/src/main/java/com/vaadin/ui/CustomLayout.java
index 179969765d..d7cbcee962 100644
--- a/server/src/main/java/com/vaadin/ui/CustomLayout.java
+++ b/server/src/main/java/com/vaadin/ui/CustomLayout.java
@@ -236,9 +236,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
// Gets the locations
String oldLocation = null;
String newLocation = null;
- for (final Iterator<String> i = slots.keySet().iterator(); i
- .hasNext();) {
- final String location = i.next();
+ for (final String location : slots.keySet()) {
final Component component = slots.get(location);
if (component == oldComponent) {
oldLocation = location;
diff --git a/server/src/main/java/com/vaadin/ui/GridLayout.java b/server/src/main/java/com/vaadin/ui/GridLayout.java
index a634e47cf3..81f14a4f1b 100644
--- a/server/src/main/java/com/vaadin/ui/GridLayout.java
+++ b/server/src/main/java/com/vaadin/ui/GridLayout.java
@@ -412,9 +412,7 @@ public class GridLayout extends AbstractLayout
public void removeComponent(int column, int row) {
// Finds the area
- for (final Iterator<Component> i = components.iterator(); i
- .hasNext();) {
- final Component component = i.next();
+ for (final Component component : components) {
final ChildComponentData childData = getState().childData
.get(component);
if (childData.column1 == column && childData.row1 == row) {
@@ -480,9 +478,8 @@ public class GridLayout extends AbstractLayout
private float getExpandRatioSum(Map<Integer, Float> ratioMap) {
float sum = 0;
- for (Iterator<Entry<Integer, Float>> iterator = ratioMap.entrySet()
- .iterator(); iterator.hasNext();) {
- sum += iterator.next().getValue();
+ for (Float expandRatio : ratioMap.values()) {
+ sum += expandRatio;
}
return sum;
}
diff --git a/server/src/main/java/com/vaadin/ui/TabSheet.java b/server/src/main/java/com/vaadin/ui/TabSheet.java
index 91bb3a61fc..12d8bdf683 100644
--- a/server/src/main/java/com/vaadin/ui/TabSheet.java
+++ b/server/src/main/java/com/vaadin/ui/TabSheet.java
@@ -710,10 +710,7 @@ public class TabSheet extends AbstractComponentContainer
int newLocation = -1;
int location = 0;
- for (final Iterator<Component> i = components.iterator(); i
- .hasNext();) {
- final Component component = i.next();
-
+ for (final Component component : components) {
if (component == oldComponent) {
oldLocation = location;
}
diff --git a/server/src/main/java/com/vaadin/ui/Window.java b/server/src/main/java/com/vaadin/ui/Window.java
index 318f48548d..f91d61d908 100644
--- a/server/src/main/java/com/vaadin/ui/Window.java
+++ b/server/src/main/java/com/vaadin/ui/Window.java
@@ -854,8 +854,7 @@ public class Window extends Panel
*/
@Deprecated
public void removeCloseShortcut() {
- for (int i = 0; i < closeShortcuts.size(); ++i) {
- CloseShortcut sc = closeShortcuts.get(i);
+ for (CloseShortcut sc : closeShortcuts) {
removeAction(sc);
}
closeShortcuts.clear();