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

📄 sampledigester2.java

📁 这是一个关于J2EE的开源包common里的许多组件的示例应用程序,可以借鉴.
💻 JAVA
字号:
package digester;

import java.io.IOException;

import org.apache.commons.digester.Digester;
import org.xml.sax.SAXException;

/**
 * Title : Base Dict Class
 * Description : here Description is the function of class, here maybe multirows    
 * @author        <a href="mailto:sunpeng@china.freeborders">kevin</a> 
 * @Version       1.0 
 */

/**
 * Class description goes here.
 * @version 1.0  2005-10-11 
 * @author kevin
 */
public class SampleDigester2
{

	public static void main(String[] args)
	{
		SampleDigester2 sample = new SampleDigester2();
		try
		{
			sample.run();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

	public void run() throws IOException, SAXException
	{
		Digester digester = new Digester();
		// This method pushes this (SampleDigester) class to the Digesters
		// object stack making its methods available to processing rules.
		digester.push(this);

		// This set of rules calls the addDataSource method and passes
		// in five parameters to the method.
		digester.addCallMethod("datasources/datasource", "addDataSource", 5);
		digester.addCallParam("datasources/datasource/name", 0);
		digester.addCallParam("datasources/datasource/driver", 1);
		digester.addCallParam("datasources/datasource/url", 2);
		digester.addCallParam("datasources/datasource/username", 3);
		digester.addCallParam("datasources/datasource/password", 4);

		// This method starts the parsing of the document.
		digester.parse("datasource.xml");
		System.out.println("==========");
	}

	// Example method called by Digester.
	public void addDataSource(String name, String driver, String url, String userName, String password)
	{
		System.out.println("datasources/datasource/name===" + name);
		System.out.println("datasources/datasource/driver===" + driver);
		System.out.println("datasources/datasource/url===" + url);
		System.out.println("datasources/datasource/userName===" + userName);
		System.out.println("datasources/datasource/password===" + password);
	}

}

⌨️ 快捷键说明

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