org.apache.commons.codec.language
Class ColognePhonetic

java.lang.Object
  extended by org.apache.commons.codec.language.ColognePhonetic
All Implemented Interfaces:
Encoder, StringEncoder

public class ColognePhonetic
extends Object
implements StringEncoder

Encodes a string into a Cologne Phonetic value.

Implements the Kölner Phonetik (Cologne Phonetic) algorithm issued by Hans Joachim Postel in 1969.

The Kölner Phonetik is a phonetic algorithm which is optimized for the German language. It is related to the well-known soundex algorithm.

Algorithm

This class is thread-safe.

Since:
1.5
See Also:
Wikipedia (de): Kölner Phonetik (in German)

Nested Class Summary
private  class ColognePhonetic.CologneBuffer
          This class is not thread-safe; the field ColognePhonetic.CologneBuffer.length is mutable.
private  class ColognePhonetic.CologneInputBuffer
           
private  class ColognePhonetic.CologneOutputBuffer
           
 
Field Summary
private static char[] AEIJOUY
           
private static char[] AHKLOQRUX
           
private static char[] AHOUKQX
           
private static char[] CKQ
           
private static char[] GKQ
           
private static char[][] PREPROCESS_MAP
          Maps some Germanic characters to plain for internal processing.
private static char[] SCZ
           
private static char[] SZ
           
private static char[] TDX
           
private static char[] WFPV
           
 
Constructor Summary
ColognePhonetic()
           
 
Method Summary
private static boolean arrayContains(char[] arr, char key)
           
 String colognePhonetic(String text)
           Implements the Kölner Phonetik algorithm.
 Object encode(Object object)
          Encodes an "Object" and returns the encoded content as an Object.
 String encode(String text)
          Encodes a String and returns a String.
 boolean isEncodeEqual(String text1, String text2)
           
private  String preprocess(String text)
          Converts the string to upper case and replaces germanic characters as defined in PREPROCESS_MAP.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AEIJOUY

private static final char[] AEIJOUY

SCZ

private static final char[] SCZ

WFPV

private static final char[] WFPV

GKQ

private static final char[] GKQ

CKQ

private static final char[] CKQ

AHKLOQRUX

private static final char[] AHKLOQRUX

SZ

private static final char[] SZ

AHOUKQX

private static final char[] AHOUKQX

TDX

private static final char[] TDX

PREPROCESS_MAP

private static final char[][] PREPROCESS_MAP
Maps some Germanic characters to plain for internal processing. The following characters are mapped:

Constructor Detail

ColognePhonetic

public ColognePhonetic()
Method Detail

arrayContains

private static boolean arrayContains(char[] arr,
                                     char key)

colognePhonetic

public String colognePhonetic(String text)

Implements the Kölner Phonetik algorithm.

In contrast to the initial description of the algorithm, this implementation does the encoding in one pass.

Parameters:
text -
Returns:
the corresponding encoding according to the Kölner Phonetik algorithm

encode

public Object encode(Object object)
              throws EncoderException
Description copied from interface: Encoder
Encodes an "Object" and returns the encoded content as an Object. The Objects here may just be byte[] or Strings depending on the implementation used.

Specified by:
encode in interface Encoder
Parameters:
object - An object to encode
Returns:
An "encoded" Object
Throws:
EncoderException - An encoder exception is thrown if the encoder experiences a failure condition during the encoding process.

encode

public String encode(String text)
Description copied from interface: StringEncoder
Encodes a String and returns a String.

Specified by:
encode in interface StringEncoder
Parameters:
text - the String to encode
Returns:
the encoded String

isEncodeEqual

public boolean isEncodeEqual(String text1,
                             String text2)

preprocess

private String preprocess(String text)
Converts the string to upper case and replaces germanic characters as defined in PREPROCESS_MAP.



commons-codec version 1.8 - Copyright © 2002-2013 - Apache Software Foundation