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

📄 filterfontstyle.java

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

import org.ehotsoft.yekki.util.StringUtil;

import java.io.Serializable;
import java.util.Properties;

public class FilterFontStyle extends Filter
    implements java.io.Serializable {

    private Properties props;

    public FilterFontStyle( Message message ) {

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

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

    private void initializeProperties() {

        props.put("Bold", "on");
        props.put("Italics", "on");
    }

    private String fontStyleToHTML(String s) {

        if(s == null || s.length() == 0)
            return s;
        int ai[] = new int[1];
        int ai1[] = new int[1];
        int ai2[] = new int[1];
        int ai3[] = new int[1];
        if(props.getProperty("Bold").equals("on"))
        {
            s = StringUtil.replace(s, "[b]", "<b>", ai);
            s = StringUtil.replace(s, "[/b]", "</b>", ai2);
            int i = ai[0];
            for(int k = ai2[0]; i > k; k++)
                s = s.concat("</b>");

        }
        if(props.getProperty("Italics").equals("on"))
        {
            s = StringUtil.replace(s, "[i]", "<i>", ai1);
            s = StringUtil.replace(s, "[/i]", "</i>", ai3);
            int j = ai1[0];
            for(int l = ai3[0]; j > l; l++)
                s = s.concat("</i>");

        }
        return s;
    }
}

⌨️ 快捷键说明

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