Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BlockType |
|
| 2.0;2 |
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.sword; | |
21 | ||
22 | import org.crosswire.jsword.JSOtherMsg; | |
23 | ||
24 | ||
25 | /** | |
26 | * Block types indicates the grain of compression. | |
27 | * | |
28 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
29 | * @author Joe Walker | |
30 | * @author DM Smith | |
31 | */ | |
32 | 0 | public enum BlockType { |
33 | /** | |
34 | * The level of compression is the Book | |
35 | */ | |
36 | 0 | BLOCK_BOOK ("BOOK", 'b'), |
37 | ||
38 | /** | |
39 | * The level of compression is the Book | |
40 | */ | |
41 | 0 | BLOCK_CHAPTER ("CHAPTER", 'c'), |
42 | ||
43 | /** | |
44 | * The level of compression is the Book | |
45 | */ | |
46 | 0 | BLOCK_VERSE ("VERSE", 'v'); |
47 | ||
48 | /** | |
49 | * Simple ctor | |
50 | */ | |
51 | 0 | BlockType(String name, char indicator) { |
52 | 0 | this.name = name; |
53 | 0 | this.indicator = indicator; |
54 | 0 | } |
55 | ||
56 | /** | |
57 | * Return a character indicating the grain of compression. This is used in | |
58 | * the names of compressed sword books. | |
59 | * | |
60 | * @return the indicator | |
61 | */ | |
62 | public char getIndicator() { | |
63 | 0 | return indicator; |
64 | } | |
65 | ||
66 | /** | |
67 | * Lookup method to convert from a String | |
68 | * | |
69 | * @param name the string representation of the block type | |
70 | * @return the matching block type | |
71 | */ | |
72 | public static BlockType fromString(String name) { | |
73 | 0 | for (BlockType v : values()) { |
74 | 0 | if (v.name.equalsIgnoreCase(name)) { |
75 | 0 | return v; |
76 | } | |
77 | } | |
78 | ||
79 | 0 | throw new ClassCastException(JSOtherMsg.lookupText("BlockType {0} is not defined!", name)); |
80 | } | |
81 | ||
82 | /* (non-Javadoc) | |
83 | * @see java.lang.Enum#toString() | |
84 | */ | |
85 | @Override | |
86 | public String toString() { | |
87 | 0 | return name; |
88 | } | |
89 | ||
90 | /** | |
91 | * The name of the BlockType | |
92 | */ | |
93 | private String name; | |
94 | /** | |
95 | * The indicator for the BlockType | |
96 | */ | |
97 | private char indicator; | |
98 | } |