public List preParse()

in src/main/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java [93:135]


    public List<String> preParse(final List<String> original) {
        final HashMap<String, Integer> existingEntries = new HashMap<>();
        final ListIterator<String> iter = original.listIterator();
        while (iter.hasNext()) {
            final String entry = iter.next().trim();
            MatchResult result;
            final Matcher _preparse_matcher_ = preparsePattern.matcher(entry);
            if (_preparse_matcher_.matches()) {
                result = _preparse_matcher_.toMatchResult();
                final String name = result.group(1);
                final String version = result.group(2);
                final Integer nv = Integer.valueOf(version);
                final Integer existing = existingEntries.get(name);
                if ((null != existing) && (nv.intValue() < existing.intValue())) {
                    iter.remove(); // removes older version from original list.
                    continue;
                }
                existingEntries.put(name, nv);
            }

        }
        // we've now removed all entries less than with less than the largest
        // version number for each name that were listed after the largest.
        // we now must remove those with smaller than the largest version number
        // for each name that were found before the largest
        while (iter.hasPrevious()) {
            final String entry = iter.previous().trim();
            MatchResult result = null;
            final Matcher _preparse_matcher_ = preparsePattern.matcher(entry);
            if (_preparse_matcher_.matches()) {
                result = _preparse_matcher_.toMatchResult();
                final String name = result.group(1);
                final String version = result.group(2);
                final int nv = Integer.parseInt(version);
                final Integer existing = existingEntries.get(name);
                if ((null != existing) && (nv < existing.intValue())) {
                    iter.remove(); // removes older version from original list.
                }
            }

        }
        return original;
    }