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 as published by
5    * the Free Software Foundation. This program is distributed in the hope
6    * that it will be useful, but WITHOUT ANY WARRANTY; without even the
7    * 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   * ID: $Id: BlockType.java 2099 2011-03-07 17:13:00Z dmsmith $
21   */
22  package org.crosswire.jsword.book.sword;
23  
24  import org.crosswire.jsword.JSOtherMsg;
25  
26  
27  /**
28   * Block types indicates the grain of compression.
29   * 
30   * @see gnu.lgpl.License for license details.<br>
31   *      The copyright to this program is held by it's authors.
32   * @author Joe Walker [joe at eireneh dot com]
33   * @author DM Smith [dmsmith555 at yahoo dot com]
34   */
35  public enum BlockType {
36      /**
37       * The level of compression is the Book
38       */
39      BLOCK_BOOK ("BOOK", 'b'),
40  
41      /**
42       * The level of compression is the Book
43       */
44      BLOCK_CHAPTER ("CHAPTER", 'c'),
45  
46      /**
47       * The level of compression is the Book
48       */
49      BLOCK_VERSE ("VERSE", 'v');
50  
51      /**
52       * Simple ctor
53       */
54      private BlockType(String name, char indicator) {
55          this.name = name;
56          this.indicator = indicator;
57      }
58  
59      /**
60       * Return a character indicating the grain of compression. This is used in
61       * the names of compressed sword books.
62       * 
63       * @return the indicator
64       */
65      public char getIndicator() {
66          return indicator;
67      }
68  
69      /**
70       * Lookup method to convert from a String
71       */
72      public static BlockType fromString(String name) {
73          for (BlockType v : values()) {
74              if (v.name.equalsIgnoreCase(name)) {
75                  return v;
76              }
77          }
78  
79          throw new ClassCastException(JSOtherMsg.lookupText("DataType {0} is not defined!", name));
80      }
81  
82      /* (non-Javadoc)
83       * @see java.lang.Enum#toString()
84       */
85      @Override
86      public String toString() {
87          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  }
99