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

📄 filtersmileyface.java

📁 JSP聊天系统
💻 JAVA
字号:
package org.ehotsoft.yekki.filter;

import java.util.Properties;

public class FilterSmileyFace extends Filter {

    private Properties props;

    public FilterSmileyFace( Message message ) {

        super( message );
        props = new Properties();
    	initializeProperties();
    }

	protected String filter( String content )
    {
        return addSmileyFace( content );
    }

    private void initializeProperties() {

        props.put("happyURL", "");
        props.put("sadURL", "");
        props.put("coolURL", "");
        //"happyURL", "URL of the desired :) image";
        //"sadURL", "URL of the desired :( image";
       //"coolURL", "URL of the desired 8) image";
    }

    private String addSmileyFace(String s) {

        String s1 = props.getProperty("happyURL");
        String s2 = props.getProperty("sadURL");
        String s3 = props.getProperty("coolURL");
        if(s == null || s.length() == 0)
            return s;
        StringBuffer stringbuffer = new StringBuffer();
        byte byte0 = 32;
        byte byte1 = 32;
        int i;
        for(i = 0; i < s.length() - 1; i++)
        {
            char c = s.charAt(i);
            char c1 = s.charAt(i + 1);
            if(s1 != null && s1.length() > 0 && c == ':' && c1 == ')')
            {
                stringbuffer.append("<img src=\"").append(s1).append("\">");
                i++;
            } else
            if(s2 != null && s2.length() > 0 && c == ':' && c1 == '(')
            {
                stringbuffer.append("<img src=\"").append(s2).append("\">");
                i++;
            } else
            if(s3 != null && s3.length() > 0 && c == '8' && c1 == ')')
            {
                stringbuffer.append("<img src=\"").append(s3).append("\">");
                i++;
            } else
            {
                stringbuffer.append(c);
            }
        }

        if(i != s.length())
            stringbuffer.append(s.charAt(s.length() - 1));
        return stringbuffer.toString();
    }
}

⌨️ 快捷键说明

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