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

📄 keyvalueconfigloader.java

📁 这个是使用java开发的一个平台
💻 JAVA
字号:
package com.exp.fcl.syscfg.loaders;

import com.exp.fcl.syscfg.KeyValueConfigFactory;
import com.exp.fcl.syscfg.SystemConfig;
import com.exp.fcl.syscfg.SystemLoader;
import com.exp.fcl.util.ValueList;
import com.exp.fcl.xml.EXPXMLDocument;
import com.exp.fcl.xml.EXPXMLNode;
import com.exp.fcl.xml.XMLDocumentBuilder;

public class KeyValueConfigLoader implements SystemLoader {
    private ValueList keyValues;

    private KeyValueConfigFactory keyValueCfgFactory;

    public void setItemConfig(EXPXMLNode itemConfigNode) {
        String name = itemConfigNode.getAttributeValue("name");
        String configPath = itemConfigNode.getAttributeValue("configpath");
        String clsName = itemConfigNode.getAttributeValue("factory");
        try {
            Class cls = Class.forName(clsName);
            this.keyValueCfgFactory = (KeyValueConfigFactory) cls.newInstance();
            String fileName = SystemConfig.getConfigPath() + configPath;
            EXPXMLDocument doc = XMLDocumentBuilder.buildDocument();
            doc.loadFromFile(fileName);
            EXPXMLNode root = doc.getRoot();
            int count = root.getChildNodesCount();
            this.keyValues = new ValueList();
            for (int i = 0; i < count; i++) {
                EXPXMLNode configNode = root.getChildNode(i);
                keyValues.add(configNode.getNodeName(), configNode
                        .getNodeValue());
            }
        } catch (Exception e) {
            System.err.println("初始化键值对配置失败, 名称:" + name + " 路径:" + configPath
                    + "  工厂类:" + clsName + "!");
            e.printStackTrace();
        }
    }

    public void load() {
        if (this.keyValueCfgFactory != null && keyValues != null) {
            this.keyValueCfgFactory.handle(this.keyValues);
        }
    }

    public boolean canExecute() {
        return true;
    }
}

⌨️ 快捷键说明

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