@@ -39,17 +39,17 @@ public class Metaphone implements StringEncoder {
3939 /**
4040 * Five values in the English language
4141 */
42- private String vowels = "AEIOU" ;
42+ private static final String VOWELS = "AEIOU" ;
4343
4444 /**
4545 * Variable used in Metaphone algorithm
4646 */
47- private String frontv = "EIY" ;
47+ private static final String FRONTV = "EIY" ;
4848
4949 /**
5050 * Variable used in Metaphone algorithm
5151 */
52- private String varson = "CSPTG" ;
52+ private static final String VARSON = "CSPTG" ;
5353
5454 /**
5555 * The max code length for metaphone is 4
@@ -152,15 +152,15 @@ public String metaphone(String txt) {
152152 /* discard if SCI, SCE or SCY */
153153 if ( isPreviousChar (local , n , 'S' ) &&
154154 !isLastChar (wdsz , n ) &&
155- (this . frontv .indexOf (local .charAt (n + 1 )) >= 0 ) ) {
155+ (FRONTV .indexOf (local .charAt (n + 1 )) >= 0 ) ) {
156156 break ;
157157 }
158158 if (regionMatch (local , n , "CIA" )) { // "CIA" -> X
159159 code .append ('X' );
160160 break ;
161161 }
162162 if (!isLastChar (wdsz , n ) &&
163- (this . frontv .indexOf (local .charAt (n + 1 )) >= 0 )) {
163+ (FRONTV .indexOf (local .charAt (n + 1 )) >= 0 )) {
164164 code .append ('S' );
165165 break ; // CI,CE,CY -> S
166166 }
@@ -184,7 +184,7 @@ public String metaphone(String txt) {
184184 case 'D' :
185185 if (!isLastChar (wdsz , n + 1 ) &&
186186 isNextChar (local , n , 'G' ) &&
187- (this . frontv .indexOf (local .charAt (n + 2 )) >= 0 )) { // DGE DGI DGY -> J
187+ (FRONTV .indexOf (local .charAt (n + 2 )) >= 0 )) { // DGE DGI DGY -> J
188188 code .append ('J' ); n += 2 ;
189189 } else {
190190 code .append ('T' );
@@ -211,7 +211,7 @@ public String metaphone(String txt) {
211211 hard = false ;
212212 }
213213 if (!isLastChar (wdsz , n ) &&
214- (this . frontv .indexOf (local .charAt (n + 1 )) >= 0 ) &&
214+ (FRONTV .indexOf (local .charAt (n + 1 )) >= 0 ) &&
215215 (!hard )) {
216216 code .append ('J' );
217217 } else {
@@ -223,7 +223,7 @@ public String metaphone(String txt) {
223223 break ; // terminal H
224224 }
225225 if ((n > 0 ) &&
226- (this . varson .indexOf (local .charAt (n - 1 )) >= 0 )) {
226+ (VARSON .indexOf (local .charAt (n - 1 )) >= 0 )) {
227227 break ;
228228 }
229229 if (isVowel (local ,n +1 )) {
@@ -308,7 +308,7 @@ public String metaphone(String txt) {
308308 }
309309
310310 private boolean isVowel (StringBuffer string , int index ) {
311- return this . vowels .indexOf (string .charAt (index )) >= 0 ;
311+ return VOWELS .indexOf (string .charAt (index )) >= 0 ;
312312 }
313313
314314 private boolean isPreviousChar (StringBuffer string , int index , char c ) {
0 commit comments