source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/properties/SearchBasedRowFilter.java@ 12656

Last change on this file since 12656 was 12656, checked in by Don-vip, 7 years ago

see #15182 - move SearchCompiler from actions.search to data.osm.search

File size: 1.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.properties;
3
4import javax.swing.RowFilter;
5import javax.swing.table.TableModel;
6
7import org.openstreetmap.josm.data.osm.Tag;
8import org.openstreetmap.josm.data.osm.search.SearchCompiler;
9
10/**
11 * A {@link RowFilter} implementation which matches tags w.r.t. the specified filter's
12 * {@link org.openstreetmap.josm.data.osm.search.SearchCompiler.Match#match(org.openstreetmap.josm.data.osm.Tagged)} method.
13 *
14 * <p>An {@link javax.swing.RowFilter.Entry}'s column 0 is considered as key, and column 1 is considered as value.</p>
15 */
16class SearchBasedRowFilter extends RowFilter<TableModel, Integer> {
17
18 final SearchCompiler.Match filter;
19
20 /**
21 * Constructs a new {@code SearchBasedRowFilter} with the given filter.
22 * @param filter the filter used to match tags
23 */
24 SearchBasedRowFilter(SearchCompiler.Match filter) {
25 this.filter = filter;
26 }
27
28 @Override
29 public boolean include(Entry entry) {
30 final String key = entry.getStringValue(0);
31 final String value = entry.getStringValue(1);
32 return filter.match(new Tag(key, value));
33 }
34
35}
Note: See TracBrowser for help on using the repository browser.