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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? filterprofanity.java

?? 這是學習Java必須讀懂兩套源代碼
?? JAVA
字號:
/**
 * Copyright (C) 2001 Yasna.com. All rights reserved.
 *
 * ===================================================================
 * The Apache Software License, Version 1.1
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by
 *        Yasna.com (http://www.yasna.com)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Yazd" and "Yasna.com" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please
 *    contact yazd@yasna.com.
 *
 * 5. Products derived from this software may not be called "Yazd",
 *    nor may "Yazd" appear in their name, without prior written
 *    permission of Yasna.com.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL YASNA.COM OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of Yasna.com. For more information
 * on Yasna.com, please see <http://www.yasna.com>.
 */

/**
 * Copyright (C) 2000 CoolServlets.com. All rights reserved.
 *
 * ===================================================================
 * The Apache Software License, Version 1.1
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by
 *        CoolServlets.com (http://www.coolservlets.com)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Jive" and "CoolServlets.com" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please
 *    contact webmaster@coolservlets.com.
 *
 * 5. Products derived from this software may not be called "Jive",
 *    nor may "Jive" appear in their name, without prior written
 *    permission of CoolServlets.com.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL COOLSERVLETS.COM OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CoolServlets.com. For more information
 * on CoolServlets.com, please see <http://www.coolservlets.com>.
 */

package com.Yasna.forum.filter;

import java.util.*;

import com.Yasna.forum.*;

/**
 * A ForumMessageFilter that replaces profanity.
 */
public class FilterProfanity extends ForumMessageFilter {

    /**
     * Array of all the bad words to filter.
     */
    private String [] filterList;

    /**
     * Indicates if case of words should be ignored.
     */
    private boolean ignoreCase = true;

    /**
     * Property values of the filter.
     */
    private Properties props;

    /**
     * Property descriptions of the filter.
     */
    private Properties propDescriptions;

    /**
     * Creates a new filter not associated with a message. This is
     * generally only useful for defining a template filter that other
     * fitlers will be cloned from.
     */
    public FilterProfanity() {
        super();
        this.props = new Properties();
        this.propDescriptions = new Properties();
        initializeProperties();
    }

    /**
     * Creates a new filter wrapped around the specified message. This
     * constructor is normally called when cloning a filter template.
     *
     * @param message the ForumMessage to wrap the new filter around.
     * @param properties the property values for the filter.
     * @param propertyDescriptions the property descriptions for the filter.
     */
    public FilterProfanity(ForumMessage message, Properties props,
            Properties propDescriptions, String [] filterList, boolean ignoreCase)
    {
        super(message);
        this.props = new Properties(props);
        this.propDescriptions = new Properties(propDescriptions);
        this.filterList = filterList;
        this.ignoreCase = ignoreCase;
    }

    /**
     * Clones a new filter that will have the same properties and that
     * will wrap around the specified message.
     *
     * @param message the ForumMessage to wrap the new filter around.
     */
    public ForumMessageFilter clone(ForumMessage message){
        return new FilterProfanity(message, props, propDescriptions,
                filterList, ignoreCase);
    }

    /**
     * Returns the name of the filter.
     */
    public String getName() {
        return "Profanity Filter";
    }

    /**
     * Returns a description of the filter.
     */
    public String getDescription() {
        return "Removes profanity from messages using a custom word list.";
    }

    /**
     * Returns the author of the filter.
     */
    public String getAuthor() {
        return "CoolServlets.com";
    }

    /**
     * Returns the major version number of the filter.
     */
    public int getMajorVersion() {
        return 1;
    }

    /**
     * Returns the minor version number of the filter.
     */
    public int getMinorVersion() {
        return 0;
    }

    /**
     * Returns the value of a property of the filter.
     *
     * @param name the name of the property.
     * @returns the value of the property.
     */
    public String getFilterProperty(String name) {
        return props.getProperty(name);
    }

    /**
     * Returns the description of a property of the filter.
     *
     * @param name the name of the property.
     * @return the description of the property.
     */
    public String getFilterPropertyDescription(String name) {
        return propDescriptions.getProperty(name);
    }

    /**
     * Returns an Enumeration of all the property names.
     */
    public Enumeration filterPropertyNames() {
        return props.propertyNames();
    }

    /**
     * Sets a property of the filter. Each filter has a set number of
     * properties that are determined by the filter author.
     *
     * @param name the name of the property to set.
     * @param value the new value for the property.
     *
     * @throws IllegalArgumentException if the property trying to be set doesn't
     *    exist.
     */
    public void setFilterProperty(String name, String value)
            throws IllegalArgumentException
    {
        if (props.getProperty(name) == null) {
            throw new IllegalArgumentException();
        }
        props.put(name, value);
        applyProperties();
    }

    /**
     * <b>Overloaded</b> to return the subject of the message with profanity
     * filtered out.
     */
    public String getSubject() {
        return filterProfanity(message.getSubject());
    }

    /**
     * <b>Overloaded</b> to return the body of the message with profanity
     * filtered out.
     */
    public String getBody() {
        return filterProfanity(message.getBody());
    }

    /**
     * Creates properties and sets their descriptions.
     */
    private void initializeProperties() {
        filterList = new String[0];
        props.put("filterList","");
        props.put("ignoreCase","on");

        propDescriptions.put("filterList","A comma delimitted list of "
            + "the bad words to filter out.");
        propDescriptions.put("ignoreCase","Indicates whether the case "
            + "of words should be ignored or not. For example, when on, the "
            + "words 'CRap' and 'crap' would both be filterd if an entry of "
            + "'CRAP' was found in the filter list.");
    }

    private void applyProperties() {
        ignoreCase = ((String)props.getProperty("ignoreCase")).equals("on");
        String list = (String)props.get("filterList");
        StringTokenizer tokens = new StringTokenizer(list,",");
        String [] newFilterList = new String[tokens.countTokens()];
        for (int i=0; i<newFilterList.length; i++) {
            if (ignoreCase) {
                newFilterList[i] = tokens.nextToken().toLowerCase().trim();
            }
            else {
                newFilterList[i] = tokens.nextToken().trim();
            }
        }
        filterList = newFilterList;
    }

    /**
     * Filters out bad words.
     */
    private String filterProfanity(String str) {
        // Check to see if the string is null or zero-length
        if (str == null || "".equals(str)) {
            return str;
        }
        String lower;
        if (ignoreCase) {
            lower = str.toLowerCase();
        }
        else {
            lower = str;
        }
        for (int i=0; i<filterList.length; i++) {
            str = replace(str, lower, filterList[i], cleanWord(filterList[i].length()));
        }
        return str;
    }

    /**
     * Generates a string of characters of specified length. For example:
     * !@%$ or %!@$%!@@ or *****
     */
    private String cleanWord(int length) {
        char[] newWord = new char[length];
        for (int i=0; i<newWord.length; i++) {
            newWord[i] = '*';
        }
        return new String(newWord);
    }

    /**
     * Replaces all instances of oldString with newString in the String line.
     */
    private String replace(String line, String lowerCaseLine,
            String oldString, String newString )
    {
        int i=0;
        if ( ( i=lowerCaseLine.indexOf( oldString, i ) ) >= 0 ) {
            int oLength = oldString.length();
            int nLength = newString.length();
            StringBuffer buf = new StringBuffer(line.length()+15);
            buf.append(line.substring(0,i)).append(newString);
            i += oLength;
            int j = i;
            while( ( i=lowerCaseLine.indexOf( oldString, i ) ) > 0 ) {
                buf.append(line.substring(j,i)).append(newString);
                i += oLength;
                j = i;
            }
            buf.append(line.substring(j));
            return buf.toString();
        }
        return line;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美在线视频你懂得| 精品国产青草久久久久福利| 69堂亚洲精品首页| 中文字幕一区av| 久久se这里有精品| 色婷婷狠狠综合| 国产亚洲1区2区3区| 免费在线看成人av| 欧美性猛交xxxx黑人交| 国产精品国产自产拍高清av| 麻豆免费精品视频| 91.麻豆视频| 亚洲一区免费观看| 97se亚洲国产综合自在线| 久久久精品人体av艺术| 精品一区二区三区在线播放| 欧洲精品视频在线观看| 国产精品高潮呻吟| 国产精品123区| 国产欧美一区二区精品忘忧草| 麻豆精品一区二区三区| 欧美精选午夜久久久乱码6080| 亚洲最大的成人av| 色婷婷av一区二区| 亚洲激情在线激情| 在线观看中文字幕不卡| 亚洲女爱视频在线| 欧美最猛黑人xxxxx猛交| 亚洲另类春色国产| 欧美综合久久久| 天堂成人国产精品一区| 欧美视频中文一区二区三区在线观看| 中文字幕一区二区视频| 9久草视频在线视频精品| 国产精品久久精品日日| 91浏览器入口在线观看| 一区二区免费视频| 欧美日韩亚洲综合在线| 日韩制服丝袜av| 日韩免费性生活视频播放| 久久99精品久久久久久久久久久久 | 激情综合色丁香一区二区| 91精品国产综合久久精品麻豆| 久久精品国产999大香线蕉| 欧美xxx久久| 国产99久久精品| 亚洲欧洲国产日本综合| 精品视频123区在线观看| 日韩av在线播放中文字幕| 日韩欧美国产三级电影视频| 韩国在线一区二区| 亚洲同性同志一二三专区| 欧美日韩精品系列| 狠狠狠色丁香婷婷综合激情| 欧美激情在线看| 在线这里只有精品| 久久精品国产一区二区三 | 欧美日韩高清在线播放| 日本欧美大码aⅴ在线播放| 久久久久久夜精品精品免费| 不卡一区二区中文字幕| 亚洲一级在线观看| 26uuu欧美| 91在线一区二区三区| 日韩电影一区二区三区四区| 国产偷国产偷精品高清尤物| 91香蕉视频mp4| 蜜臀av性久久久久蜜臀aⅴ四虎 | 欧美一区二区久久| 国产69精品久久777的优势| 亚洲国产欧美日韩另类综合 | 亚洲va韩国va欧美va| 精品999在线播放| 色网综合在线观看| 久久国产精品免费| 亚洲影视在线播放| 国产亚洲精品aa| 91精品国产色综合久久不卡电影| 国产大片一区二区| 青青草国产成人99久久| 一区二区在线观看视频| 久久人人97超碰com| 777a∨成人精品桃花网| av电影一区二区| 国产美女精品一区二区三区| 亚洲国产裸拍裸体视频在线观看乱了| 久久久久久日产精品| 91.com在线观看| 色94色欧美sute亚洲13| 日韩av一级片| |精品福利一区二区三区| 欧美大片在线观看一区二区| 成人黄色在线看| 国产真实乱子伦精品视频| 亚洲国产三级在线| 亚洲欧美另类图片小说| 国产亚洲综合av| 精品伦理精品一区| 欧美v日韩v国产v| 欧美喷潮久久久xxxxx| 色婷婷综合五月| 99re亚洲国产精品| 成人的网站免费观看| 高清av一区二区| 国产激情一区二区三区| 国产成人h网站| 国产福利一区二区| 国产精品一区二区免费不卡| 久久国产麻豆精品| 韩国一区二区三区| 国精产品一区一区三区mba桃花| 免费看欧美美女黄的网站| 日韩电影在线免费看| 美腿丝袜亚洲综合| 麻豆精品在线播放| 91在线视频官网| 成人av午夜影院| 日韩国产在线观看| 欧美视频在线一区| 欧美亚洲国产怡红院影院| 在线观看免费亚洲| 欧美体内she精视频| 777a∨成人精品桃花网| 69堂成人精品免费视频| 欧美videos中文字幕| 久久综合久色欧美综合狠狠| 久久欧美一区二区| 国产精品青草久久| 亚洲曰韩产成在线| 日韩电影网1区2区| 国产黄人亚洲片| 91美女蜜桃在线| 欧美日韩视频一区二区| 日韩午夜av电影| 国产日本欧洲亚洲| 亚洲精品欧美激情| 舔着乳尖日韩一区| 国产原创一区二区| 色综合久久久久久久| 在线不卡一区二区| 精品免费日韩av| 成人免费小视频| 国产精品乱子久久久久| 国产精品久久久久久久久免费樱桃 | 国产一区二区视频在线| 成人精品免费看| 成人教育av在线| 欧美主播一区二区三区| 精品国产乱码久久久久久影片| 国产亚洲美州欧州综合国| 亚洲另类中文字| 久久99热99| 日本丶国产丶欧美色综合| 欧美成人精精品一区二区频| 国产精品国产三级国产| 日本欧美一区二区在线观看| 国产精品1区2区3区| 在线观看日韩av先锋影音电影院| 在线成人免费视频| 日韩毛片高清在线播放| 久草热8精品视频在线观看| 99re热这里只有精品视频| 欧美α欧美αv大片| 一二三区精品福利视频| 国产99久久久精品| 日韩小视频在线观看专区| 一区二区三区在线免费观看| 国产麻豆日韩欧美久久| 欧美日韩在线播放三区四区| 国产精品美女久久久久av爽李琼 | 亚洲高清视频中文字幕| 国产激情一区二区三区桃花岛亚洲 | 久久综合99re88久久爱| 亚洲va欧美va人人爽午夜| 不卡av在线网| 国产亚洲欧美中文| 免费xxxx性欧美18vr| 欧美三级在线视频| 亚洲欧洲国产日韩| 成人精品亚洲人成在线| 精品国产麻豆免费人成网站| 性做久久久久久免费观看| 色综合中文字幕| 国产精品每日更新| 国产传媒欧美日韩成人| 欧美xxxxx牲另类人与| 日本不卡高清视频| 制服视频三区第一页精品| 亚洲资源中文字幕| 99久久国产综合精品色伊| 国产精品色一区二区三区| 国产91高潮流白浆在线麻豆 | 欧美一区二区成人| 天天影视网天天综合色在线播放| 色综合视频在线观看| 亚洲精品高清视频在线观看| 91浏览器打开| 亚洲码国产岛国毛片在线| 91色婷婷久久久久合中文| 中文字幕av资源一区|