亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? soundex.java

?? 一個(gè)很實(shí)用的東東
?? JAVA
字號(hào):
/*
 * Copyright 2001-2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ 

package org.apache.commons.codec.language;

import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.StringEncoder;

/**
 * Encodes a string into a Soundex value. Soundex is an encoding used to relate similar names, but can also be used as a
 * general purpose scheme to find word with similar phonemes.
 * 
 * @author Apache Software Foundation
 * @version $Id: Soundex.java,v 1.26 2004/07/07 23:15:24 ggregory Exp $
 */
public class Soundex implements StringEncoder {

    /**
     * An instance of Soundex using the US_ENGLISH_MAPPING mapping.
     * 
     * @see #US_ENGLISH_MAPPING
     */
    public static final Soundex US_ENGLISH = new Soundex();

    /**
     * This is a default mapping of the 26 letters used in US English. A value of <code>0</code> for a letter position
     * means do not encode.
     * <p>
     * (This constant is provided as both an implementation convenience and to allow Javadoc to pick
     * up the value for the constant values page.)
     * </p>
     * 
     * @see #US_ENGLISH_MAPPING
     */
    public static final String US_ENGLISH_MAPPING_STRING = "01230120022455012623010202";

    /**
     * This is a default mapping of the 26 letters used in US English. A value of <code>0</code> for a letter position
     * means do not encode.
     * 
     * @see Soundex#Soundex(char[])
     */
    public static final char[] US_ENGLISH_MAPPING = US_ENGLISH_MAPPING_STRING.toCharArray();

    /**
     * Encodes the Strings and returns the number of characters in the two encoded Strings that are the same. This
     * return value ranges from 0 through 4: 0 indicates little or no similarity, and 4 indicates strong similarity or
     * identical values.
     * 
     * @param s1
     *                  A String that will be encoded and compared.
     * @param s2
     *                  A String that will be encoded and compared.
     * @return The number of characters in the two encoded Strings that are the same from 0 to 4.
     * 
     * @see SoundexUtils#difference(StringEncoder,String,String)
     * @see <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp"> MS
     *          T-SQL DIFFERENCE </a>
     * 
     * @throws EncoderException
     *                  if an error occurs encoding one of the strings
     * @since 1.3
     */
    public int difference(String s1, String s2) throws EncoderException {
        return SoundexUtils.difference(this, s1, s2);
    }

    /**
     * The maximum length of a Soundex code - Soundex codes are only four characters by definition.
     * 
     * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
     */
    private int maxLength = 4;

    /**
     * Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each
     * letter is mapped. This implementation contains a default map for US_ENGLISH
     */
    private char[] soundexMapping;

    /**
     * Creates an instance using US_ENGLISH_MAPPING
     * 
     * @see Soundex#Soundex(char[])
     * @see Soundex#US_ENGLISH_MAPPING
     */
    public Soundex() {
        this(US_ENGLISH_MAPPING);
    }

    /**
     * Creates a soundex instance using the given mapping. This constructor can be used to provide an internationalized
     * mapping for a non-Western character set.
     * 
     * Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each
     * letter is mapped. This implementation contains a default map for US_ENGLISH
     * 
     * @param mapping
     *                  Mapping array to use when finding the corresponding code for a given character
     */
    public Soundex(char[] mapping) {
        this.setSoundexMapping(mapping);
    }

    /**
     * Encodes an Object using the soundex algorithm. This method is provided in order to satisfy the requirements of
     * the Encoder interface, and will throw an EncoderException if the supplied object is not of type java.lang.String.
     * 
     * @param pObject
     *                  Object to encode
     * @return An object (or type java.lang.String) containing the soundex code which corresponds to the String
     *             supplied.
     * @throws EncoderException
     *                  if the parameter supplied is not of type java.lang.String
     * @throws IllegalArgumentException
     *                  if a character is not mapped
     */
    public Object encode(Object pObject) throws EncoderException {
        if (!(pObject instanceof String)) {
            throw new EncoderException("Parameter supplied to Soundex encode is not of type java.lang.String");
        }
        return soundex((String) pObject);
    }

    /**
     * Encodes a String using the soundex algorithm.
     * 
     * @param pString
     *                  A String object to encode
     * @return A Soundex code corresponding to the String supplied
     * @throws IllegalArgumentException
     *                  if a character is not mapped
     */
    public String encode(String pString) {
        return soundex(pString);
    }

    /**
     * Used internally by the SoundEx algorithm.
     * 
     * Consonants from the same code group separated by W or H are treated as one.
     * 
     * @param str
     *                  the cleaned working string to encode (in upper case).
     * @param index
     *                  the character position to encode
     * @return Mapping code for a particular character
     * @throws IllegalArgumentException
     *                  if the character is not mapped
     */
    private char getMappingCode(String str, int index) {
        char mappedChar = this.map(str.charAt(index));
        // HW rule check
        if (index > 1 && mappedChar != '0') {
            char hwChar = str.charAt(index - 1);
            if ('H' == hwChar || 'W' == hwChar) {
                char preHWChar = str.charAt(index - 2);
                char firstCode = this.map(preHWChar);
                if (firstCode == mappedChar || 'H' == preHWChar || 'W' == preHWChar) {
                    return 0;
                }
            }
        }
        return mappedChar;
    }

    /**
     * Returns the maxLength. Standard Soundex
     * 
     * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
     * @return int
     */
    public int getMaxLength() {
        return this.maxLength;
    }

    /**
     * Returns the soundex mapping.
     * 
     * @return soundexMapping.
     */
    private char[] getSoundexMapping() {
        return this.soundexMapping;
    }

    /**
     * Maps the given upper-case character to it's Soudex code.
     * 
     * @param ch
     *                  An upper-case character.
     * @return A Soundex code.
     * @throws IllegalArgumentException
     *                  Thrown if <code>ch</code> is not mapped.
     */
    private char map(char ch) {
        int index = ch - 'A';
        if (index < 0 || index >= this.getSoundexMapping().length) {
            throw new IllegalArgumentException("The character is not mapped: " + ch);
        }
        return this.getSoundexMapping()[index];
    }

    /**
     * Sets the maxLength.
     * 
     * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
     * @param maxLength
     *                  The maxLength to set
     */
    public void setMaxLength(int maxLength) {
        this.maxLength = maxLength;
    }

    /**
     * Sets the soundexMapping.
     * 
     * @param soundexMapping
     *                  The soundexMapping to set.
     */
    private void setSoundexMapping(char[] soundexMapping) {
        this.soundexMapping = soundexMapping;
    }

    /**
     * Retreives the Soundex code for a given String object.
     * 
     * @param str
     *                  String to encode using the Soundex algorithm
     * @return A soundex code for the String supplied
     * @throws IllegalArgumentException
     *                  if a character is not mapped
     */
    public String soundex(String str) {
        if (str == null) {
            return null;
        }
        str = SoundexUtils.clean(str);
        if (str.length() == 0) {
            return str;
        }
        char out[] = {'0', '0', '0', '0'};
        char last, mapped;
        int incount = 1, count = 1;
        out[0] = str.charAt(0);
        last = getMappingCode(str, 0);
        while ((incount < str.length()) && (count < out.length)) {
            mapped = getMappingCode(str, incount++);
            if (mapped != 0) {
                if ((mapped != '0') && (mapped != last)) {
                    out[count++] = mapped;
                }
                last = mapped;
            }
        }
        return new String(out);
    }

}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美美女视频在线观看| 国内精品久久久久影院薰衣草 | 久久99国产精品成人| 欧美日韩的一区二区| 一区二区免费在线播放| 91丨porny丨蝌蚪视频| 国产精品久久久久久久第一福利| 国产在线麻豆精品观看| 久久亚洲综合av| 国产一区美女在线| 久久伊99综合婷婷久久伊| 国产综合久久久久久久久久久久| 欧美电影免费观看高清完整版在线 | 久久久久成人黄色影片| 国产一区不卡视频| 久久精品一区四区| 成人午夜av电影| 中文字幕一区二区三区四区不卡 | 国产精品久久免费看| 99免费精品在线| 亚洲狼人国产精品| 欧美日韩免费观看一区二区三区| 午夜视频久久久久久| 91精品国产一区二区三区香蕉| 日韩不卡手机在线v区| 日韩美女视频在线| 国产精品2024| 亚洲欧洲精品一区二区三区不卡| 一本一道久久a久久精品综合蜜臀| 一区二区日韩电影| 欧美日韩mp4| 久久电影网站中文字幕| 久久亚洲春色中文字幕久久久| 国产馆精品极品| 成人免费一区二区三区视频| 欧美亚洲图片小说| 日本亚洲最大的色成网站www| 精品国精品国产| 成人黄色一级视频| 亚洲综合一区二区三区| 欧美一二区视频| 国产成人av电影在线播放| 国产精品久久久久一区二区三区共 | 在线精品视频免费播放| 日韩电影一区二区三区四区| 蜜桃久久久久久久| 久久人人97超碰com| 99re在线精品| 天涯成人国产亚洲精品一区av| 欧美成人欧美edvon| 成人久久视频在线观看| 亚洲成a天堂v人片| 国产三级欧美三级日产三级99| 91麻豆精品视频| 青草av.久久免费一区| 日本一区二区三区久久久久久久久不 | 成人毛片老司机大片| 一区二区激情视频| 精品美女一区二区| 色综合久久久久| 久久精品国产精品青草| 亚洲欧洲美洲综合色网| 日韩无一区二区| www.亚洲色图| 蜜桃av一区二区在线观看| 国产精品不卡在线| 欧美一级二级三级乱码| 不卡大黄网站免费看| 午夜精品福利久久久| 国产欧美视频在线观看| 欧美人妇做爰xxxⅹ性高电影| 国产高清视频一区| 亚洲第一成人在线| 国产精品麻豆网站| 91精品国产综合久久久久久久 | 99久久精品99国产精品| 青青青爽久久午夜综合久久午夜| 国产精品久久久久影院色老大| 欧美一级午夜免费电影| 91在线国产福利| 久久99久久精品| 亚洲综合男人的天堂| 国产日韩欧美高清| 日韩精品一区二区三区四区视频| 91丨porny丨最新| 国产91丝袜在线18| 美女在线一区二区| 一区二区三区鲁丝不卡| 91成人免费在线视频| 五月综合激情网| 亚洲色图一区二区| 国产色产综合色产在线视频| 91精品国产免费| 色婷婷综合久久久中文一区二区| 国产精品亚洲成人| 精品一区中文字幕| 日日摸夜夜添夜夜添亚洲女人| 1区2区3区欧美| 欧美国产一区在线| www成人在线观看| 欧美一区二区三区的| 欧美性videosxxxxx| 91亚洲精品乱码久久久久久蜜桃| 国产一区二区久久| 欧美tickle裸体挠脚心vk| 欧美日韩成人综合在线一区二区| 色综合一个色综合亚洲| 成人午夜大片免费观看| 国产成人日日夜夜| 国产曰批免费观看久久久| 青椒成人免费视频| 日本vs亚洲vs韩国一区三区二区| 亚洲午夜免费福利视频| 亚洲靠逼com| 亚洲黄色在线视频| 亚洲欧美另类小说| 综合久久国产九一剧情麻豆| 国产精品无码永久免费888| 久久精品网站免费观看| 精品88久久久久88久久久| 欧美成人综合网站| 日韩一级片网址| 日韩欧美一级精品久久| 91精品国产综合久久精品麻豆 | 久久精品亚洲精品国产欧美kt∨| 日韩视频免费观看高清完整版| 在线播放亚洲一区| 7777精品伊人久久久大香线蕉的 | 欧美变态tickle挠乳网站| 欧美一二三在线| 日韩一卡二卡三卡| 精品国产乱码久久久久久牛牛| 日韩免费电影网站| 精品国产一二三| 久久久久久久久97黄色工厂| 久久久影视传媒| 国产片一区二区| 中文一区一区三区高中清不卡| 国产精品私人自拍| 中文字幕佐山爱一区二区免费| 亚洲人成亚洲人成在线观看图片 | www.久久久久久久久| www.色综合.com| 96av麻豆蜜桃一区二区| 色屁屁一区二区| 欧美日韩日本视频| 日韩一区二区三| 久久亚洲一级片| 国产精品嫩草99a| 亚洲欧美国产三级| 亚洲第一福利一区| 久久电影国产免费久久电影| 国产精品自拍在线| 成人午夜av在线| 在线一区二区三区四区五区| 欧美日韩日日夜夜| 精品剧情在线观看| 国产精品天美传媒| 亚洲国产美女搞黄色| 日本不卡免费在线视频| 国产精品综合一区二区三区| 亚洲国产人成综合网站| 国产亚洲欧美一区在线观看| 成人免费看的视频| 国产精品一区二区果冻传媒| 亚洲免费伊人电影| 日韩不卡一区二区三区| 国产精品麻豆久久久| 欧美日韩免费观看一区三区| 一本色道久久综合亚洲aⅴ蜜桃| 国产一区二区三区电影在线观看| 国产精品水嫩水嫩| 日韩视频免费观看高清完整版 | 一本色道久久综合亚洲91 | 欧美日韩精品欧美日韩精品一综合| 日韩三级免费观看| 亚洲国产成人自拍| 亚洲高清免费在线| 国产一区二区成人久久免费影院 | 亚洲黄一区二区三区| 美日韩一级片在线观看| 波多野结衣在线一区| 欧美理论片在线| 国产欧美日韩在线| 亚洲超碰精品一区二区| 国产一区二区久久| 精品视频999| 久久久精品黄色| 亚洲一区二区视频在线| 国产一区二区三区国产| 在线国产电影不卡| 久久嫩草精品久久久久| 亚洲自拍偷拍麻豆| 国产精品羞羞答答xxdd| 欧美三级视频在线播放| 欧美极品xxx| 日本v片在线高清不卡在线观看| aaa欧美大片| 久久综合久久综合久久| 亚洲最色的网站|