|
Last change
on this file since 12656 was 12656, checked in by Don-vip, 9 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.
|
|---|
| 2 | package org.openstreetmap.josm.gui.dialogs.properties;
|
|---|
| 3 |
|
|---|
| 4 | import javax.swing.RowFilter;
|
|---|
| 5 | import javax.swing.table.TableModel;
|
|---|
| 6 |
|
|---|
| 7 | import org.openstreetmap.josm.data.osm.Tag;
|
|---|
| 8 | import 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 | */
|
|---|
| 16 | class 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.