Ticket #20167: enhanced_for_loops_v2.patch

File enhanced_for_loops_v2.patch, 55.1 KB (added by gaben, 5 years ago)

three more readability improvements not related to loops

  • src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    11231123            OsmPrimitive nxt = first;
    11241124
    11251125            if (cyclePrims && shift) {
    1126                 for (Iterator<OsmPrimitive> i = cycleList.iterator(); i.hasNext();) {
    1127                     nxt = i.next();
     1126                for (OsmPrimitive osmPrimitive : cycleList) {
     1127                    nxt = osmPrimitive;
    11281128                    if (!nxt.isSelected()) {
    11291129                        break; // take first primitive in cycleList not in sel
    11301130                    }
  • src/org/openstreetmap/josm/actions/JoinAreasAction.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    707707
    708708        //  see #9599
    709709        if (discardedWays.stream().anyMatch(w -> !w.isNew())) {
    710             for (int i = 0; i < boundaries.size(); i++) {
    711                 AssembledPolygon ring = boundaries.get(i);
     710            for (AssembledPolygon ring : boundaries) {
    712711                for (int k = 0; k < ring.ways.size(); k++) {
    713712                    WayInPolygon ringWay = ring.ways.get(k);
    714713                    Way older = keepOlder(ringWay.way, oldestWayMap, discardedWays);
  • src/org/openstreetmap/josm/data/cache/HostLimitQueue.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    33
    44import java.io.IOException;
    55import java.net.URL;
    6 import java.util.Iterator;
    76import java.util.Map;
    87import java.util.concurrent.ConcurrentHashMap;
    98import java.util.concurrent.LinkedBlockingDeque;
     
    5251    }
    5352
    5453    private JCSCachedTileLoaderJob<?, ?> findJob() {
    55         for (Iterator<Runnable> it = iterator(); it.hasNext();) {
    56             Runnable r = it.next();
     54        for (Runnable r : this) {
    5755            if (r instanceof JCSCachedTileLoaderJob) {
    5856                JCSCachedTileLoaderJob<?, ?> job = (JCSCachedTileLoaderJob<?, ?>) r;
    5957                if (tryAcquireSemaphore(job)) {
  • src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    104104        }
    105105        boolean isFirst = true;
    106106
    107         for (int t = 0; t < trks.size(); t++) {
    108             List<List<WayPoint>> segs = trks.get(t);
     107        // TODO: refactor this to be more readable
     108        for (List<List<WayPoint>> segs : trks) {
    109109            for (int s = 0; s < segs.size(); s++) {
    110110                List<WayPoint> wps = segs.get(s);
    111111                for (int i = 0; i < wps.size(); i++) {
  • src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    262262     */
    263263    private static NTV2SubGrid getSubGrid(NTV2SubGrid[] topLevelSubGrid, double lon, double lat) {
    264264        NTV2SubGrid sub = null;
    265         for (int i = 0; i < topLevelSubGrid.length; i++) {
    266             sub = topLevelSubGrid[i].getSubGridForCoord(lon, lat);
     265        for (NTV2SubGrid subGrid : topLevelSubGrid) {
     266            sub = subGrid.getSubGridForCoord(lon, lat);
    267267            if (sub != null) {
    268268                break;
    269269            }
     
    273273
    274274    @Override
    275275    public String toString() {
    276         return new StringBuilder(256)
    277             .append("Headers  : ")
    278             .append(overviewHeaderCount)
    279             .append("\nSub Hdrs : ")
    280             .append(subGridHeaderCount)
    281             .append("\nSub Grids: ")
    282             .append(subGridCount)
    283             .append("\nType     : ")
    284             .append(shiftType)
    285             .append("\nVersion  : ")
    286             .append(version)
    287             .append("\nFr Ellpsd: ")
    288             .append(fromEllipsoid)
    289             .append("\nTo Ellpsd: ")
    290             .append(toEllipsoid)
    291             .append("\nFr Maj Ax: ")
    292             .append(fromSemiMajorAxis)
    293             .append("\nFr Min Ax: ")
    294             .append(fromSemiMinorAxis)
    295             .append("\nTo Maj Ax: ")
    296             .append(toSemiMajorAxis)
    297             .append("\nTo Min Ax: ")
    298             .append(toSemiMinorAxis)
    299             .toString();
     276        char endl = '\n';
     277        return "Headers  : " + overviewHeaderCount + endl +
     278                "Sub Hdrs : " + subGridHeaderCount + endl +
     279                "Sub Grids: " + subGridCount + endl +
     280                "Type     : " + shiftType + endl +
     281                "Version  : " + version + endl +
     282                "Fr Ellpsd: " + fromEllipsoid + endl +
     283                "To Ellpsd: " + toEllipsoid + endl +
     284                "Fr Maj Ax: " + fromSemiMajorAxis + endl +
     285                "Fr Min Ax: " + fromSemiMinorAxis + endl +
     286                "To Maj Ax: " + toSemiMajorAxis + endl +
     287                "To Min Ax: " + toSemiMinorAxis;
    300288    }
    301289
    302290    /**
  • src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    275275                schemes = DEFAULT_SCHEMES;
    276276            }
    277277            allowedSchemes = new HashSet<>(schemes.length);
    278             for (int i = 0; i < schemes.length; i++) {
    279                 allowedSchemes.add(schemes[i].toLowerCase(Locale.ENGLISH));
     278            for (String scheme : schemes) {
     279                allowedSchemes.add(scheme.toLowerCase(Locale.ENGLISH));
    280280            }
    281281        }
    282282
  • src/org/openstreetmap/josm/data/validation/tests/ConnectivityRelations.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    8282
    8383        final Map<Integer, Map<Integer, Boolean>> result = new HashMap<>();
    8484        String[] lanes = joined.split("\\|", -1);
    85         for (int i = 0; i < lanes.length; i++) {
    86             String[] lane = lanes[i].split(":", -1);
     85        for (final String s : lanes) {
     86            String[] lane = s.split(":", -1);
    8787            int laneNumber;
    8888            //Ignore connections from bw, since we cannot derive a lane number from bw
    8989            if (!"bw".equals(lane[0])) {
     
    9393            }
    9494            Map<Integer, Boolean> connections = new HashMap<>();
    9595            String[] toLanes = TO_LANE_PATTERN.split(lane[1], -1);
    96             for (int j = 0; j < toLanes.length; j++) {
    97                 String toLane = toLanes[j].trim();
     96            for (final String value : toLanes) {
     97                String toLane = value.trim();
    9898                try {
    9999                    if (OPTIONAL_LANE_PATTERN.matcher(toLane).matches()) {
    100100                        toLane = toLane.replace("(", "").replace(")", "").trim();
  • src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    155155    /**
    156156     * Returns the list of "duplicate nodes" errors for the given selection of node and parent test
    157157     * @param parentTest The parent test of returned errors
    158      * @param nodes The nodes selction to look into
     158     * @param nodes The nodes selection to look into
    159159     * @return the list of "duplicate nodes" errors
    160160     */
    161161    public List<TestError> buildTestErrors(Test parentTest, List<Node> nodes) {
     
    186186                                boolean typed = false;
    187187                                Way w = (Way) sp;
    188188                                Map<String, String> keys = w.getKeys();
    189                                 for (Iterator<Entry<String, Boolean>> itt = typeMap.entrySet().iterator(); itt.hasNext();) {
    190                                     Entry<String, Boolean> e = itt.next();
     189                                for (Entry<String, Boolean> e : typeMap.entrySet()) {
    191190                                    if (keys.containsKey(e.getKey())) {
    192191                                        e.setValue(Boolean.TRUE);
    193192                                        typed = true;
  • src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    219219            // build regular expression for other words (for fast match)
    220220            StringBuilder expression = new StringBuilder();
    221221            int maxLength = 0;
    222             for (int i = 0; i < words.length; i++) {
    223                 if (words[i].length() > maxLength) {
    224                     maxLength = words[i].length();
     222            for (String word : words) {
     223                if (word.length() > maxLength) {
     224                    maxLength = word.length();
    225225                }
    226226                if (expression.length() > 0) {
    227227                    expression.append('|');
    228228                }
    229                 expression.append(Pattern.quote(words[i]));
     229                expression.append(Pattern.quote(word));
    230230            }
    231231            this.regExpr = Pattern.compile(expression.toString(), CASE_INSENSITIVE + UNICODE_CASE);
    232232        }
     
    242242
    243243            // which word matches?
    244244            String part = "";
    245             for (int i = 0; i < words.length; i++) {
    246                 String word = words[i];
     245            for (String word : words) {
    247246                if (start + word.length() <= name.length()) {
    248247                    part = name.substring(start, start + word.length());
    249248                }
  • src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    276276    private void buildUndoTree() {
    277277        List<Command> undoCommands = UndoRedoHandler.getInstance().getUndoCommands();
    278278        undoRoot = new DefaultMutableTreeNode();
    279         for (int i = 0; i < undoCommands.size(); ++i) {
    280             undoRoot.add(getNodeForCommand(undoCommands.get(i)));
     279        for (Command undoCommand : undoCommands) {
     280            undoRoot.add(getNodeForCommand(undoCommand));
    281281        }
    282282        undoTreeModel.setRoot(undoRoot);
    283283    }
     
    285285    private void buildRedoTree() {
    286286        List<Command> redoCommands = UndoRedoHandler.getInstance().getRedoCommands();
    287287        redoRoot = new DefaultMutableTreeNode();
    288         for (int i = 0; i < redoCommands.size(); ++i) {
    289             redoRoot.add(getNodeForCommand(redoCommands.get(i)));
     288        for (Command redoCommand : redoCommands) {
     289            redoRoot.add(getNodeForCommand(redoCommand));
    290290        }
    291291        redoTreeModel.setRoot(redoRoot);
    292292    }
     
    340340        CommandListMutableTreeNode node = new CommandListMutableTreeNode(c);
    341341        if (c.getChildren() != null) {
    342342            List<PseudoCommand> children = new ArrayList<>(c.getChildren());
    343             for (int i = 0; i < children.size(); ++i) {
    344                 node.add(getNodeForCommand(children.get(i)));
     343            for (PseudoCommand child : children) {
     344                node.add(getNodeForCommand(child));
    345345            }
    346346        }
    347347        return node;
  • src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    193193         * Determine the panel geometry
    194194         */
    195195        if (action == Action.RESTORE_SAVED || action == Action.ELEMENT_SHRINKS) {
    196             for (int i = 0; i < n; ++i) {
    197                 final ToggleDialog dlg = allDialogs.get(i);
     196            for (final ToggleDialog dlg : allDialogs) {
    198197                if (dlg.isDialogInDefaultView()) {
    199198                    final int ph = action == Action.RESTORE_SAVED ? dlg.getLastHeight() : dlg.getPreferredHeight();
    200199                    final int ah = dlg.getSize().height;
     
    250249             */
    251250            int dm = 0;        // additional space needed by the small dialogs
    252251            int dp = 0;        // available space from the large dialogs
    253             for (int i = 0; i < n; ++i) {
    254                 final ToggleDialog dlg = allDialogs.get(i);
     252            for (final ToggleDialog dlg : allDialogs) {
    255253                if (dlg != triggeredBy && dlg.isDialogInDefaultView()) {
    256254                    final int ha = dlg.getSize().height;                              // current
    257255                    final int h0 = ha * r / sumA;                                     // proportional shrinking
     
    265263                }
    266264            }
    267265            /** adjust, without changing the sum */
    268             for (int i = 0; i < n; ++i) {
    269                 final ToggleDialog dlg = allDialogs.get(i);
     266            for (final ToggleDialog dlg : allDialogs) {
    270267                if (dlg != triggeredBy && dlg.isDialogInDefaultView()) {
    271268                    final int ha = dlg.getHeight();
    272269                    final int h0 = ha * r / sumA;
     
    275272                        int hn = Math.min(ha, he);
    276273                        dlg.setPreferredSize(new Dimension(Integer.MAX_VALUE, hn));
    277274                    } else {
    278                         int d = dp == 0 ? 0 : ((h0-he) * dm / dp);
     275                        int d = dp == 0 ? 0 : ((h0 - he) * dm / dp);
    279276                        dlg.setPreferredSize(new Dimension(Integer.MAX_VALUE, h0 - d));
    280277                    }
    281278                }
  • src/org/openstreetmap/josm/gui/mappaint/styleelement/placement/CompletelyInsideAreaStrategy.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    3939        // will have to do.                                    ++
    4040        // Centroids are not optimal either, just imagine a U-shaped house.
    4141
    42         Rectangle pb = path.getBounds();
     42        final Rectangle pb = path.getBounds();
    4343
    4444        // quick check to see if label box is smaller than primitive box
    4545        if (pb.width < nb.getWidth() || pb.height < nb.getHeight()) {
     
    5555        final int nbw = (int) nb.getWidth();
    5656        final int nbh = (int) nb.getHeight();
    5757
    58         Rectangle centeredNBounds = new Rectangle(x2, y2, nbw, nbh);
     58        final Rectangle centeredNBounds = new Rectangle(x2, y2, nbw, nbh);
    5959
    6060        // slower check to see if label is displayed inside primitive shape
    6161        if (path.contains(centeredNBounds)) {
     
    8484        };
    8585        // Dumb algorithm to find a better placement. We could surely find a smarter one but it should
    8686        // solve most of building issues with only few calculations (8 at most)
    87         for (int i = 0; i < candidates.length; i++) {
    88             centeredNBounds = candidates[i];
    89             if (path.contains(centeredNBounds)) {
    90                 return centerOf(path.getMapViewState(), centeredNBounds);
     87        for (Rectangle candidate : candidates) {
     88            if (path.contains(candidate)) {
     89                return centerOf(path.getMapViewState(), candidate);
    9190            }
    9291        }
    9392
  • src/org/openstreetmap/josm/tools/ListenerList.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    44import java.lang.ref.WeakReference;
    55import java.text.MessageFormat;
    66import java.util.HashMap;
    7 import java.util.Iterator;
    87import java.util.Objects;
    98import java.util.concurrent.CopyOnWriteArrayList;
    109import java.util.stream.Stream;
     
    155154        for (T l : listeners) {
    156155            eventFirerer.fire(l);
    157156        }
    158         for (Iterator<WeakListener<T>> iterator = weakListeners.iterator(); iterator.hasNext();) {
    159             WeakListener<T> weakLink = iterator.next();
     157        for (WeakListener<T> weakLink : weakListeners) {
    160158            T l = weakLink.listener.get();
    161159            if (l != null) {
    162160                // cleanup during add() should be enough to not cause memory leaks
  • src/org/openstreetmap/josm/tools/Utils.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    15091509            dirStrings[i] = new DirectionString(dir, substr);
    15101510        }
    15111511        Bidi.reorderVisually(levels, 0, dirStrings, 0, levels.length);
    1512         for (int i = 0; i < dirStrings.length; ++i) {
    1513             char[] chars = dirStrings[i].str.toCharArray();
    1514             gvs.add(font.layoutGlyphVector(frc, chars, 0, chars.length, dirStrings[i].direction));
     1512        for (DirectionString dirString : dirStrings) {
     1513            char[] chars = dirString.str.toCharArray();
     1514            gvs.add(font.layoutGlyphVector(frc, chars, 0, chars.length, dirString.direction));
    15151515        }
    15161516        return gvs;
    15171517    }
  • test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    347347
    348348    private static boolean isInIanaList(String name, String[] array, Set<String> ianaTlds) {
    349349        boolean ok = true;
    350         for (int i = 0; i < array.length; i++) {
    351             if (!ianaTlds.contains(array[i])) {
    352                 Logging.error(name + " contains unexpected value: " + array[i]);
     350        for (String element : array) {
     351            if (!ianaTlds.contains(element)) {
     352                Logging.error(name + " contains unexpected value: " + element);
    353353                ok = false;
    354354            }
    355355        }
  • test/unit/org/openstreetmap/josm/data/validation/routines/EmailValidatorTest.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    492492    @Disabled("This test fails so disable it for 1.1.4 release. The real solution is to fix the email parsing")
    493493    @Test
    494494    void testEmailFromPerl() {
    495         for (int index = 0; index < testEmailFromPerl.length; index++) {
    496             String item = testEmailFromPerl[index].item;
    497             if (testEmailFromPerl[index].valid) {
    498                 assertTrue("Should be OK: "+item, validator.isValid(item));
     495        for (ResultPair resultPair : testEmailFromPerl) {
     496            String item = resultPair.item;
     497            if (resultPair.valid) {
     498                assertTrue("Should be OK: " + item, validator.isValid(item));
    499499            } else {
    500                 assertFalse("Should fail: "+item, validator.isValid(item));
     500                assertFalse("Should fail: " + item, validator.isValid(item));
    501501            }
    502502        }
    503503    }
  • test/unit/org/openstreetmap/josm/data/validation/routines/UrlValidatorTest.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    3030 */
    3131class UrlValidatorTest {
    3232
    33    private static final boolean printStatus = false;
    34    private static final boolean printIndex = false; //print index that indicates current scheme,host,port,path, query test were using.
     33    private static final boolean printStatus = false;
     34    private static final boolean printIndex = false; //print index that indicates current scheme,host,port,path, query test were using.
    3535
    36    /**
    37     * Setup
    38     */
    39    @BeforeEach
    40    public void setUp() {
    41       for (int index = 0; index < testPartsIndex.length - 1; index++) {
    42          testPartsIndex[index] = 0;
    43       }
    44    }
     36    /**
     37     * Setup
     38     */
     39    @BeforeEach
     40    public void setUp() {
     41        for (int index = 0; index < testPartsIndex.length - 1; index++) {
     42            testPartsIndex[index] = 0;
     43        }
     44    }
    4545
    46    /**
    47     * Test is valid
    48     */
    49    @Test
    50    public void testIsValid() {
     46    /**
     47     * Test is valid
     48     */
     49    @Test
     50    public void testIsValid() {
    5151        testIsValid(testUrlParts, UrlValidator.ALLOW_ALL_SCHEMES);
    5252        setUp();
    5353        long options =
    54             UrlValidator.ALLOW_2_SLASHES
    55                 + UrlValidator.ALLOW_ALL_SCHEMES
    56                 + UrlValidator.NO_FRAGMENTS;
     54                UrlValidator.ALLOW_2_SLASHES
     55                        + UrlValidator.ALLOW_ALL_SCHEMES
     56                        + UrlValidator.NO_FRAGMENTS;
    5757
    5858        testIsValid(testUrlPartsOptions, options);
    59    }
     59    }
    6060
    61    /**
    62     * Test is valid scheme
    63     */
    64    @Test
    65    public void testIsValidScheme() {
    66       if (printStatus) {
    67          System.out.print("\n testIsValidScheme() ");
    68       }
    69       //UrlValidator urlVal = new UrlValidator(schemes,false,false,false);
    70       UrlValidator urlVal = new UrlValidator(schemes, 0);
    71       for (int sIndex = 0; sIndex < testScheme.length; sIndex++) {
    72          ResultPair testPair = testScheme[sIndex];
    73          boolean result = urlVal.isValidScheme(testPair.item);
    74          assertEquals(testPair.item, testPair.valid, result);
    75          if (printStatus) {
    76             if (result == testPair.valid) {
    77                System.out.print('.');
    78             } else {
    79                System.out.print('X');
    80             }
    81          }
    82       }
    83       if (printStatus) {
    84          System.out.println();
    85       }
    86    }
     61    /**
     62     * Test is valid scheme
     63     */
     64    @Test
     65    public void testIsValidScheme() {
     66        if (printStatus) {
     67            System.out.print("\n testIsValidScheme() ");
     68        }
     69        //UrlValidator urlVal = new UrlValidator(schemes,false,false,false);
     70        UrlValidator urlVal = new UrlValidator(schemes, 0);
     71        for (ResultPair testPair : testScheme) {
     72            boolean result = urlVal.isValidScheme(testPair.item);
     73            assertEquals(testPair.item, testPair.valid, result);
     74            if (printStatus) {
     75                if (result == testPair.valid) {
     76                    System.out.print('.');
     77                } else {
     78                    System.out.print('X');
     79                }
     80            }
     81        }
     82        if (printStatus) {
     83            System.out.println();
     84        }
     85    }
    8786
    88    /**
    89     * Create set of tests by taking the testUrlXXX arrays and
    90     * running through all possible permutations of their combinations.
    91     *
    92     * @param testObjects Used to create a url.
    93     * @param options options
    94     */
    95    private void testIsValid(Object[] testObjects, long options) {
    96       UrlValidator urlVal = new UrlValidator(null, null, options);
    97       assertTrue(urlVal.isValid("http://www.google.com"));
    98       assertTrue(urlVal.isValid("http://www.google.com/"));
    99       int statusPerLine = 60;
    100       int printed = 0;
    101       if (printIndex) {
    102          statusPerLine = 6;
    103       }
    104       do {
    105           StringBuilder testBuffer = new StringBuilder();
    106          boolean expected = true;
    107          for (int testPartsIndexIndex = 0; testPartsIndexIndex < testPartsIndex.length; ++testPartsIndexIndex) {
    108             int index = testPartsIndex[testPartsIndexIndex];
    109             ResultPair[] part = (ResultPair[]) testObjects[testPartsIndexIndex];
    110             testBuffer.append(part[index].item);
    111             expected &= part[index].valid;
    112          }
    113          String url = testBuffer.toString();
    114          boolean result = urlVal.isValid(url);
    115          assertEquals(url, expected, result);
    116          if (printStatus) {
    117             if (printIndex) {
    118                System.out.print(testPartsIndextoString());
    119             } else {
    120                if (result == expected) {
    121                   System.out.print('.');
    122                } else {
    123                   System.out.print('X');
    124                }
    125             }
    126             printed++;
    127             if (printed == statusPerLine) {
    128                System.out.println();
    129                printed = 0;
    130             }
    131          }
    132       } while (incrementTestPartsIndex(testPartsIndex, testObjects));
    133       if (printStatus) {
    134          System.out.println();
    135       }
    136    }
     87    /**
     88     * Create set of tests by taking the testUrlXXX arrays and
     89     * running through all possible permutations of their combinations.
     90     *
     91     * @param testObjects Used to create a url.
     92     * @param options    options
     93     */
     94    private void testIsValid(Object[] testObjects, long options) {
     95        UrlValidator urlVal = new UrlValidator(null, null, options);
     96        assertTrue(urlVal.isValid("http://www.google.com"));
     97        assertTrue(urlVal.isValid("http://www.google.com/"));
     98        int statusPerLine = 60;
     99        int printed = 0;
     100        if (printIndex) {
     101            statusPerLine = 6;
     102        }
     103        do {
     104            StringBuilder testBuffer = new StringBuilder();
     105            boolean expected = true;
     106            for (int testPartsIndexIndex = 0; testPartsIndexIndex < testPartsIndex.length; ++testPartsIndexIndex) {
     107                int index = testPartsIndex[testPartsIndexIndex];
     108                ResultPair[] part = (ResultPair[]) testObjects[testPartsIndexIndex];
     109                testBuffer.append(part[index].item);
     110                expected &= part[index].valid;
     111            }
     112            String url = testBuffer.toString();
     113            boolean result = urlVal.isValid(url);
     114            assertEquals(url, expected, result);
     115            if (printStatus) {
     116                if (printIndex) {
     117                    System.out.print(testPartsIndextoString());
     118                } else {
     119                    if (result == expected) {
     120                        System.out.print('.');
     121                    } else {
     122                        System.out.print('X');
     123                    }
     124                }
     125                printed++;
     126                if (printed == statusPerLine) {
     127                    System.out.println();
     128                    printed = 0;
     129                }
     130            }
     131        } while (incrementTestPartsIndex(testPartsIndex, testObjects));
     132        if (printStatus) {
     133            System.out.println();
     134        }
     135    }
    137136
    138137    /**
    139138     * Non-regression test for VALIDATOR-202
     
    143142        String[] schemes = {"http", "https"};
    144143        UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.NO_FRAGMENTS);
    145144        assertTrue(urlValidator.isValid(
    146           "http://l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.org"));
     145                "http://l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.org"));
    147146    }
    148147
    149148    /**
     
    163162    void testValidator218() {
    164163        UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_2_SLASHES);
    165164        assertTrue("parentheses should be valid in URLs",
    166                validator.isValid("http://somewhere.com/pathxyz/file(1).html"));
     165                validator.isValid("http://somewhere.com/pathxyz/file(1).html"));
    167166    }
    168167
    169168    /**
     
    190189     */
    191190    @Test
    192191    void testValidator248() {
    193         RegexValidator regex = new RegexValidator(new String[] {"localhost", ".*\\.my-testing"});
     192        RegexValidator regex = new RegexValidator("localhost", ".*\\.my-testing");
    194193        UrlValidator validator = new UrlValidator(regex, 0);
    195194
    196195        assertTrue("localhost URL should validate",
     
    210209        validator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
    211210
    212211        assertTrue("localhost URL should validate",
    213               validator.isValid("http://localhost/test/index.html"));
     212                validator.isValid("http://localhost/test/index.html"));
    214213
    215214        assertTrue("machinename URL should validate",
    216               validator.isValid("http://machinename/test/index.html"));
     215                validator.isValid("http://machinename/test/index.html"));
    217216
    218217        assertTrue("www.apache.org should still validate",
    219               validator.isValid("http://www.apache.org/test/index.html"));
     218                validator.isValid("http://www.apache.org/test/index.html"));
    220219    }
    221220
    222221    /**
     
    266265        UrlValidator validator = new UrlValidator();
    267266
    268267        assertTrue("http://apache.org/ should be allowed by default",
    269                  validator.isValid("http://www.apache.org/test/index.html"));
     268                validator.isValid("http://www.apache.org/test/index.html"));
    270269
    271270        assertFalse("file:///c:/ shouldn't be allowed by default",
    272                  validator.isValid("file:///C:/some.file"));
     271                validator.isValid("file:///C:/some.file"));
    273272
    274273        assertFalse("file:///c:\\ shouldn't be allowed by default",
    275               validator.isValid("file:///C:\\some.file"));
     274                validator.isValid("file:///C:\\some.file"));
    276275
    277276        assertFalse("file:///etc/ shouldn't be allowed by default",
    278               validator.isValid("file:///etc/hosts"));
     277                validator.isValid("file:///etc/hosts"));
    279278
    280279        assertFalse("file://localhost/etc/ shouldn't be allowed by default",
    281               validator.isValid("file://localhost/etc/hosts"));
     280                validator.isValid("file://localhost/etc/hosts"));
    282281
    283282        assertFalse("file://localhost/c:/ shouldn't be allowed by default",
    284               validator.isValid("file://localhost/c:/some.file"));
     283                validator.isValid("file://localhost/c:/some.file"));
    285284
    286285        // Turn it on, and check
    287286        // Note - we need to enable local urls when working with file:
    288         validator = new UrlValidator(new String[] {"http", "file"}, UrlValidator.ALLOW_LOCAL_URLS);
     287        validator = new UrlValidator(new String[]{"http", "file"}, UrlValidator.ALLOW_LOCAL_URLS);
    289288
    290289        assertTrue("http://apache.org/ should be allowed by default",
    291                  validator.isValid("http://www.apache.org/test/index.html"));
     290                validator.isValid("http://www.apache.org/test/index.html"));
    292291
    293292        assertTrue("file:///c:/ should now be allowed",
    294                  validator.isValid("file:///C:/some.file"));
     293                validator.isValid("file:///C:/some.file"));
    295294
    296295        // Currently, we don't support the c:\ form
    297296        assertFalse("file:///c:\\ shouldn't be allowed",
    298               validator.isValid("file:///C:\\some.file"));
     297                validator.isValid("file:///C:\\some.file"));
    299298
    300299        assertTrue("file:///etc/ should now be allowed",
    301               validator.isValid("file:///etc/hosts"));
     300                validator.isValid("file:///etc/hosts"));
    302301
    303302        assertTrue("file://localhost/etc/ should now be allowed",
    304               validator.isValid("file://localhost/etc/hosts"));
     303                validator.isValid("file://localhost/etc/hosts"));
    305304
    306305        assertTrue("file://localhost/c:/ should now be allowed",
    307               validator.isValid("file://localhost/c:/some.file"));
     306                validator.isValid("file://localhost/c:/some.file"));
    308307
    309308        // These are never valid
    310309        assertFalse("file://c:/ shouldn't ever be allowed, needs file:///c:/",
    311               validator.isValid("file://C:/some.file"));
     310                validator.isValid("file://C:/some.file"));
    312311
    313312        assertFalse("file://c:\\ shouldn't ever be allowed, needs file:///c:/",
    314               validator.isValid("file://C:\\some.file"));
     313                validator.isValid("file://C:\\some.file"));
    315314    }
    316315
    317316    /**
     
    323322        assertTrue(urlValidator.isValid("http://sample.ondemand.com/"));
    324323        assertTrue(urlValidator.isValid("hTtP://sample.ondemand.CoM/"));
    325324        assertTrue(urlValidator.isValid("httpS://SAMPLE.ONEMAND.COM/"));
    326         urlValidator = new UrlValidator(new String[] {"HTTP", "HTTPS"});
     325        urlValidator = new UrlValidator("HTTP", "HTTPS");
    327326        assertTrue(urlValidator.isValid("http://sample.ondemand.com/"));
    328327        assertTrue(urlValidator.isValid("hTtP://sample.ondemand.CoM/"));
    329328        assertTrue(urlValidator.isValid("httpS://SAMPLE.ONEMAND.COM/"));
     
    366365    }
    367366
    368367    static boolean incrementTestPartsIndex(int[] testPartsIndex, Object[] testParts) {
    369       boolean carry = true;  //add 1 to lowest order part.
    370       boolean maxIndex = true;
    371       for (int testPartsIndexIndex = testPartsIndex.length - 1; testPartsIndexIndex >= 0; --testPartsIndexIndex) {
    372          int index = testPartsIndex[testPartsIndexIndex];
    373          ResultPair[] part = (ResultPair[]) testParts[testPartsIndexIndex];
    374          if (carry) {
    375             if (index < part.length - 1) {
    376                index++;
    377                testPartsIndex[testPartsIndexIndex] = index;
    378                carry = false;
    379             } else {
    380                testPartsIndex[testPartsIndexIndex] = 0;
    381                carry = true;
    382             }
    383          }
    384          maxIndex &= (index == (part.length - 1));
    385       }
     368        boolean carry = true;  //add 1 to lowest order part.
     369        boolean maxIndex = true;
     370        for (int testPartsIndexIndex = testPartsIndex.length - 1; testPartsIndexIndex >= 0; --testPartsIndexIndex) {
     371            int index = testPartsIndex[testPartsIndexIndex];
     372            ResultPair[] part = (ResultPair[]) testParts[testPartsIndexIndex];
     373            if (carry) {
     374                if (index < part.length - 1) {
     375                    index++;
     376                    testPartsIndex[testPartsIndexIndex] = index;
     377                    carry = false;
     378                } else {
     379                    testPartsIndex[testPartsIndexIndex] = 0;
     380                    carry = true;
     381                }
     382            }
     383            maxIndex &= (index == (part.length - 1));
     384        }
    386385
    387       return (!maxIndex);
    388    }
     386        return (!maxIndex);
     387    }
    389388
    390    private String testPartsIndextoString() {
    391        StringBuilder carryMsg = new StringBuilder("{");
    392        for (int testPartsIndexIndex = 0; testPartsIndexIndex < testPartsIndex.length; ++testPartsIndexIndex) {
    393          carryMsg.append(testPartsIndex[testPartsIndexIndex]);
    394          if (testPartsIndexIndex < testPartsIndex.length - 1) {
    395             carryMsg.append(',');
    396          } else {
    397             carryMsg.append('}');
    398          }
    399        }
    400        return carryMsg.toString();
    401    }
     389    private String testPartsIndextoString() {
     390        StringBuilder carryMsg = new StringBuilder("{");
     391        for (int testPartsIndexIndex = 0; testPartsIndexIndex < testPartsIndex.length; ++testPartsIndexIndex) {
     392            carryMsg.append(testPartsIndex[testPartsIndexIndex]);
     393            if (testPartsIndexIndex < testPartsIndex.length - 1) {
     394                carryMsg.append(',');
     395            } else {
     396                carryMsg.append('}');
     397            }
     398        }
     399        return carryMsg.toString();
     400    }
    402401
    403    /**
    404     * Non-regression test for VALIDATOR-290
    405     */
    406    @Test
    407    public void testValidator290() {
     402    /**
     403     * Non-regression test for VALIDATOR-290
     404     */
     405    @Test
     406    public void testValidator290() {
    408407        UrlValidator validator = new UrlValidator();
    409408        assertTrue(validator.isValid("http://xn--h1acbxfam.idn.icann.org/"));
    410409        // Internationalized country code top-level domains
     
    441440        assertTrue(validator.isValid("http://test.xn--mgbaam7a8h")); // United Arab Emirates
    442441    }
    443442
    444    /**
    445     * Non-regression test for VALIDATOR-361
    446     */
    447    @Test
    448    public void testValidator361() {
    449        UrlValidator validator = new UrlValidator();
    450        assertTrue(validator.isValid("http://hello.tokyo/"));
     443    /**
     444     * Non-regression test for VALIDATOR-361
     445     */
     446    @Test
     447    public void testValidator361() {
     448        UrlValidator validator = new UrlValidator();
     449        assertTrue(validator.isValid("http://hello.tokyo/"));
    451450    }
    452451
    453    /**
    454     * Non-regression test for VALIDATOR-363
    455     */
    456    @Test
    457    public void testValidator363() {
     452    /**
     453     * Non-regression test for VALIDATOR-363
     454     */
     455    @Test
     456    public void testValidator363() {
    458457        UrlValidator urlValidator = new UrlValidator();
    459458        assertTrue(urlValidator.isValid("http://www.example.org/a/b/hello..world"));
    460459        assertTrue(urlValidator.isValid("http://www.example.org/a/hello..world"));
     
    474473        assertTrue(urlValidator.isValid("http://www.example.org/.../.."));
    475474    }
    476475
    477    /**
    478     * Non-regression test for VALIDATOR-375
    479     */
    480    @Test
    481    public void testValidator375() {
    482        UrlValidator validator = new UrlValidator();
    483        String url = "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html";
    484        assertTrue("IPv6 address URL should validate: " + url, validator.isValid(url));
    485        url = "http://[::1]:80/index.html";
    486        assertTrue("IPv6 address URL should validate: " + url, validator.isValid(url));
    487        url = "http://FEDC:BA98:7654:3210:FEDC:BA98:7654:3210:80/index.html";
    488        assertFalse("IPv6 address without [] should not validate: " + url, validator.isValid(url));
     476    /**
     477     * Non-regression test for VALIDATOR-375
     478     */
     479    @Test
     480    public void testValidator375() {
     481        UrlValidator validator = new UrlValidator();
     482        String url = "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html";
     483        assertTrue("IPv6 address URL should validate: " + url, validator.isValid(url));
     484        url = "http://[::1]:80/index.html";
     485        assertTrue("IPv6 address URL should validate: " + url, validator.isValid(url));
     486        url = "http://FEDC:BA98:7654:3210:FEDC:BA98:7654:3210:80/index.html";
     487        assertFalse("IPv6 address without [] should not validate: " + url, validator.isValid(url));
    489488    }
    490489
    491    /**
    492     * Non-regression test for VALIDATOR-353
    493     */
    494    @Test
    495    public void testValidator353() { // userinfo
    496        UrlValidator validator = new UrlValidator();
    497        assertTrue(validator.isValid("http://www.apache.org:80/path"));
    498        assertTrue(validator.isValid("http://user:pass@www.apache.org:80/path"));
    499        assertTrue(validator.isValid("http://user:@www.apache.org:80/path"));
    500        assertTrue(validator.isValid("http://us%00er:-._~!$&'()*+,;=@www.apache.org:80/path"));
    501        assertFalse(validator.isValid("http://:pass@www.apache.org:80/path"));
    502        assertFalse(validator.isValid("http://:@www.apache.org:80/path"));
    503        assertFalse(validator.isValid("http://user:pa:ss@www.apache.org/path"));
    504        assertFalse(validator.isValid("http://user:pa@ss@www.apache.org/path"));
    505    }
     490    /**
     491     * Non-regression test for VALIDATOR-353
     492     */
     493    @Test
     494    public void testValidator353() { // userinfo
     495        UrlValidator validator = new UrlValidator();
     496        assertTrue(validator.isValid("http://www.apache.org:80/path"));
     497        assertTrue(validator.isValid("http://user:pass@www.apache.org:80/path"));
     498        assertTrue(validator.isValid("http://user:@www.apache.org:80/path"));
     499        assertTrue(validator.isValid("http://us%00er:-._~!$&'()*+,;=@www.apache.org:80/path"));
     500        assertFalse(validator.isValid("http://:pass@www.apache.org:80/path"));
     501        assertFalse(validator.isValid("http://:@www.apache.org:80/path"));
     502        assertFalse(validator.isValid("http://user:pa:ss@www.apache.org/path"));
     503        assertFalse(validator.isValid("http://user:pa@ss@www.apache.org/path"));
     504    }
    506505
    507    /**
    508     * Non-regression test for VALIDATOR-382
    509     */
    510    @Test
    511    public void testValidator382() {
    512        UrlValidator validator = new UrlValidator();
    513        assertTrue(validator.isValid("ftp://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose"));
    514    }
     506    /**
     507     * Non-regression test for VALIDATOR-382
     508     */
     509    @Test
     510    public void testValidator382() {
     511        UrlValidator validator = new UrlValidator();
     512        assertTrue(validator.isValid("ftp://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose"));
     513    }
    515514
    516    /**
    517     * Non-regression test for VALIDATOR-380
    518     */
    519    @Test
    520    public void testValidator380() {
    521        UrlValidator validator = new UrlValidator();
    522        assertTrue(validator.isValid("http://www.apache.org:80/path"));
    523        assertTrue(validator.isValid("http://www.apache.org:8/path"));
    524        assertTrue(validator.isValid("http://www.apache.org:/path"));
    525    }
     515    /**
     516     * Non-regression test for VALIDATOR-380
     517     */
     518    @Test
     519    public void testValidator380() {
     520        UrlValidator validator = new UrlValidator();
     521        assertTrue(validator.isValid("http://www.apache.org:80/path"));
     522        assertTrue(validator.isValid("http://www.apache.org:8/path"));
     523        assertTrue(validator.isValid("http://www.apache.org:/path"));
     524    }
    526525
    527    /**
    528     * Unit test of {@link UrlValidator#getValidatorName}.
    529     */
    530    @Test
    531    public void testValidatorName() {
    532        assertEquals("URL validator", UrlValidator.getInstance().getValidatorName());
    533    }
     526    /**
     527     * Unit test of {@link UrlValidator#getValidatorName}.
     528     */
     529    @Test
     530    public void testValidatorName() {
     531        assertEquals("URL validator", UrlValidator.getInstance().getValidatorName());
     532    }
    534533
    535    //-------------------- Test data for creating a composite URL
    536    /**
    537     * The data given below approximates the 4 parts of a URL
    538     * {@code <scheme>://<authority><path>?<query>} except that the port number
    539     * is broken out of authority to increase the number of permutations.
    540     * A complete URL is composed of a scheme+authority+port+path+query,
    541     * all of which must be individually valid for the entire URL to be considered
    542     * valid.
    543     */
    544    ResultPair[] testUrlScheme = {new ResultPair("http://", true),
    545                                new ResultPair("ftp://", true),
    546                                new ResultPair("h3t://", true),
    547                                new ResultPair("3ht://", false),
    548                                new ResultPair("http:/", false),
    549                                new ResultPair("http:", false),
    550                                new ResultPair("http/", false),
    551                                new ResultPair("://", false),
    552                                new ResultPair("", true)};
     534    //-------------------- Test data for creating a composite URL
     535    /**
     536     * The data given below approximates the 4 parts of a URL
     537     * {@code <scheme>://<authority><path>?<query>} except that the port number
     538     * is broken out of authority to increase the number of permutations.
     539     * A complete URL is composed of a scheme+authority+port+path+query,
     540     * all of which must be individually valid for the entire URL to be considered
     541     * valid.
     542     */
     543    ResultPair[] testUrlScheme = {
     544            new ResultPair("http://", true),
     545            new ResultPair("ftp://", true),
     546            new ResultPair("h3t://", true),
     547            new ResultPair("3ht://", false),
     548            new ResultPair("http:/", false),
     549            new ResultPair("http:", false),
     550            new ResultPair("http/", false),
     551            new ResultPair("://", false),
     552            new ResultPair("", true)
     553    };
    553554
    554    ResultPair[] testUrlAuthority = {new ResultPair("www.google.com", true),
    555                                   new ResultPair("go.com", true),
    556                                   new ResultPair("go.au", true),
    557                                   new ResultPair("0.0.0.0", true),
    558                                   new ResultPair("255.255.255.255", true),
    559                                   new ResultPair("256.256.256.256", false),
    560                                   new ResultPair("255.com", true),
    561                                   new ResultPair("1.2.3.4.5", false),
    562                                   new ResultPair("1.2.3.4.", false),
    563                                   new ResultPair("1.2.3", false),
    564                                   new ResultPair(".1.2.3.4", false),
    565                                   new ResultPair("go.a", false),
    566                                   new ResultPair("go.a1a", false),
    567                                   new ResultPair("go.cc", true),
    568                                   new ResultPair("go.1aa", false),
    569                                   new ResultPair("aaa.", false),
    570                                   new ResultPair(".aaa", false),
    571                                   new ResultPair("aaa", false),
    572                                   new ResultPair("", false)
    573    };
    574    ResultPair[] testUrlPort = {new ResultPair(":80", true),
    575                              new ResultPair(":65535", true),
    576                              new ResultPair(":0", true),
    577                              new ResultPair("", true),
    578                              new ResultPair(":-1", false),
    579                              new ResultPair(":65636", true),
    580                              new ResultPair(":65a", false)
    581    };
    582    ResultPair[] testPath = {new ResultPair("/test1", true),
    583                           new ResultPair("/t123", true),
    584                           new ResultPair("/$23", true),
    585                           new ResultPair("/..", false),
    586                           new ResultPair("/../", false),
    587                           new ResultPair("/test1/", true),
    588                           new ResultPair("", true),
    589                           new ResultPair("/test1/file", true),
    590                           new ResultPair("/..//file", false),
    591                           new ResultPair("/test1//file", false)
    592    };
    593    //Test allow2slash, noFragment
    594    ResultPair[] testUrlPathOptions = {new ResultPair("/test1", true),
    595                                     new ResultPair("/t123", true),
    596                                     new ResultPair("/$23", true),
    597                                     new ResultPair("/..", false),
    598                                     new ResultPair("/../", false),
    599                                     new ResultPair("/test1/", true),
    600                                     new ResultPair("/#", false),
    601                                     new ResultPair("", true),
    602                                     new ResultPair("/test1/file", true),
    603                                     new ResultPair("/t123/file", true),
    604                                     new ResultPair("/$23/file", true),
    605                                     new ResultPair("/../file", false),
    606                                     new ResultPair("/..//file", false),
    607                                     new ResultPair("/test1//file", true),
    608                                     new ResultPair("/#/file", false)
    609    };
     555    ResultPair[] testUrlAuthority = {
     556            new ResultPair("www.google.com", true),
     557            new ResultPair("go.com", true),
     558            new ResultPair("go.au", true),
     559            new ResultPair("0.0.0.0", true),
     560            new ResultPair("255.255.255.255", true),
     561            new ResultPair("256.256.256.256", false),
     562            new ResultPair("255.com", true),
     563            new ResultPair("1.2.3.4.5", false),
     564            new ResultPair("1.2.3.4.", false),
     565            new ResultPair("1.2.3", false),
     566            new ResultPair(".1.2.3.4", false),
     567            new ResultPair("go.a", false),
     568            new ResultPair("go.a1a", false),
     569            new ResultPair("go.cc", true),
     570            new ResultPair("go.1aa", false),
     571            new ResultPair("aaa.", false),
     572            new ResultPair(".aaa", false),
     573            new ResultPair("aaa", false),
     574            new ResultPair("", false)
     575    };
     576
     577    ResultPair[] testUrlPort = {
     578            new ResultPair(":80", true),
     579            new ResultPair(":65535", true),
     580            new ResultPair(":0", true),
     581            new ResultPair("", true),
     582            new ResultPair(":-1", false),
     583            new ResultPair(":65636", true),
     584            new ResultPair(":65a", false)
     585    };
     586
     587    ResultPair[] testPath = {
     588            new ResultPair("/test1", true),
     589            new ResultPair("/t123", true),
     590            new ResultPair("/$23", true),
     591            new ResultPair("/..", false),
     592            new ResultPair("/../", false),
     593            new ResultPair("/test1/", true),
     594            new ResultPair("", true),
     595            new ResultPair("/test1/file", true),
     596            new ResultPair("/..//file", false),
     597            new ResultPair("/test1//file", false)
     598    };
     599
     600    //Test allow2slash, noFragment
     601    ResultPair[] testUrlPathOptions = {
     602            new ResultPair("/test1", true),
     603            new ResultPair("/t123", true),
     604            new ResultPair("/$23", true),
     605            new ResultPair("/..", false),
     606            new ResultPair("/../", false),
     607            new ResultPair("/test1/", true),
     608            new ResultPair("/#", false),
     609            new ResultPair("", true),
     610            new ResultPair("/test1/file", true),
     611            new ResultPair("/t123/file", true),
     612            new ResultPair("/$23/file", true),
     613            new ResultPair("/../file", false),
     614            new ResultPair("/..//file", false),
     615            new ResultPair("/test1//file", true),
     616            new ResultPair("/#/file", false)
     617    };
    610618
    611    ResultPair[] testUrlQuery = {new ResultPair("?action=view", true),
    612                               new ResultPair("?action=edit&mode=up", true),
    613                               new ResultPair("", true)
    614    };
     619    ResultPair[] testUrlQuery = {
     620            new ResultPair("?action=view", true),
     621            new ResultPair("?action=edit&mode=up", true),
     622            new ResultPair("", true)
     623    };
    615624
    616    Object[] testUrlParts = {testUrlScheme, testUrlAuthority, testUrlPort, testPath, testUrlQuery};
    617    Object[] testUrlPartsOptions = {testUrlScheme, testUrlAuthority, testUrlPort, testUrlPathOptions, testUrlQuery};
    618    int[] testPartsIndex = {0, 0, 0, 0, 0};
     625    Object[] testUrlParts = {testUrlScheme, testUrlAuthority, testUrlPort, testPath, testUrlQuery};
     626    Object[] testUrlPartsOptions = {testUrlScheme, testUrlAuthority, testUrlPort, testUrlPathOptions, testUrlQuery};
     627    int[] testPartsIndex = {0, 0, 0, 0, 0};
    619628
    620    //---------------- Test data for individual url parts ----------------
    621    private final String[] schemes = {"http", "gopher", "g0-To+.",
    622                                       "not_valid" // TODO this will need to be dropped if the ctor validates schemes
    623                                     };
     629    //---------------- Test data for individual url parts ----------------
     630    private final String[] schemes = {
     631            "http",
     632            "gopher",
     633            "g0-To+.",
     634            "not_valid" // TODO this will need to be dropped if the ctor validates schemes
     635    };
    624636
    625    ResultPair[] testScheme = {new ResultPair("http", true),
    626                             new ResultPair("ftp", false),
    627                             new ResultPair("httpd", false),
    628                             new ResultPair("gopher", true),
    629                             new ResultPair("g0-to+.", true),
    630                             new ResultPair("not_valid", false), // underscore not allowed
    631                             new ResultPair("HtTp", true),
    632                             new ResultPair("telnet", false)};
     637    ResultPair[] testScheme = {
     638            new ResultPair("http", true),
     639            new ResultPair("ftp", false),
     640            new ResultPair("httpd", false),
     641            new ResultPair("gopher", true),
     642            new ResultPair("g0-to+.", true),
     643            new ResultPair("not_valid", false), // underscore not allowed
     644            new ResultPair("HtTp", true),
     645            new ResultPair("telnet", false)
     646    };
    633647}
  • test/unit/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModelTest.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    7575
    7676    protected void ensureSelected(DefaultListSelectionModel model, Object... idx) {
    7777        if (idx == null) return;
    78         for (int i = 0; i < idx.length; i++) {
    79             if (idx[i] instanceof Integer) {
    80                 int j = (Integer) idx[i];
     78        for (Object object : idx) {
     79            if (object instanceof Integer) {
     80                int j = (Integer) object;
    8181                assertTrue(model.isSelectedIndex(j), "expected row " + j + " to be selected");
    8282                break;
    8383            }
    84             int[] rows = (int[]) idx[i];
     84            int[] rows = (int[]) object;
    8585            if (rows.length != 2) {
    8686                fail("illegal selection range. Either null or not length 2: " + Arrays.toString(rows));
    8787            }