Changeset 12383 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2017-06-10T00:50:51+02:00 (7 years ago)
Author:
Don-vip
Message:

see #14929 - new methods to ease the direct handling of filters

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/FilterMatcher.java

    r12121 r12383  
    325325    }
    326326
     327    /**
     328     * Returns a new {@code FilterMatcher} containing the given filters.
     329     * @param filters filters to add to the resulting filter matcher
     330     * @return a new {@code FilterMatcher} containing the given filters
     331     * @throws ParseError if the search expression in a filter cannot be parsed
     332     * @since 12383
     333     */
     334    public static FilterMatcher of(Filter... filters) throws ParseError {
     335        FilterMatcher result = new FilterMatcher();
     336        for (Filter filter : filters) {
     337            result.add(filter);
     338        }
     339        return result;
     340    }
    327341}
  • trunk/src/org/openstreetmap/josm/data/osm/FilterWorker.java

    r10716 r12383  
    55import java.util.Collections;
    66
     7import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    78import org.openstreetmap.josm.data.osm.FilterMatcher.FilterType;
    89import org.openstreetmap.josm.tools.SubclassFilteredCollection;
     
    1920    private FilterWorker() {
    2021        // Hide default constructor for utils classes
     22    }
     23
     24    /**
     25     * Apply the filters to the primitives of the data set.
     26     *
     27     * @param all the collection of primitives for that the filter state should be updated
     28     * @param filters the filters
     29     * @return true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process
     30     * @throws ParseError if the search expression in a filter cannot be parsed
     31     * @since 12383
     32     */
     33    public static boolean executeFilters(Collection<OsmPrimitive> all, Filter... filters) throws ParseError {
     34        return executeFilters(all, FilterMatcher.of(filters));
    2135    }
    2236
Note: See TracChangeset for help on using the changeset viewer.