| BookCategory.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 * Copyright: 2005
18 * The copyright to this program is held by it's authors.
19 *
20 */
21 package org.crosswire.jsword.book;
22
23 import org.crosswire.jsword.JSMsg;
24
25 /**
26 * An Enumeration of the possible types of Book.
27 *
28 * @see gnu.lgpl.License for license details.<br>
29 * The copyright to this program is held by it's authors.
30 * @author Joe Walker [joe at eireneh dot com]
31 * @author DM Smith
32 */
33 public enum BookCategory {
34 /** Books that are Bibles */
35 // TRANSLATOR: The name for the book category consisting of Bibles.
36 BIBLE("Biblical Texts", JSMsg.gettext("Biblical Texts")),
37
38 /** Books that are Dictionaries */
39 // TRANSLATOR: The name for the book category consisting of Lexicons and Dictionaries.
40 DICTIONARY("Lexicons / Dictionaries", JSMsg.gettext("Dictionaries")),
41
42 /** Books that are Commentaries */
43 // TRANSLATOR: The name for the book category consisting of Commentaries.
44 COMMENTARY("Commentaries", JSMsg.gettext("Commentaries")),
45
46 /** Books that are indexed by day. AKA, Daily Devotions */
47 // TRANSLATOR: The name for the book category consisting of Daily Devotions, indexed by day of the year.
48 DAILY_DEVOTIONS("Daily Devotional", JSMsg.gettext("Daily Devotionals")),
49
50 /** Books that map words from one language to another. */
51 // TRANSLATOR: The name for the book category consisting of Glossaries that map words/phrases from one language into another.
52 GLOSSARY("Glossaries", JSMsg.gettext("Glossaries")),
53
54 /** Books that are questionable. */
55 // TRANSLATOR: The name for the book category consisting of books that are considered unorthodox by mainstream Christianity.
56 QUESTIONABLE("Cults / Unorthodox / Questionable Material", JSMsg.gettext("Cults / Unorthodox / Questionable Materials")),
57
58 /** Books that are just essays. */
59 // TRANSLATOR: The name for the book category consisting of just essays.
60 ESSAYS("Essays", JSMsg.gettext("Essays")),
61
62 /** Books that are predominately images. */
63 // TRANSLATOR: The name for the book category consisting of books containing mostly images.
64 IMAGES("Images", JSMsg.gettext("Images")),
65
66 /** Books that are a collection of maps. */
67 // TRANSLATOR: The name for the book category consisting of books containing mostly maps.
68 MAPS("Maps", JSMsg.gettext("Maps")),
69
70 /** Books that are just books. */
71 // TRANSLATOR: The name for the book category consisting of general books.
72 GENERAL_BOOK("Generic Books", JSMsg.gettext("General Books")),
73
74 /** Books that are not any of the above. This is a catch all for new book categories. */
75 // TRANSLATOR: The name for the book category consisting of books not in any of the other categories.
76 OTHER("Other", JSMsg.gettext("Other"));
77
78 /**
79 * @param name
80 * The name of the BookCategory
81 */
82 private BookCategory(String name, String externalName) {
83 this.name = name;
84 this.externalName = externalName;
85 }
86
87 /**
88 * Lookup method to convert from a String
89 */
90 public static BookCategory fromString(String name) {
91 for (BookCategory o : BookCategory.values()) {
92 if (o.name.equalsIgnoreCase(name)) {
93 return o;
94 }
95 }
96 return OTHER;
97 }
98
99 /**
100 * Lookup method to convert from a String
101 */
102 public static BookCategory fromExternalString(String name) {
103 for (BookCategory o : BookCategory.values()) {
104 if (o.externalName.equalsIgnoreCase(name)) {
105 return o;
106 }
107 }
108 return OTHER;
109 }
110
111 /**
112 * Lookup method to convert from an integer
113 */
114 public static BookCategory fromInteger(int i) {
115 for (BookCategory o : BookCategory.values()) {
116 if (i == o.ordinal()) {
117 return o;
118 }
119 }
120 return OTHER;
121 }
122
123 /**
124 * @return the internal name.
125 */
126 public String getName() {
127 return name;
128 }
129
130 /**
131 * @return the internationalized name.
132 */
133 @Override
134 public String toString() {
135 return externalName;
136 }
137
138 /**
139 * The names of the BookCategory
140 */
141 private transient String name;
142 private transient String externalName;
143 }
144