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 as published by
5    * the Free Software Foundation. This program is distributed in the hope
6    * that it will be useful, but WITHOUT ANY WARRANTY; without even the
7    * 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   * Copyright: 2005
18   *     The copyright to this program is held by it's authors.
19   *
20   * ID: $Id: Index.java 1966 2009-10-30 01:15:14Z dmsmith $
21   */
22  package org.crosswire.jsword.index;
23  
24  import org.crosswire.jsword.book.BookException;
25  import org.crosswire.jsword.index.search.SearchModifier;
26  import org.crosswire.jsword.passage.Key;
27  import org.crosswire.jsword.passage.NoSuchKeyException;
28  
29  /**
30   * An index into a body of text that knows what words exist and where they are.
31   * 
32   * @see gnu.lgpl.License for license details.<br>
33   *      The copyright to this program is held by it's authors.
34   * @author Joe Walker [joe at eireneh dot com]
35   */
36  public interface Index {
37      /**
38       * Find the set of references that satisfy the query. Query is anything that
39       * the underlying index can handle. If the <code>query</code> being searched
40       * for is null then an empty Key <b>MUST</b> be returned. Users of this
41       * index may use this functionality to get empty KeyLists which they then
42       * use to aggregate other searches done on this index.
43       * 
44       * @param query
45       *            The text to search for
46       * @return The references to the word
47       */
48      Key find(String query) throws BookException;
49  
50      /**
51       * An index must be able to create KeyLists for users in a similar way to
52       * the Book that it is indexing.
53       * 
54       * @param name
55       *            The string to convert to a Key
56       * @return A new Key representing the given string, if possible
57       * @throws NoSuchKeyException
58       *             If the string can not be turned into a Key
59       * @see org.crosswire.jsword.passage.KeyFactory#getKey(String)
60       */
61      Key getKey(String name) throws NoSuchKeyException;
62  
63      /**
64       * Set any modifier for the current and subsequent search. Using null will
65       * clear the search modifier.
66       * 
67       * @param modifier
68       *            how to modify the search and its results.
69       */
70      void setSearchModifier(SearchModifier modifier);
71  
72      /**
73       * Get the current SearchModifier. If there is none then return null.
74       * 
75       * @return the current search modifier, or null if there is not one.
76       */
77      SearchModifier getSearchModifier();
78  }
79