Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BlurQuery |
|
| 2.3333333333333335;2.333 |
1 | /** | |
2 | * Distribution License: | |
3 | * JSword is free software; you can redistribute it and/or modify it under | |
4 | * the terms of the GNU Lesser General Public License, version 2.1 or later | |
5 | * as published by the Free Software Foundation. This program is distributed | |
6 | * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
7 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
8 | * See the GNU Lesser General Public License for more details. | |
9 | * | |
10 | * The License is available on the internet at: | |
11 | * http://www.gnu.org/copyleft/lgpl.html | |
12 | * or by writing to: | |
13 | * Free Software Foundation, Inc. | |
14 | * 59 Temple Place - Suite 330 | |
15 | * Boston, MA 02111-1307, USA | |
16 | * | |
17 | * © CrossWire Bible Society, 2005 - 2016 | |
18 | */ | |
19 | package org.crosswire.jsword.index.query; | |
20 | ||
21 | import org.crosswire.jsword.book.BookException; | |
22 | import org.crosswire.jsword.index.Index; | |
23 | import org.crosswire.jsword.passage.Key; | |
24 | import org.crosswire.jsword.passage.RestrictionType; | |
25 | ||
26 | /** | |
27 | * A blur query specifies how much to blur the results of the right query before | |
28 | * ANDing it to the left. | |
29 | * | |
30 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
31 | * @author DM Smith | |
32 | */ | |
33 | public class BlurQuery extends AbstractBinaryQuery { | |
34 | /** | |
35 | * Create a query that specifies how much to blur the results of the right | |
36 | * query before ANDing it to the left. | |
37 | * | |
38 | * @param theLeftQuery | |
39 | * @param theRightQuery | |
40 | * @param theFactor the amount of blurring | |
41 | */ | |
42 | public BlurQuery(Query theLeftQuery, Query theRightQuery, int theFactor) { | |
43 | 0 | super(theLeftQuery, theRightQuery); |
44 | 0 | factor = theFactor; |
45 | 0 | } |
46 | ||
47 | /* | |
48 | * (non-Javadoc) | |
49 | * | |
50 | * @see | |
51 | * org.crosswire.jsword.index.search.parse.Query#find(org.crosswire.jsword | |
52 | * .index.search.Index) | |
53 | */ | |
54 | public Key find(Index index) throws BookException { | |
55 | 0 | Key left = getLeftQuery().find(index); |
56 | ||
57 | 0 | if (left.isEmpty()) { |
58 | 0 | return left; |
59 | } | |
60 | ||
61 | 0 | Key right = getRightQuery().find(index); |
62 | ||
63 | 0 | if (right.isEmpty()) { |
64 | 0 | return right; |
65 | } | |
66 | ||
67 | 0 | right.blur(factor, RestrictionType.getDefaultBlurRestriction()); |
68 | ||
69 | 0 | left.retainAll(right); |
70 | ||
71 | 0 | return left; |
72 | } | |
73 | ||
74 | /** | |
75 | * @return the blur factor | |
76 | */ | |
77 | public int getFactor() { | |
78 | 0 | return factor; |
79 | } | |
80 | ||
81 | private int factor; | |
82 | } |