Ignore:
Timestamp:
2013-12-26T15:19:31+01:00 (10 years ago)
Author:
simon04
Message:

see #9414 - MapCSS-based tagchecker: provide {i.key}, {i.value}, {i.tag} variables to messages/fixes which refer to the corresponding match condition

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6524 r6538  
    3838import java.util.Iterator;
    3939import java.util.List;
     40import java.util.regex.Matcher;
    4041import java.util.zip.GZIPInputStream;
    4142import java.util.zip.ZipFile;
     
    835836        return String.format("%d %s %d %s", days, trn("day", "days", days), elapsedTime/3600000, tr("h"));
    836837    }
     838
     839    /**
     840     * Returns a list of capture groups if {@link Matcher#matches()}, or {@code null}.
     841     * The first element (index 0) is the complete match.
     842     * Further elements correspond to the parts in parentheses of the regular expression.
     843     * @param m the matcher
     844     * @return a list of capture groups if {@link Matcher#matches()}, or {@code null}.
     845     */
     846    public static List<String> getMatches(final Matcher m) {
     847        if (m.matches()) {
     848            List<String> result = new ArrayList<String>(m.groupCount() + 1);
     849            for (int i = 0; i <= m.groupCount(); i++) {
     850                result.add(m.group(i));
     851            }
     852            return result;
     853        } else {
     854            return null;
     855        }
     856    }
    837857}
Note: See TracChangeset for help on using the changeset viewer.