Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
IndexManager |
|
| 1.0;1 |
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 | */ | |
20 | package org.crosswire.jsword.index; | |
21 | ||
22 | import java.net.URI; | |
23 | ||
24 | import org.crosswire.jsword.book.Book; | |
25 | import org.crosswire.jsword.book.BookException; | |
26 | ||
27 | /** | |
28 | * Manages the life-cycle of an Index. | |
29 | * | |
30 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
31 | * @author Joe Walker | |
32 | */ | |
33 | public interface IndexManager { | |
34 | /** | |
35 | * Detects if index data has been stored and is valid for this Bible. | |
36 | * | |
37 | * @param book the book | |
38 | * @return true if the book has a usable index | |
39 | */ | |
40 | boolean isIndexed(Book book); | |
41 | ||
42 | /** | |
43 | * Create a new Searcher. | |
44 | * | |
45 | * @param book the book | |
46 | * @return an index that can be searched. | |
47 | * @throws BookException | |
48 | */ | |
49 | Index getIndex(Book book) throws BookException; | |
50 | ||
51 | /** | |
52 | * Detect or checking whether this book needs reindexing. | |
53 | * It is safe methods, you can always call it whether the book | |
54 | * is already indexed or not. | |
55 | * This check for <br> | |
56 | * <pre> | |
57 | * - isIndexed(Book book) | |
58 | * - Is index valid, eg index version changed incompatibly (due to internal structure change or search engine update) | |
59 | * - | |
60 | * </pre> | |
61 | * | |
62 | * @param book the Book | |
63 | * @return true if no index present or current index is of incompatible/older version | |
64 | */ | |
65 | boolean needsReindexing(Book book); | |
66 | ||
67 | /** | |
68 | * Read from the given source version to generate ourselves. On completion | |
69 | * of this method the index should be usable. | |
70 | * | |
71 | * @param book The book that should be indexed | |
72 | */ | |
73 | void scheduleIndexCreation(Book book); | |
74 | ||
75 | /** | |
76 | * We have downloaded a search index to a zip file. It should be installed | |
77 | * from here. | |
78 | * | |
79 | * @param book | |
80 | * The book that we downloaded an index for | |
81 | * @param tempDest | |
82 | * The URI of a zip file to install | |
83 | * @throws BookException | |
84 | */ | |
85 | void installDownloadedIndex(Book book, URI tempDest) throws BookException; | |
86 | ||
87 | /** | |
88 | * Tidy up after yourself and remove all the files that make up any indexes | |
89 | * you created. | |
90 | * | |
91 | * @param book the book who's index should be deleted. | |
92 | * @throws BookException | |
93 | */ | |
94 | void deleteIndex(Book book) throws BookException; | |
95 | ||
96 | /** | |
97 | * Close all indexes associated with this Index Manager | |
98 | */ | |
99 | void closeAllIndexes(); | |
100 | ||
101 | /** | |
102 | * Obtain the current IndexPolicy. Defaults to IndexPolicyAdapter. | |
103 | * | |
104 | * @return the current IndexPolicy | |
105 | */ | |
106 | IndexPolicy getIndexPolicy(); | |
107 | ||
108 | /** | |
109 | * Set the desired IndexPolicy. Setting to null will cause the | |
110 | * IndexPolicyAdapter to be used. | |
111 | * | |
112 | * @param policy the IndexPolicy to use when creating indexes. | |
113 | */ | |
114 | void setIndexPolicy(IndexPolicy policy); | |
115 | } |