| Nils Diewald | 01ff7af | 2015-02-04 22:54:26 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap.collection; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 2 | |
| 3 | import java.util.*; |
| 4 | |
| 5 | import org.apache.lucene.search.RegexpQuery; |
| 6 | import org.apache.lucene.index.Term; |
| 7 | |
| 8 | /** |
| 9 | * @author Nils Diewald |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 10 | * |
| 11 | * RegexFilter implements a helper object for |
| 12 | * regular expressions used in KorapFilter |
| 13 | * constraints. |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | public class RegexFilter { |
| 17 | String regex; |
| 18 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 19 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 20 | public RegexFilter (String regex) { |
| Nils Diewald | 01ff7af | 2015-02-04 22:54:26 +0000 | [diff] [blame] | 21 | this.regex = regex; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 22 | }; |
| 23 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 24 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 25 | public RegexpQuery toQuery (String field) { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 26 | return new RegexpQuery(new Term(field, this.regex)); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 27 | }; |
| 28 | }; |