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

📄 appconfig.java

📁 Athena酒店小组_Athena酒店管理系统
💻 JAVA
字号:
/*
 * DBConfig.java
 *
 * Created on 2007年5月12日, 下午1:14
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package utils;

import javax.xml.parsers.*;
import org.w3c.dom.*;

import plugin.*;

/**
 *
 * @author Virlene Cheng
 */
public class AppConfig
{
    public static final String CONFIG_DB_FILE = "Athena.xml";
    public static final String NODE_UI = "ui";
    public static final String NODE_UI_DECORATED = "decorated";
    public static final String NODE_UI_LOOKANDFEEL = "lookandfeel";
    
    private String configFile;
    private String decorated;
    private String lookAndFeel;
    
    /** 构造函数 */
    public AppConfig()
    {
	this.configFile = DBConfig.CONFIG_DB_FILE;
	loadConfig();
    }
    
    /**
     * 构造函数
     * @param 配置文件
     */
    public AppConfig(String configFile)
    {
	this.configFile = configFile;
	loadConfig();
    }
    
    public boolean getDecorated()
    {
	return Boolean.parseBoolean(decorated);
    }
    
    public String getLookAndFeel()
    {
	return lookAndFeel;
    }
    
    
    /**
     * 读取配置
     */
    private void loadConfig()
    {
	try
	{
	    //初始化XML文件读取器
	    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	    DocumentBuilder db = dbf.newDocumentBuilder();
	    Document doc = db.parse(configFile);
	    Element root = doc.getDocumentElement();
	    
	    //获取UI配置节点
	    Node ui = root.getElementsByTagName(AppConfig.NODE_UI).item(0);
	    loadUIConfig(ui);
	    
	    
	}
	catch(Exception ex)
	{
	    ex.printStackTrace();
	}
    }
    
    private void loadUIConfig(Node ui)
    {
	NodeList list = ui.getChildNodes();
	
	//获取UI的各项配置
	for (int i = 0; i < list.getLength(); i++)
	{
	    Node tempNode = list.item(i);
	    if (tempNode.getNodeName().equals(AppConfig.NODE_UI_DECORATED))
	    {
		decorated = tempNode.getTextContent();
	    }
	    if (tempNode.getNodeName().equals(AppConfig.NODE_UI_LOOKANDFEEL))
	    {
		lookAndFeel = tempNode.getTextContent();
	    }	
	}
    }
}

⌨️ 快捷键说明

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