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

📄 dictionarypropertyeditor.java

📁 基于最大匹配算法的的中文分词组件
💻 JAVA
字号:
/*
 * @作者:Hades , 创建日期:2006-12-25
 *
 * 汕头大学03计算机本科
 * 
 */
package edu.stu.cn.segment.spring.ioc;

import java.beans.PropertyEditorSupport;

import edu.stu.cn.segment.matching.dictionary.DictionaryImpl;
import edu.stu.cn.segment.matching.util.DictionaryUtil;

/**
 * @author Hades Guan 将字符串描述转换为相应字典类型
 */
public class DictionaryPropertyEditor<T extends DictionaryImpl> extends
        PropertyEditorSupport
{
    @SuppressWarnings("unused")
    private Class<T> classType = null;

    /**
     * 默认构造函数
     * 
     * @param classType
     *            指定所使用泛型的Class类型
     */
    public DictionaryPropertyEditor(Class<T> classType)
    {
        this.classType = classType;
    }

    /*
     * (非 Javadoc)
     * 
     * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String)
     */
    @Override
    public void setAsText(String text) throws IllegalArgumentException
    {
        // 初始化字典工具
        DictionaryUtil<T> tool = new DictionaryUtil<T>();
        // 根据指定的文件路径初始化字典实例
        T dic = tool.readDictionary(text);
        // 设置访问值
        this.setValue(dic);
    }

}

⌨️ 快捷键说明

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