166166 * <li>
167167 * <h3>Step 3:</h3>
168168 * Removal of all codes “0” except at the beginning. This means that two or more identical consecutive digits can occur
169- * if they occur after removing the "0" digits.
169+ * if they occur after removing the "0" digits.
170170 *
171171 * <h4>Example:</h4>
172172 * {@code "6050750206802" => "65752682"}</li>
173173 *
174174 * </ul>
175175 *
176- * @see <a href="http://de.wikipedia.org/wiki/K%C3%B6lner_Phonetik"><span
177- * style="font-variant:small-caps">Wikipedia</span> (de): <i>Kölner Phonetik</i></a> (a German description of the
178- * algorithm and more sources)
176+ * @see <a href="http://de.wikipedia.org/wiki/K%C3%B6lner_Phonetik">Wikipedia (de): Kölner Phonetik (in German)</a>
179177 * @author Apache Software Foundation
180178 * @since 1.5
181179 */
@@ -184,7 +182,7 @@ public class ColognePhonetic implements StringEncoder {
184182 private abstract class CologneBuffer {
185183
186184 protected final char [] data ;
187-
185+
188186 protected int length = 0 ;
189187
190188 public CologneBuffer (char [] data ) {
@@ -250,19 +248,18 @@ public char getNextChar() {
250248 protected int getNextPos () {
251249 return data .length - length ;
252250 }
253-
251+
254252 public char removeNext () {
255253 char ch = getNextChar ();
256254 length --;
257255 return ch ;
258256 }
259257 }
260258
261- private static final char [][] PREPROCESS_MAP = new char [][] {
262- { '\u00C4' , 'A' }, // Ä
263- { '\u00DC' , 'U' }, // Ü
264- { '\u00D6' , 'O' }, // Ö
265- { '\u00DF' , 'S' } // ß
259+ private static final char [][] PREPROCESS_MAP = new char [][]{{'\u00C4' , 'A' }, // Ä
260+ {'\u00DC' , 'U' }, // Ü
261+ {'\u00D6' , 'O' }, // Ö
262+ {'\u00DF' , 'S' } // ß
266263 };
267264
268265 /*
@@ -279,17 +276,14 @@ private static boolean arrayContains(char[] arr, char key) {
279276
280277 /**
281278 * <p>
282- * <b>colognePhonetic()</b> is the actual implementations of the <i>Kölner
283- * Phonetik</i> algorithm.
279+ * <b>colognePhonetic()</b> is the actual implementations of the <i>Kölner Phonetik</i> algorithm.
284280 * </p>
285281 * <p>
286- * In contrast to the initial description of the algorithm, this
287- * implementation does the encoding in one pass.
282+ * In contrast to the initial description of the algorithm, this implementation does the encoding in one pass.
288283 * </p>
289284 *
290285 * @param text
291- * @return the corresponding encoding according to the <i>Kölner
292- * Phonetik</i> algorithm
286+ * @return the corresponding encoding according to the <i>Kölner Phonetik</i> algorithm
293287 */
294288 public String colognePhonetic (String text ) {
295289 if (text == null ) {
@@ -319,7 +313,7 @@ public String colognePhonetic(String text) {
319313 nextChar = '-' ;
320314 }
321315
322- if (arrayContains (new char [] { 'A' , 'E' , 'I' , 'J' , 'O' , 'U' , 'Y' }, chr )) {
316+ if (arrayContains (new char []{ 'A' , 'E' , 'I' , 'J' , 'O' , 'U' , 'Y' }, chr )) {
323317 code = '0' ;
324318 } else if (chr == 'H' || chr < 'A' || chr > 'Z' ) {
325319 if (lastCode == '/' ) {
@@ -328,34 +322,34 @@ public String colognePhonetic(String text) {
328322 code = '-' ;
329323 } else if (chr == 'B' || (chr == 'P' && nextChar != 'H' )) {
330324 code = '1' ;
331- } else if ((chr == 'D' || chr == 'T' ) && !arrayContains (new char [] { 'S' , 'C' , 'Z' }, nextChar )) {
325+ } else if ((chr == 'D' || chr == 'T' ) && !arrayContains (new char []{ 'S' , 'C' , 'Z' }, nextChar )) {
332326 code = '2' ;
333- } else if (arrayContains (new char [] { 'W' , 'F' , 'P' , 'V' }, chr )) {
327+ } else if (arrayContains (new char []{ 'W' , 'F' , 'P' , 'V' }, chr )) {
334328 code = '3' ;
335- } else if (arrayContains (new char [] { 'G' , 'K' , 'Q' }, chr )) {
329+ } else if (arrayContains (new char []{ 'G' , 'K' , 'Q' }, chr )) {
336330 code = '4' ;
337- } else if (chr == 'X' && !arrayContains (new char [] { 'C' , 'K' , 'Q' }, lastChar )) {
331+ } else if (chr == 'X' && !arrayContains (new char []{ 'C' , 'K' , 'Q' }, lastChar )) {
338332 code = '4' ;
339333 input .addLeft ('S' );
340334 rightLength ++;
341335 } else if (chr == 'S' || chr == 'Z' ) {
342336 code = '8' ;
343337 } else if (chr == 'C' ) {
344338 if (lastCode == '/' ) {
345- if (arrayContains (new char [] { 'A' , 'H' , 'K' , 'L' , 'O' , 'Q' , 'R' , 'U' , 'X' }, nextChar )) {
339+ if (arrayContains (new char []{ 'A' , 'H' , 'K' , 'L' , 'O' , 'Q' , 'R' , 'U' , 'X' }, nextChar )) {
346340 code = '4' ;
347341 } else {
348342 code = '8' ;
349343 }
350344 } else {
351- if (arrayContains (new char [] { 'S' , 'Z' }, lastChar ) ||
352- !arrayContains (new char [] { 'A' , 'H' , 'O' , 'U' , 'K' , 'Q' , 'X' }, nextChar )) {
345+ if (arrayContains (new char []{ 'S' , 'Z' }, lastChar ) ||
346+ !arrayContains (new char []{ 'A' , 'H' , 'O' , 'U' , 'K' , 'Q' , 'X' }, nextChar )) {
353347 code = '8' ;
354348 } else {
355349 code = '4' ;
356350 }
357351 }
358- } else if (arrayContains (new char [] { 'T' , 'D' , 'X' }, chr )) {
352+ } else if (arrayContains (new char []{ 'T' , 'D' , 'X' }, chr )) {
359353 code = '8' ;
360354 } else if (chr == 'R' ) {
361355 code = '7' ;
@@ -379,9 +373,11 @@ public String colognePhonetic(String text) {
379373
380374 public Object encode (Object object ) throws EncoderException {
381375 if (!(object instanceof String )) {
382- throw new EncoderException (
383- "This method’s parameter was expected to be of the type " + String .class .getName () +
384- ". But actually it was of the type " + object .getClass ().getName () + "." );
376+ throw new EncoderException ("This method’s parameter was expected to be of the type " +
377+ String .class .getName () +
378+ ". But actually it was of the type " +
379+ object .getClass ().getName () +
380+ "." );
385381 }
386382 return encode ((String ) object );
387383 }
@@ -395,8 +391,7 @@ public boolean isEncodeEqual(String text1, String text2) {
395391 }
396392
397393 /*
398- * Converts the string to upper case and replaces germanic umlauts, and the
399- * “ß”.
394+ * Converts the string to upper case and replaces germanic umlauts, and the “ß”.
400395 */
401396 private String preprocess (String text ) {
402397 text = text .toUpperCase (Locale .GERMAN );
0 commit comments