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

📄 installconfig.java

📁 jfreechart技术的一些源代码
💻 JAVA
字号:
/**
 * 本程序源代码及其目标程序由Turbo Chen 版权所有.
 * 你可以使用,转载,分发本程序,但必须保留本版权申明内容.
 *
 * @author Turbo Chen(turbochen@163.com)
 * @create date 2004-2-8
 */
package net.turbochen.autoinstaller;

import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

/**
 *
 * 安装配置.
 * 
 * @author Turbo Chen(turbochen@163.com)
 */
public class InstallConfig
{

	private final static String CONFIG = "install-config.xml";
	
	private ResourceCollection resSet = new ResourceCollection();
	
	private String resourceBase = "";
	
	private static InstallConfig installConfig = null;
	
	private InstallConfig()
	{
		super();
		load();
	}
	
	public static InstallConfig getInstance()
	{
		if ( installConfig==null ) installConfig = new InstallConfig();
		return installConfig;
	}
	
	/**
	 * 取得所有安装资源。
	 * @return
	 * @author Turbo Chen(turbochen@163.com)
	 */
	public ResourceCollection getResources()
	{
		return this.resSet;
	}
	
	/**
	 * 取得安装资源所在的基准位置。
	 * @return
	 * @author Turbo Chen(turbochen@163.com)
	 */
	public String getResourceBase()
	{
		return this.resourceBase;
	}
	
	private void load()
	{
		try
		{
			InputStream input = ClassLoader.getSystemClassLoader().getResourceAsStream(CONFIG);
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		    DocumentBuilder builder = factory.newDocumentBuilder();
		    Document configDoc = builder.parse(input);
		    
			Element eConfig = (Element) configDoc.getElementsByTagName("install-config").item(0);
			resourceBase = eConfig.getAttribute("resourcebase");

			NodeList eResources = configDoc.getElementsByTagName("resource");
			for ( int i=0;i<eResources.getLength();i++ )
			{
				Element eResource = (Element) eResources.item(i);
				Resource res = new Resource(eResource.getAttribute("name"),PathUtil.replaceAll(eResource.getAttribute("dist")));
				resSet.addResource(res);
			}
		    
		} catch (ParserConfigurationException e)
		{
		    // TODO 异常处理
		    e.printStackTrace();
		} catch (SAXException e)
		{
		    // TODO 异常处理
		    e.printStackTrace();
		} catch (IOException e)
		{
		    // TODO 异常处理
		    e.printStackTrace();
		}
			
	
	}



}

⌨️ 快捷键说明

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