Index.java |
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 org.crosswire.jsword.book.BookException; 23 import org.crosswire.jsword.index.search.SearchModifier; 24 import org.crosswire.jsword.passage.Key; 25 import org.crosswire.jsword.passage.NoSuchKeyException; 26 27 /** 28 * An index into a body of text that knows what words exist and where they are. 29 * 30 * @see gnu.lgpl.License The GNU Lesser General Public License for details. 31 * @author Joe Walker 32 */ 33 public interface Index { 34 /** 35 * Find the set of references that satisfy the query. Query is anything that 36 * the underlying index can handle. If the <code>query</code> being searched 37 * for is null then an empty Key <b>MUST</b> be returned. Users of this 38 * index may use this functionality to get empty KeyLists which they then 39 * use to aggregate other searches done on this index. 40 * 41 * @param query 42 * The text to search for 43 * @return The references to the word 44 * @throws BookException 45 */ 46 Key find(String query) throws BookException; 47 48 /** 49 * An index must be able to create KeyLists for users in a similar way to 50 * the Book that it is indexing. 51 * 52 * @param name 53 * The string to convert to a Key 54 * @return A new Key representing the given string, if possible 55 * @throws NoSuchKeyException 56 * If the string can not be turned into a Key 57 * @see org.crosswire.jsword.passage.KeyFactory#getKey(String) 58 */ 59 Key getKey(String name) throws NoSuchKeyException; 60 61 /** 62 * Set any modifier for the current and subsequent search. Using null will 63 * clear the search modifier. 64 * 65 * @param modifier 66 * how to modify the search and its results. 67 */ 68 void setSearchModifier(SearchModifier modifier); 69 70 /** 71 * Get the current SearchModifier. If there is none then return null. 72 * 73 * @return the current search modifier, or null if there is not one. 74 */ 75 SearchModifier getSearchModifier(); 76 77 /** 78 * Closes resources related to the index 79 */ 80 void close(); 81 } 82