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  
23  /**
24   * An Enumeration of the possible states of an index.
25   * 
26   * @see gnu.lgpl.License The GNU Lesser General Public License for details.
27   * @author Joe Walker
28   * @author DM Smith
29   */
30  public enum IndexStatus {
31      /**
32       * There is a complete and ready to use search index
33       */
34      DONE("Indexed"),
35  
36      /**
37       * There is no search index, and no plans to create one
38       */
39      UNDONE("No Index"),
40  
41      /**
42       * This Book has been scheduled for index creation
43       */
44      SCHEDULED("Scheduled"),
45  
46      /**
47       * An index is currently being generated for this Book
48       */
49      CREATING("Creating"),
50  
51      /**
52       * An index is no longer valid and needs to be discarded.
53       */
54      INVALID("Invalid");
55  
56      /**
57       * @param name
58       *            The name of the BookCategory
59       */
60      IndexStatus(String name) {
61          this.name = name;
62      }
63  
64      /**
65       * Lookup method to convert from a String
66       * 
67       * @param name 
68       * @return the matching index status
69       */
70      public static IndexStatus fromString(String name) {
71          for (IndexStatus o : IndexStatus.values()) {
72              if (o.name.equalsIgnoreCase(name)) {
73                  return o;
74              }
75          }
76          // cannot get here
77          assert false;
78          return null;
79      }
80  
81      @Override
82      public String toString() {
83          return name;
84      }
85  
86      /**
87       * The name of the IndexStatus
88       */
89      private String name;
90  
91  }
92