| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| KeyFactory |
|
| 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.passage; | |
| 21 | ||
| 22 | /** | |
| 23 | * A Factory for new Keys and KeyLists. | |
| 24 | * | |
| 25 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
| 26 | * @author Joe Walker | |
| 27 | */ | |
| 28 | public interface KeyFactory { | |
| 29 | /** | |
| 30 | * Get a complete list of index entries. Create a Key that encompasses all | |
| 31 | * of the known valid keys for the given context. For a dictionary this will | |
| 32 | * include all of the entries in the dictionary, for a Bible this will | |
| 33 | * probably include all the verses in the Bible, but a commentary may well | |
| 34 | * miss some out. | |
| 35 | * | |
| 36 | * @return A Key that includes all of the known Keys | |
| 37 | */ | |
| 38 | Key getGlobalKeyList(); | |
| 39 | ||
| 40 | /** | |
| 41 | * Get a Key for the name, if possible. Otherwise return an empty Key. | |
| 42 | * | |
| 43 | * @param name | |
| 44 | * @return a valid key. | |
| 45 | */ | |
| 46 | Key getValidKey(String name); | |
| 47 | ||
| 48 | /** | |
| 49 | * Someone has typed in a reference to find, but we need a Key to actually | |
| 50 | * look it up. So we create a Key from the string if such a translation is | |
| 51 | * possible. The returned Key may be a BranchKey if the string represents | |
| 52 | * more than one Key. | |
| 53 | * | |
| 54 | * @param name | |
| 55 | * The string to translate into a Key | |
| 56 | * @return The Key corresponding to the input text | |
| 57 | * @throws NoSuchKeyException | |
| 58 | * If the name can not be parsed. | |
| 59 | */ | |
| 60 | Key getKey(String name) throws NoSuchKeyException; | |
| 61 | ||
| 62 | /** | |
| 63 | * Fetch an empty Key to which we can add Keys. Not all implementations of | |
| 64 | * Key are able to hold any type of Key, It isn't reasonable to expect a Key | |
| 65 | * of Bible verses (=Passage) to hold a dictionary Key. So each KeyFactory | |
| 66 | * must be able to create you an empty Key to which you can safely add other | |
| 67 | * Keys it generates. | |
| 68 | * | |
| 69 | * @return An empty Key that can hold other Keys from this factory. | |
| 70 | */ | |
| 71 | Key createEmptyKeyList(); | |
| 72 | } |