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