diff --git a/extensions/jython/src/com/google/refine/jython/JythonEvaluable.java b/extensions/jython/src/com/google/refine/jython/JythonEvaluable.java index dad9d0d55..0c9c73481 100644 --- a/extensions/jython/src/com/google/refine/jython/JythonEvaluable.java +++ b/extensions/jython/src/com/google/refine/jython/JythonEvaluable.java @@ -101,9 +101,9 @@ public class JythonEvaluable implements Evaluable { sb.append("def "); sb.append(s_functionName); sb.append("(value, cell, cells, row, rowIndex):"); - for (int i = 0; i < lines.length; i++) { + for (String line : lines) { sb.append("\n "); - sb.append(lines[i]); + sb.append(line); } _engine.exec(sb.toString()); diff --git a/main/src/com/google/refine/browsing/util/ExpressionNominalValueGrouper.java b/main/src/com/google/refine/browsing/util/ExpressionNominalValueGrouper.java index a6d3dbdc9..041d2086f 100644 --- a/main/src/com/google/refine/browsing/util/ExpressionNominalValueGrouper.java +++ b/main/src/com/google/refine/browsing/util/ExpressionNominalValueGrouper.java @@ -213,8 +213,8 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor Object[] choiceValues = (Object[]) value; List counts = new ArrayList(choiceValues.length); - for (int i = 0; i < choiceValues.length; i++) { - counts.add(getChoiceValueCount(choiceValues[i])); + for (Object choiceValue : choiceValues) { + counts.add(getChoiceValueCount(choiceValue)); } return counts; } else if (value instanceof Collection) { diff --git a/main/src/com/google/refine/browsing/util/TimeBinIndex.java b/main/src/com/google/refine/browsing/util/TimeBinIndex.java index 00a08fa0b..32099827e 100644 --- a/main/src/com/google/refine/browsing/util/TimeBinIndex.java +++ b/main/src/com/google/refine/browsing/util/TimeBinIndex.java @@ -110,8 +110,8 @@ abstract public class TimeBinIndex { long diff = _max - _min; - for (int i = 0; i < steps.length; i++) { - _step = steps[i]; + for (long step : steps) { + _step = step; if (diff / _step <= 100) break; } diff --git a/main/src/com/google/refine/clustering/binning/FingerprintKeyer.java b/main/src/com/google/refine/clustering/binning/FingerprintKeyer.java index 50921043a..1455192d2 100644 --- a/main/src/com/google/refine/clustering/binning/FingerprintKeyer.java +++ b/main/src/com/google/refine/clustering/binning/FingerprintKeyer.java @@ -65,8 +65,8 @@ public class FingerprintKeyer extends Keyer { protected String asciify(String s) { char[] c = s.toCharArray(); StringBuffer b = new StringBuffer(); - for (int i = 0; i < c.length; i++) { - b.append(translate(c[i])); + for (char element : c) { + b.append(translate(element)); } return b.toString(); } diff --git a/main/src/com/google/refine/expr/functions/arrays/Uniques.java b/main/src/com/google/refine/expr/functions/arrays/Uniques.java index 810e3df4f..1acd8e41b 100644 --- a/main/src/com/google/refine/expr/functions/arrays/Uniques.java +++ b/main/src/com/google/refine/expr/functions/arrays/Uniques.java @@ -72,8 +72,8 @@ public class Uniques implements Function { Object[] a = (Object[]) v; set = new HashSet(a.length); - for (int i = 0; i < a.length; i++) { - set.add(a[i]); + for (Object element : a) { + set.add(element); } } else { set = new HashSet(ExpressionUtils.toObjectList(v)); diff --git a/main/src/com/google/refine/expr/util/CalendarParser.java b/main/src/com/google/refine/expr/util/CalendarParser.java index 191f0e9bf..de3da51c9 100644 --- a/main/src/com/google/refine/expr/util/CalendarParser.java +++ b/main/src/com/google/refine/expr/util/CalendarParser.java @@ -742,9 +742,9 @@ public class CalendarParser { } String lstr = str.toLowerCase(); - for (int i = 0; i < WEEKDAY_NAMES.length; i++) { - if (lstr.startsWith(WEEKDAY_NAMES[i]) - || WEEKDAY_NAMES[i].toLowerCase().startsWith(lstr)) { + for (String element : WEEKDAY_NAMES) { + if (lstr.startsWith(element) + || element.toLowerCase().startsWith(lstr)) { return true; } } @@ -1037,8 +1037,8 @@ public class CalendarParser { return; } else if (zoneNames != null) { // maybe it's a time zone name - for (int z = 0; z < zoneNames.length; z++) { - if (token.equalsIgnoreCase(zoneNames[z])) { + for (String zoneName : zoneNames) { + if (token.equalsIgnoreCase(zoneName)) { TimeZone tz = TimeZone.getTimeZone(token); if (tz.getRawOffset() != 0 || lToken.equals("gmt")) { state.setTimeZone(tz); @@ -1679,9 +1679,7 @@ public class CalendarParser { } String[] tList = tmpTime.split("[:\\.]"); - for (int i = 0; i < tList.length; i++) { - String token = tList[i]; - + for (String token : tList) { if (DEBUG) { System.err.println("HOUR " + (state.isHourSet() ? Integer @@ -1790,9 +1788,7 @@ public class CalendarParser { int minute = UNSET; String[] tList = zoneStr.substring(1).split(":"); - for (int i = 0; i < tList.length; i++) { - String token = tList[i]; - + for (String token : tList) { if (DEBUG) { System.err .println("TZ_HOUR " diff --git a/main/src/com/google/refine/history/ChangeSequence.java b/main/src/com/google/refine/history/ChangeSequence.java index 644d5eda6..8ac58894e 100644 --- a/main/src/com/google/refine/history/ChangeSequence.java +++ b/main/src/com/google/refine/history/ChangeSequence.java @@ -51,8 +51,8 @@ public class ChangeSequence implements Change { @Override public void apply(Project project) { synchronized (project) { - for (int i = 0; i < _changes.length; i++) { - _changes[i].apply(project); + for (Change _change : _changes) { + _change.apply(project); } } } @@ -69,9 +69,7 @@ public class ChangeSequence implements Change { @Override public void save(Writer writer, Properties options) throws IOException { writer.write("count="); writer.write(Integer.toString(_changes.length)); writer.write('\n'); - for (int i = 0; i < _changes.length; i++) { - Change change = _changes[i]; - + for (Change change : _changes) { writer.write(change.getClass().getName()); writer.write('\n'); change.save(writer, options); diff --git a/main/src/com/google/refine/operations/column/ColumnSplitOperation.java b/main/src/com/google/refine/operations/column/ColumnSplitOperation.java index 4200fc8ee..63f2787af 100644 --- a/main/src/com/google/refine/operations/column/ColumnSplitOperation.java +++ b/main/src/com/google/refine/operations/column/ColumnSplitOperation.java @@ -195,9 +195,8 @@ public class ColumnSplitOperation extends EngineDependentOperation { List results = new ArrayList(_fieldLengths.length + 1); int lastIndex = 0; - for (int i = 0; i < _fieldLengths.length; i++) { + for (int length : _fieldLengths) { int from = lastIndex; - int length = _fieldLengths[i]; int to = Math.min(from + length, s.length()); results.add(stringToValue(s.substring(from, to))); diff --git a/main/src/com/google/refine/operations/row/DenormalizeOperation.java b/main/src/com/google/refine/operations/row/DenormalizeOperation.java index 744ad069d..80b70a91b 100644 --- a/main/src/com/google/refine/operations/row/DenormalizeOperation.java +++ b/main/src/com/google/refine/operations/row/DenormalizeOperation.java @@ -88,8 +88,7 @@ public void write(JSONWriter writer, Properties options) if (rd.cellDependencies != null) { newRow = oldRow.dup(); - for (int c = 0; c < rd.cellDependencies.length; c++) { - CellDependency cd = rd.cellDependencies[c]; + for (CellDependency cd : rd.cellDependencies) { if (cd != null) { int contextRowIndex = cd.rowIndex; int contextCellIndex = cd.cellIndex;