⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jasendigester.java

📁 spam source codejasen-0.9jASEN - java Anti Spam ENgine.zip 如标题所示
💻 JAVA
字号:
/*
 * @(#)JasenDigester.java	30/10/2004
 *
 * Copyright (c) 2004, 2005  jASEN.org
 * All rights reserved.
 *
 * 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 names of the authors may not be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 *
 *   4. Any modification or additions to the software must be contributed back
 *      to the project.
 *
 *   5. Any investigation or reverse engineering of source code or binary to
 *      enable emails to bypass the filters, and hence inflict spam and or viruses
 *      onto users who use or do not use jASEN could subject the perpetrator to
 *      criminal and or civil liability.
 *
 * 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 JASEN.ORG,
 * OR ANY CONTRIBUTORS TO THIS SOFTWARE 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.
 *
 */
package org.jasen.config;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;

import javax.xml.parsers.SAXParser;

import org.apache.commons.digester.Digester;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;

/**
 * <P>
 * 	Digests the jASEN configuration files.
 * </P>
 * @author Jason Polites
 */
public class JasenDigester extends Digester
{

    public JasenDigester() {
        super ();
    }

    public JasenDigester(SAXParser parser) {
        super (parser);
    }


    public JasenDigester(XMLReader reader) {
        super (reader);
    }

    /**
     * Initialises the digester
     */
    public void init() {
		setValidating( false );

		// Create a container for the plugins
		addObjectCreate( "jasen-config", JasenConfiguration.class );

		addSetProperties( "jasen-config", "libPath", "libPath" );
		addSetProperties( "jasen-config/scanner", "calculator", "calculator" );
		addSetProperties( "jasen-config/scanner", "mimeParser", "mimeParser" );
		addSetProperties( "jasen-config/scanner", "headerParser", "headerParser" );
		addSetProperties( "jasen-config/scanner", "tokenizer", "tokenizer" );
		addSetProperties( "jasen-config/scanner", "tokenLimit", "tokenLimit" );
		addSetProperties( "jasen-config/scanner", "dnsResolver", "dnsResolver" );
		addSetProperties( "jasen-config/scanner", "inetResolver", "inetResolver" );
		addSetProperties( "jasen-config/scanner", "errorHandler", "errorHandler" );
		addSetProperties( "jasen-config/scanner", "boundary", "boundary" );

		addSetProperties( "jasen-config/engine", "confidence", "confidence" );
		addSetProperties( "jasen-config/engine", "guess", "guess" );
		addSetProperties( "jasen-config/engine", "esf", "esf" );
		addSetProperties( "jasen-config/engine", "ftt", "ftt" );

		addSetProperties( "jasen-config/auto-update", "url", "autoUpdateUrl" );
		addSetProperties( "jasen-config/auto-update", "parcel", "autoUpdateParcel" );
		addSetProperties( "jasen-config/auto-update", "frequency", "autoUpdateFrequency" );
		addSetProperties( "jasen-config/auto-update", "enabled", "autoUpdateEnabled" );
		addSetProperties( "jasen-config/auto-update", "checkOnStartup", "autoUpdateCheckOnStartup" );
		addSetProperties( "jasen-config/auto-update", "readBuffer", "autoUpdateReadBuffer" );
		addSetProperties( "jasen-config/auto-update", "readTimeout", "autoUpdateReadTimout" );
		addSetProperties( "jasen-config/auto-update", "errorHandler", "autoUpdateErrorHandler" );

		addObjectCreate( "jasen-config/plugin", JasenPluginConfiguration.class );
		addSetProperties( "jasen-config/plugin", "name", "name" );
		addSetProperties( "jasen-config/plugin", "displayName", "displayName" );
		addSetProperties( "jasen-config/plugin", "description", "description" );
		addSetProperties( "jasen-config/plugin", "priority", "priority" );
		addSetProperties( "jasen-config/plugin", "type", "type" );
		addSetProperties( "jasen-config/plugin", "calculator", "calculator" );
		addSetProperties( "jasen-config/plugin", "properties", "properties" );

		addSetNext( "jasen-config/plugin", "addPluginConfiguration" );

		addObjectCreate( "jasen-config/parser", JasenParserConfiguration.class );
		addSetProperties( "jasen-config/parser", "contrastThreshold", "contrastThreshold" );
		addSetProperties( "jasen-config/parser", "microElementSize", "microElementSize" );
		addSetProperties( "jasen-config/parser", "microFontSize", "microFontSize" );
		
		addSetNext("jasen-config/parser", "setParserConfiguration");
		
    }

    /*
     * (non-Javadoc)
     * @see org.apache.commons.digester.Digester#parse(java.io.File)
     */
    public Object parse(File file) throws IOException, SAXException {
        init();
        return super.parse (file);
    }

    /*
     * (non-Javadoc)
     * @see org.apache.commons.digester.Digester#parse(org.xml.sax.InputSource)
     */
    public Object parse(InputSource input) throws IOException, SAXException {
        init();
        return super.parse (input);
    }

    /*
     * (non-Javadoc)
     * @see org.apache.commons.digester.Digester#parse(java.io.InputStream)
     */
    public Object parse(InputStream input) throws IOException, SAXException {
        init();
        return super.parse (input);
    }

    /*
     * (non-Javadoc)
     * @see org.apache.commons.digester.Digester#parse(java.io.Reader)
     */
    public Object parse(Reader reader) throws IOException, SAXException {
        init();
        return super.parse (reader);
    }

    /*
     * (non-Javadoc)
     * @see org.apache.commons.digester.Digester#parse(java.lang.String)
     */
    public Object parse(String uri) throws IOException, SAXException {
        init();
        return super.parse (uri);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -