Coverage Report - org.crosswire.jsword.index.search.SearcherFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
SearcherFactory
0%
0/23
N/A
6.5
 
 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.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  
  * Factory method for creating a new Searcher.
 35  
  * 
 36  
  * @see gnu.lgpl.License The GNU Lesser General Public License for details.
 37  
  * @author Joe Walker
 38  
  */
 39  
 public final class SearcherFactory {
 40  
     /**
 41  
      * Prevent instantiation
 42  
      */
 43  0
     private SearcherFactory() {
 44  0
     }
 45  
 
 46  
     /**
 47  
      * Create a new Searcher.
 48  
      * 
 49  
      * @param book the book
 50  
      * @return the searcher
 51  
      * @throws InstantiationException 
 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  
      * The log stream
 82  
      */
 83  0
     private static final Logger log = LoggerFactory.getLogger(SearcherFactory.class);
 84  
 }