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 java.lang.Object
implements StringEncoder

Encodes a string into a Cologne Phonetic value.

Implements the “Kölner Phonetic” (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

Since:
1.5
Author:
Apache Software Foundation
See Also:
Wikipedia (de): Kölner Phonetik (in German)

Nested Class Summary
private  class ColognePhonetic.CologneBuffer
           
private  class ColognePhonetic.CologneInputBuffer
           
private  class ColognePhonetic.CologneOutputBuffer
           
 
Field Summary
private static char[][] PREPROCESS_MAP
           
 
Constructor Summary
ColognePhonetic()
           
 
Method Summary
private static boolean arrayContains(char[] arr, char key)
           
 java.lang.String colognePhonetic(java.lang.String text)
           colognePhonetic() is the actual implementations of the Kölner Phonetik algorithm.
 java.lang.Object encode(java.lang.Object object)
          Encodes an "Object" and returns the encoded content as an Object.
 java.lang.String encode(java.lang.String text)
          Encodes a String and returns a String.
 boolean isEncodeEqual(java.lang.String text1, java.lang.String text2)
           
private  java.lang.String preprocess(java.lang.String text)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREPROCESS_MAP

private static final char[][] PREPROCESS_MAP
Constructor Detail

ColognePhonetic

public ColognePhonetic()
Method Detail

arrayContains

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

colognePhonetic

public java.lang.String colognePhonetic(java.lang.String text)

colognePhonetic() is the actual implementations of 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 java.lang.Object encode(java.lang.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 ot 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 java.lang.String encode(java.lang.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(java.lang.String text1,
                             java.lang.String text2)

preprocess

private java.lang.String preprocess(java.lang.String text)


commons-codec version 1.5-SNAPSHOT - Copyright © 2002-2011 - Apache Software Foundation