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: 2007
18   *     The copyright to this program is held by it's authors.
19   *
20   * ID: $Id: EditType.java 2050 2010-12-09 15:31:45Z dmsmith $
21   */
22  package org.crosswire.common.diff;
23  
24  /**
25   * An Enumeration of the possible Edits.
26   * 
27   * @see gnu.lgpl.License for license details.<br>
28   *      The copyright to this program is held by it's authors.
29   * @author DM Smith [dmsmith555 at yahoo dot com]
30   */
31  public enum EditType  {
32      /**
33       * Delete a sequence.
34       */
35      DELETE  ("Delete", '-'),
36  
37      /**
38       * Insert a sequence
39       */
40      INSERT  ("Insert", '+'),
41  
42      /**
43       * Equal sequences
44       */
45      EQUAL ("Equal", ' ');
46  
47      /**
48       * @param name
49       *            The name of the FeatureType
50       */
51      private EditType(String name, char symbol) {
52          this.name = name;
53          this.symbol = symbol;
54      }
55  
56      /**
57       * @return te symbol for this EditType
58       */
59      public char getSymbol() {
60          return symbol;
61      }
62  
63      /**
64       * Get a CompressorType from a String
65       * 
66       * @param name the case insensitive representation of the desired CompressorType
67       * @return the desired compressor or null if not found.
68       */
69      public static EditType fromString(String name) {
70          for (EditType v : values()) {
71              if (v.name().equalsIgnoreCase(name)) {
72                  return v;
73              }
74          }
75  
76          // cannot get here
77          assert false;
78          return null;
79      }
80  
81      /**
82       * Lookup method to convert from a String
83       */
84      public static EditType fromSymbol(char symbol) {
85          for (EditType v : values()) {
86              if (v.symbol == symbol) {
87                  return v;
88              }
89          }
90  
91          // cannot get here
92          assert false;
93          return null;
94      }
95  
96      /*
97       * (non-Javadoc)
98       * 
99       * @see java.lang.Object#toString()
100      */
101     @Override
102     public String toString() {
103         return name;
104     }
105 
106     /**
107      * The name of the FeatureType
108      */
109     private String name;
110 
111     /**
112      * The symbol representing the EditType
113      */
114     private char symbol;
115 }
116