Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EditType |
|
| 2.2;2.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, 2007 - 2016 | |
18 | * | |
19 | */ | |
20 | package org.crosswire.common.diff; | |
21 | ||
22 | /** | |
23 | * An Enumeration of the possible Edits. | |
24 | * | |
25 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
26 | * @author DM Smith | |
27 | */ | |
28 | 0 | public enum EditType { |
29 | /** | |
30 | * Delete a sequence. | |
31 | */ | |
32 | 0 | DELETE("Delete", '-'), |
33 | ||
34 | /** | |
35 | * Insert a sequence | |
36 | */ | |
37 | 0 | INSERT("Insert", '+'), |
38 | ||
39 | /** | |
40 | * Equal sequences | |
41 | */ | |
42 | 0 | EQUAL("Equal", ' '); |
43 | ||
44 | /** | |
45 | * @param name | |
46 | * The name of the EditType | |
47 | * @param symbol | |
48 | * The symbol of the EditType | |
49 | */ | |
50 | 0 | EditType(String name, char symbol) { |
51 | 0 | this.name = name; |
52 | 0 | this.symbol = symbol; |
53 | 0 | } |
54 | ||
55 | /** | |
56 | * @return the symbol for this EditType | |
57 | */ | |
58 | public char getSymbol() { | |
59 | 0 | return symbol; |
60 | } | |
61 | ||
62 | /** | |
63 | * Lookup method to find an EditType by name. | |
64 | * | |
65 | * @param name the case insensitive representation of the desired EditType | |
66 | * @return the desired EditType or null if not found. | |
67 | */ | |
68 | public static EditType fromString(String name) { | |
69 | 0 | for (EditType v : values()) { |
70 | 0 | if (v.name().equalsIgnoreCase(name)) { |
71 | 0 | return v; |
72 | } | |
73 | } | |
74 | ||
75 | // cannot get here | |
76 | 0 | assert false; |
77 | 0 | return null; |
78 | } | |
79 | ||
80 | /** | |
81 | * Lookup method to find an EditType by symbol. | |
82 | * | |
83 | * @param symbol | |
84 | * The symbol of the EditType | |
85 | * @return the desired EditType or null if not found. | |
86 | */ | |
87 | public static EditType fromSymbol(char symbol) { | |
88 | 0 | for (EditType v : values()) { |
89 | 0 | if (v.symbol == symbol) { |
90 | 0 | return v; |
91 | } | |
92 | } | |
93 | ||
94 | // cannot get here | |
95 | 0 | assert false; |
96 | 0 | return null; |
97 | } | |
98 | ||
99 | /* (non-Javadoc) | |
100 | * @see java.lang.Enum#toString() | |
101 | */ | |
102 | @Override | |
103 | public String toString() { | |
104 | 0 | return name; |
105 | } | |
106 | ||
107 | /** | |
108 | * The name of the EditType | |
109 | */ | |
110 | private String name; | |
111 | ||
112 | /** | |
113 | * The symbol representing the EditType | |
114 | */ | |
115 | private char symbol; | |
116 | } |