aboutsummaryrefslogtreecommitdiffstats
path: root/compatibility-server/src
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-10-02 11:43:19 +0200
committerHenri Sara <henri.sara@gmail.com>2017-10-02 12:43:19 +0300
commit7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce (patch)
tree9351fb5d91124db9935f684da60bdb74ef01881d /compatibility-server/src
parent43f4a17f0d17e584e83ea3faaa40ac1def1dd4b1 (diff)
downloadvaadin-framework-7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce.tar.gz
vaadin-framework-7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce.zip
Use enhanced for loop for arrays. (#10121)
Diffstat (limited to 'compatibility-server/src')
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java9
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractContainer.java10
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java10
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerHierarchicalWrapper.java4
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java30
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java5
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java10
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java20
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java4
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java5
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java5
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java15
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java38
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java15
14 files changed, 82 insertions, 98 deletions
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java
index f13a01a5b5..bbe184de86 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java
@@ -52,8 +52,9 @@ import com.vaadin.shared.ui.ErrorLevel;
*
* @author Vaadin Ltd.
* @since 3.0
- * @deprecated As of 8.0, replaced by {@link com.vaadin.data.Validator}. The validation is performed
- * outside components, see {@link Binder}.{@code withValidator(...)}
+ * @deprecated As of 8.0, replaced by {@link com.vaadin.data.Validator}. The
+ * validation is performed outside components, see
+ * {@link Binder}.{@code withValidator(...)}
*/
@Deprecated
public interface Validator extends Serializable {
@@ -140,8 +141,8 @@ public interface Validator extends Serializable {
return false;
}
if (causes != null) {
- for (int i = 0; i < causes.length; i++) {
- if (!causes[i].isInvisible()) {
+ for (InvalidValueException e : causes) {
+ if (!e.isInvisible()) {
return false;
}
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractContainer.java
index ec5138d063..81d91c0d01 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractContainer.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractContainer.java
@@ -220,9 +220,8 @@ public abstract class AbstractContainer implements Container {
protected void fireContainerPropertySetChange(
Container.PropertySetChangeEvent event) {
if (getPropertySetChangeListeners() != null) {
- final Object[] l = getPropertySetChangeListeners().toArray();
- for (int i = 0; i < l.length; i++) {
- ((Container.PropertySetChangeListener) l[i])
+ for (Object l : getPropertySetChangeListeners().toArray()) {
+ ((Container.PropertySetChangeListener) l)
.containerPropertySetChange(event);
}
}
@@ -246,9 +245,8 @@ public abstract class AbstractContainer implements Container {
*/
protected void fireItemSetChange(ItemSetChangeEvent event) {
if (getItemSetChangeListeners() != null) {
- final Object[] l = getItemSetChangeListeners().toArray();
- for (int i = 0; i < l.length; i++) {
- ((Container.ItemSetChangeListener) l[i])
+ for (Object l : getItemSetChangeListeners().toArray()) {
+ ((Container.ItemSetChangeListener) l)
.containerItemSetChange(event);
}
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java
index 54959822a7..77d837d200 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java
@@ -164,11 +164,10 @@ public abstract class AbstractProperty<T> implements Property<T>,
*/
protected void fireReadOnlyStatusChange() {
if (readOnlyStatusChangeListeners != null) {
- final Object[] l = readOnlyStatusChangeListeners.toArray();
final Property.ReadOnlyStatusChangeEvent event = new ReadOnlyStatusChangeEvent(
this);
- for (int i = 0; i < l.length; i++) {
- ((Property.ReadOnlyStatusChangeListener) l[i])
+ for (Object l : readOnlyStatusChangeListeners.toArray()) {
+ ((Property.ReadOnlyStatusChangeListener) l)
.readOnlyStatusChange(event);
}
}
@@ -245,10 +244,9 @@ public abstract class AbstractProperty<T> implements Property<T>,
*/
protected void fireValueChange() {
if (valueChangeListeners != null) {
- final Object[] l = valueChangeListeners.toArray();
final Property.ValueChangeEvent event = new ValueChangeEvent(this);
- for (int i = 0; i < l.length; i++) {
- ((Property.ValueChangeListener) l[i]).valueChange(event);
+ for (Object l : valueChangeListeners.toArray()) {
+ ((Property.ValueChangeListener) l).valueChange(event);
}
}
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerHierarchicalWrapper.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerHierarchicalWrapper.java
index e9f160dedd..de605a9ed6 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerHierarchicalWrapper.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerHierarchicalWrapper.java
@@ -184,8 +184,8 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical,
Object[] array = roots.toArray();
Arrays.sort(array, basedOnOrderFromWrappedContainer);
roots = new LinkedHashSet<Object>();
- for (int i = 0; i < array.length; i++) {
- roots.add(array[i]);
+ for (Object root : array) {
+ roots.add(root);
}
for (Object object : children.keySet()) {
LinkedList<Object> object2 = children.get(object);
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java
index 9fca1061fd..4ae90a7569 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java
@@ -278,8 +278,8 @@ public class FilesystemContainer implements Container.Hierarchical {
if (!(itemId instanceof File)) {
return false;
}
- for (int i = 0; i < roots.length; i++) {
- if (roots[i].equals(itemId)) {
+ for (File root : roots) {
+ if (root.equals(itemId)) {
return true;
}
}
@@ -374,10 +374,10 @@ public class FilesystemContainer implements Container.Hierarchical {
boolean val = false;
// Try to match all roots
- for (int i = 0; i < roots.length; i++) {
+ for (File root : roots) {
try {
val |= ((File) itemId).getCanonicalPath()
- .startsWith(roots[i].getCanonicalPath());
+ .startsWith(root.getCanonicalPath());
} catch (final IOException e) {
// Exception ignored
}
@@ -444,8 +444,8 @@ public class FilesystemContainer implements Container.Hierarchical {
if (recursive) {
final Collection<File> col = new ArrayList<File>();
- for (int i = 0; i < roots.length; i++) {
- addItemIds(col, roots[i]);
+ for (File root : roots) {
+ addItemIds(col, root);
}
return Collections.unmodifiableCollection(col);
} else {
@@ -554,24 +554,24 @@ public class FilesystemContainer implements Container.Hierarchical {
* Internal method to recursively calculate the number of files under a root
* directory.
*
- * @param f
+ * @param directory
* the root to start counting from.
*/
- private int getFileCounts(File f) {
+ private int getFileCounts(File directory) {
File[] l;
if (filter != null) {
- l = f.listFiles(filter);
+ l = directory.listFiles(filter);
} else {
- l = f.listFiles();
+ l = directory.listFiles();
}
if (l == null) {
return 0;
}
int ret = l.length;
- for (int i = 0; i < l.length; i++) {
- if (l[i].isDirectory()) {
- ret += getFileCounts(l[i]);
+ for (File f : l) {
+ if (f.isDirectory()) {
+ ret += getFileCounts(f);
}
}
return ret;
@@ -588,8 +588,8 @@ public class FilesystemContainer implements Container.Hierarchical {
if (recursive) {
int counts = 0;
- for (int i = 0; i < roots.length; i++) {
- counts += getFileCounts(roots[i]);
+ for (File f : roots) {
+ counts += getFileCounts(f);
}
return counts;
} else {
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java
index aa504409db..da6ff62b92 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java
@@ -615,10 +615,9 @@ public class HierarchicalContainer extends IndexedContainer
boolean success = true;
Collection<?> children2 = container.getChildren(itemId);
if (children2 != null) {
- Object[] array = children2.toArray();
- for (int i = 0; i < array.length; i++) {
+ for (Object o : children2.toArray()) {
boolean removeItemRecursively = removeItemRecursively(container,
- array[i]);
+ o);
if (!removeItemRecursively) {
success = false;
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java
index bd74a132b0..98f2deecac 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java
@@ -526,11 +526,10 @@ public class IndexedContainer
// Sends event to listeners listening all value changes
if (propertyValueChangeListeners != null) {
- final Object[] l = propertyValueChangeListeners.toArray();
final Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent(
source);
- for (int i = 0; i < l.length; i++) {
- ((Property.ValueChangeListener) l[i]).valueChange(event);
+ for (Object l : propertyValueChangeListeners.toArray()) {
+ ((Property.ValueChangeListener) l).valueChange(event);
}
}
@@ -544,9 +543,8 @@ public class IndexedContainer
if (listenerList != null) {
final Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent(
source);
- Object[] listeners = listenerList.toArray();
- for (int i = 0; i < listeners.length; i++) {
- ((Property.ValueChangeListener) listeners[i])
+ for (Object listener : listenerList.toArray()) {
+ ((Property.ValueChangeListener) listener)
.valueChange(event);
}
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java
index f2fab292af..8b44785e93 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java
@@ -351,26 +351,26 @@ public class MethodProperty<T> extends AbstractProperty<T> {
this.type = type;
// Find set and get -methods
- final Method[] m = instance.getClass().getMethods();
+ final Method[] methods = instance.getClass().getMethods();
// Finds get method
boolean found = false;
- for (int i = 0; i < m.length; i++) {
+ for (Method m : methods) {
// Tests the name of the get Method
- if (!m[i].getName().equals(getMethodName)) {
+ if (!m.getName().equals(getMethodName)) {
// name does not match, try next method
continue;
}
// Tests return type
- if (!type.equals(m[i].getReturnType())) {
+ if (!type.equals(m.getReturnType())) {
continue;
}
// Tests the parameter types
- final Class<?>[] c = m[i].getParameterTypes();
+ final Class<?>[] c = m.getParameterTypes();
if (c.length != getArgs.length) {
// not the right amount of parameters, try next method
@@ -395,7 +395,7 @@ public class MethodProperty<T> extends AbstractProperty<T> {
+ "-method");
} else {
found = true;
- getMethod = m[i];
+ getMethod = m;
}
}
}
@@ -409,17 +409,17 @@ public class MethodProperty<T> extends AbstractProperty<T> {
// Finds setMethod
found = false;
- for (int i = 0; i < m.length; i++) {
+ for (Method m : methods) {
// Checks name
- if (!m[i].getName().equals(setMethodName)) {
+ if (!m.getName().equals(setMethodName)) {
// name does not match, try next method
continue;
}
// Checks parameter compatibility
- final Class<?>[] c = m[i].getParameterTypes();
+ final Class<?>[] c = m.getParameterTypes();
if (c.length != setArgs.length) {
// not the right amount of parameters, try next method
@@ -448,7 +448,7 @@ public class MethodProperty<T> extends AbstractProperty<T> {
+ "-method");
} else {
found = true;
- setMethod = m[i];
+ setMethod = m;
}
}
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java
index 48052a7671..4228f04dcb 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java
@@ -144,8 +144,8 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> {
throw new IllegalArgumentException(
"Invalid property name '" + propertyName + "'");
}
- for (int i = 0; i < simplePropertyNames.length; i++) {
- String simplePropertyName = simplePropertyNames[i].trim();
+ for (String simplePropertyName : simplePropertyNames) {
+ simplePropertyName = simplePropertyName.trim();
if (!simplePropertyName.isEmpty()) {
lastSimplePropertyName = simplePropertyName;
lastClass = propertyClass;
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java
index 81eb4eb00d..d7be9c54e8 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java
@@ -259,11 +259,10 @@ public class PropertysetItem
*/
private void fireItemPropertySetChange() {
if (propertySetChangeListeners != null) {
- final Object[] l = propertySetChangeListeners.toArray();
final Item.PropertySetChangeEvent event = new PropertysetItem.PropertySetChangeEvent(
this);
- for (int i = 0; i < l.length; i++) {
- ((Item.PropertySetChangeListener) l[i])
+ for (Object l : propertySetChangeListeners.toArray()) {
+ ((Item.PropertySetChangeListener) l)
.itemPropertySetChange(event);
}
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java
index 7591ca7a75..e8c6f99c90 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java
@@ -1460,11 +1460,10 @@ public class SQLContainer implements Container, Container.Filterable,
protected void fireContentsChange() {
if (itemSetChangeListeners != null) {
- final Object[] l = itemSetChangeListeners.toArray();
final Container.ItemSetChangeEvent event = new SQLContainer.ItemSetChangeEvent(
this);
- for (int i = 0; i < l.length; i++) {
- ((Container.ItemSetChangeListener) l[i])
+ for (Object l : itemSetChangeListeners.toArray()) {
+ ((Container.ItemSetChangeListener) l)
.containerItemSetChange(event);
}
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java
index 620a29f83a..f23326e4f3 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java
@@ -479,9 +479,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
// Converts the key-array to id-set
final LinkedList<Object> acceptedSelections = new LinkedList<Object>();
- for (int i = 0; i < clientSideSelectedKeys.length; i++) {
- final Object id = itemIdMapper
- .get(clientSideSelectedKeys[i]);
+ for (String key : clientSideSelectedKeys) {
+ final Object id = itemIdMapper.get(key);
if (!isNullSelectionAllowed()
&& (id == null || id == getNullSelectionItemId())) {
// skip empty selection if nullselection is not allowed
@@ -1721,9 +1720,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
&& !propertySetEventListeners.isEmpty()) {
final Container.PropertySetChangeEvent event = new PropertySetChangeEvent(
this);
- final Object[] listeners = propertySetEventListeners.toArray();
- for (int i = 0; i < listeners.length; i++) {
- ((Container.PropertySetChangeListener) listeners[i])
+ for (Object l : propertySetEventListeners.toArray()) {
+ ((Container.PropertySetChangeListener) l)
.containerPropertySetChange(event);
}
}
@@ -1737,9 +1735,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
if (itemSetEventListeners != null && !itemSetEventListeners.isEmpty()) {
final Container.ItemSetChangeEvent event = new ItemSetChangeEvent(
this);
- final Object[] listeners = itemSetEventListeners.toArray();
- for (int i = 0; i < listeners.length; i++) {
- ((Container.ItemSetChangeListener) listeners[i])
+ for (Object l : itemSetEventListeners.toArray()) {
+ ((Container.ItemSetChangeListener) l)
.containerItemSetChange(event);
}
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java
index 3c717ac954..52f36e9906 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java
@@ -695,20 +695,19 @@ public class Table extends AbstractSelect implements Action.Container,
// Checks that the new visible columns contains no nulls, properties
// exist and that there are no duplicates before adding them to newVC.
final Collection<?> properties = getContainerPropertyIds();
- for (int i = 0; i < visibleColumns.length; i++) {
- if (visibleColumns[i] == null) {
+ for (Object id : visibleColumns) {
+ if (id == null) {
throw new NullPointerException("Ids must be non-nulls");
- } else if (!properties.contains(visibleColumns[i])
- && !columnGenerators.containsKey(visibleColumns[i])) {
+ } else if (!properties.contains(id)
+ && !columnGenerators.containsKey(id)) {
throw new IllegalArgumentException(
"Ids must exist in the Container or as a generated column, missing id: "
- + visibleColumns[i]);
- } else if (newVC.contains(visibleColumns[i])) {
+ + id);
+ } else if (newVC.contains(id)) {
throw new IllegalArgumentException(
- "Ids must be unique, duplicate id: "
- + visibleColumns[i]);
+ "Ids must be unique, duplicate id: " + id);
} else {
- newVC.add(visibleColumns[i]);
+ newVC.add(id);
}
}
@@ -1476,11 +1475,10 @@ public class Table extends AbstractSelect implements Action.Container,
return;
}
final LinkedList<Object> newOrder = new LinkedList<Object>();
- for (int i = 0; i < columnOrder.length; i++) {
- if (columnOrder[i] != null
- && visibleColumns.contains(columnOrder[i])) {
- visibleColumns.remove(columnOrder[i]);
- newOrder.add(columnOrder[i]);
+ for (Object id : columnOrder) {
+ if (id != null && visibleColumns.contains(id)) {
+ visibleColumns.remove(id);
+ newOrder.add(id);
}
}
for (final Object columnId : visibleColumns) {
@@ -2848,9 +2846,9 @@ public class Table extends AbstractSelect implements Action.Container,
* selected on the client side (the ones that the client side is aware
* of).
*/
- for (int i = 0; i < ka.length; i++) {
+ for (String k : ka) {
// key to id
- final Object id = itemIdMapper.get(ka[i]);
+ final Object id = itemIdMapper.get(k);
if (!isNullSelectionAllowed()
&& (id == null || id == getNullSelectionItemId())) {
// skip empty selection if nullselection is not allowed
@@ -2892,8 +2890,8 @@ public class Table extends AbstractSelect implements Action.Container,
private Set<Object> getCurrentlyRenderedItemIds() {
HashSet<Object> ids = new HashSet<Object>();
if (pageBuffer != null) {
- for (int i = 0; i < pageBuffer[CELL_ITEMID].length; i++) {
- ids.add(pageBuffer[CELL_ITEMID][i]);
+ for (Object id : pageBuffer[CELL_ITEMID]) {
+ ids.add(id);
}
}
return ids;
@@ -4486,8 +4484,8 @@ public class Table extends AbstractSelect implements Action.Container,
// may be null if the table has not been rendered yet (e.g. not attached
// to a layout)
if (null != cells) {
- for (int i = 0; i < cells[CELL_ITEMID].length; i++) {
- visible.add(cells[CELL_ITEMID][i]);
+ for (Object id : cells[CELL_ITEMID]) {
+ visible.add(id);
}
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java
index 2d6c1e521e..7738c166f7 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java
@@ -529,9 +529,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
// Collapses the nodes
if (variables.containsKey("collapse")) {
- final String[] keys = (String[]) variables.get("collapse");
- for (int i = 0; i < keys.length; i++) {
- final Object id = itemIdMapper.get(keys[i]);
+ for (String key : (String[]) variables.get("collapse")) {
+ final Object id = itemIdMapper.get(key);
if (id != null && isExpanded(id)) {
expanded.remove(id);
if (expandedItemId == id) {
@@ -548,9 +547,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
if (variables.containsKey("requestChildTree")) {
sendChildTree = true;
}
- final String[] keys = (String[]) variables.get("expand");
- for (int i = 0; i < keys.length; i++) {
- final Object id = itemIdMapper.get(keys[i]);
+ for (String key : (String[]) variables.get("expand")) {
+ final Object id = itemIdMapper.get(key);
if (id != null) {
expandItem(id, sendChildTree);
}
@@ -593,12 +591,11 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
* The variables sent to the server from the client
*/
private void handleSelectedItems(Map<String, Object> variables) {
- final String[] ka = (String[]) variables.get("selected");
// Converts the key-array to id-set
final LinkedList<Object> s = new LinkedList<Object>();
- for (int i = 0; i < ka.length; i++) {
- final Object id = itemIdMapper.get(ka[i]);
+ for (String key : (String[]) variables.get("selected")) {
+ final Object id = itemIdMapper.get(key);
if (!isNullSelectionAllowed()
&& (id == null || id == getNullSelectionItemId())) {
// skip empty selection if nullselection is not allowed