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

📄 infoconfig.java

📁 源码/软件简介: 云网论坛1.1RC国际版是采用JSP开发的集论坛、CMS(网站内容管理系统)、博客、聊天室、商城、交友、语音灌水等于一体的门户式社区。拥有CWBBS ( Cloud Web BBS
💻 JAVA
字号:
package com.redmoon.forum.plugin.info;

import cn.js.fan.util.XMLProperties;
import java.net.URL;
import org.jdom.Element;
import org.apache.log4j.Logger;
import org.jdom.Document;
import java.io.FileInputStream;
import org.jdom.input.SAXBuilder;
import cn.js.fan.util.StrUtil;
import cn.js.fan.cache.jcs.RMCache;
import java.util.Vector;
import cn.js.fan.base.BaseConfig;
import java.util.List;
import java.util.Iterator;
import java.net.URLDecoder;

public class InfoConfig extends BaseConfig {
    RMCache rmCache;

    private XMLProperties properties;
    private final String CONFIG_FILENAME = "config_" + InfoUnit.code + ".xml";

    private String cfgpath;

    Logger logger;
    Document doc = null;
    Element root = null;

    //String DESKey = "fgfkeydw";//DES密钥长度为64bit,1个字母为八位,需8个字母,不能超过8个,否则会出错

    public InfoConfig() {
        rmCache = RMCache.getInstance();
        URL cfgURL = getClass().getClassLoader().getResource(CONFIG_FILENAME);
        cfgpath = cfgURL.getFile();
        cfgpath = URLDecoder.decode(cfgpath);

        properties = new XMLProperties(cfgpath);

        logger = Logger.getLogger(InfoConfig.class.getName());

        SAXBuilder sb = new SAXBuilder();
        try {
            FileInputStream fin = new FileInputStream(cfgpath);
            doc = sb.build(fin);
            root = doc.getRootElement();
            fin.close();
        } catch (org.jdom.JDOMException e) {
            logger.error("InfoConfig:" + e.getMessage());
        } catch (java.io.IOException e) {
            logger.error("InfoConfig:" + e.getMessage());
        }
    }

    public String getProperty(String name) {
        return properties.getProperty(name);
    }

    public int getIntProperty(String name) {
        String p = getProperty(name);
        if (StrUtil.isNumeric(p)) {
            return Integer.parseInt(p);
        }
        else
            return -65536;
    }

    public void setProperty(String name, String value) {
        properties.setProperty(name, value);
    }

    public String getTypeName(String code) {
        String typeName=null;
        try {
            typeName = (String)rmCache.getFromGroup(code, this.cacheGroup);
        }
        catch (Exception e) {
            logger.info("getTypeName1:" + e.getMessage());
        }
        if (typeName==null) {
            Iterator ir = getAllType().iterator();
            while (ir.hasNext()) {
                InfoType it = (InfoType)ir.next();
                if (it.getCode().equals(code)) {
                    return it.getName();
                }
            }
            if (typeName==null)
                typeName = "";
        }
        return typeName;
    }

    public Vector getAllType() {
        Vector v = null;
        try {
            v = (Vector) rmCache.getFromGroup("infoTypes", cacheGroup);
        }
        catch (Exception e) {
            logger.error("getAllType:" + e.getMessage());
        }
        if (v==null) {
            v = new Vector();
            Element e = root.getChild("alltype");
            List list = e.getChildren();
            if (list!=null) {
                Iterator ir = list.iterator();
                while (ir.hasNext()) {
                    e = (Element)ir.next();
                    InfoType it = new InfoType();
                    String code = e.getAttributeValue("code");
                    String name = e.getChildText("name");
                    it.setCode(code);
                    it.setName(name);
                    v.addElement(it);
                }
            }
        }
        return v;
    }

    public String getAllTypeOptions() {
        String str = "";
        Iterator ir = getAllType().iterator();
        while (ir.hasNext()) {
            InfoType it = (InfoType) ir.next();
            str += "<option value='" + it.getCode() + "'>" + it.getName() + "</option>";
        }
        return str;
    }
}

⌨️ 快捷键说明

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