| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
package org.crosswire.jsword.index.search; |
| 21 | |
|
| 22 | |
import java.io.IOException; |
| 23 | |
|
| 24 | |
import org.crosswire.common.util.PluginUtil; |
| 25 | |
import org.crosswire.jsword.book.Book; |
| 26 | |
import org.crosswire.jsword.book.BookException; |
| 27 | |
import org.crosswire.jsword.index.Index; |
| 28 | |
import org.crosswire.jsword.index.IndexManager; |
| 29 | |
import org.crosswire.jsword.index.IndexManagerFactory; |
| 30 | |
import org.slf4j.Logger; |
| 31 | |
import org.slf4j.LoggerFactory; |
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
public final class SearcherFactory { |
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | 0 | private SearcherFactory() { |
| 44 | 0 | } |
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
public static Searcher createSearcher(Book book) throws InstantiationException { |
| 54 | |
try { |
| 55 | 0 | IndexManager imanager = IndexManagerFactory.getIndexManager(); |
| 56 | 0 | Index index = imanager.getIndex(book); |
| 57 | |
|
| 58 | 0 | Searcher parser = PluginUtil.getImplementation(Searcher.class); |
| 59 | 0 | parser.init(index); |
| 60 | |
|
| 61 | 0 | return parser; |
| 62 | 0 | } catch (IOException e) { |
| 63 | 0 | log.error("createSearcher failed", e); |
| 64 | 0 | throw new InstantiationException(); |
| 65 | 0 | } catch (BookException e) { |
| 66 | 0 | log.error("createSearcher failed", e); |
| 67 | 0 | throw new InstantiationException(); |
| 68 | 0 | } catch (ClassCastException e) { |
| 69 | 0 | log.error("createSearcher failed", e); |
| 70 | 0 | throw new InstantiationException(); |
| 71 | 0 | } catch (ClassNotFoundException e) { |
| 72 | 0 | log.error("createSearcher failed", e); |
| 73 | 0 | throw new InstantiationException(); |
| 74 | 0 | } catch (IllegalAccessException e) { |
| 75 | 0 | log.error("createSearcher failed", e); |
| 76 | 0 | throw new InstantiationException(); |
| 77 | |
} |
| 78 | |
} |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | 0 | private static final Logger log = LoggerFactory.getLogger(SearcherFactory.class); |
| 84 | |
} |