/*
 * Created on 2004-10-19
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.huihoo.willow.store;

import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSetBase;

/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class DatabaseRuleSet extends RuleSetBase
{

	// ----------------------------------------------------- Instance Variables

	/**
	 * The matching pattern prefix to use for recognizing our elements.
	 */
	protected String prefix = null;

	// ------------------------------------------------------------ Constructor

	/**
	 * Construct an instance of this <code>RuleSet</code> with the default
	 * matching pattern prefix.
	 */
	public DatabaseRuleSet()
	{

		this("");

	}

	/**
	 * Construct an instance of this <code>RuleSet</code> with the specified
	 * matching pattern prefix.
	 *
	 * @param prefix Prefix for matching pattern rules (including the
	 *  trailing slash character)
	 */
	public DatabaseRuleSet(String prefix)
	{

		super();
		this.namespaceURI = null;
		this.prefix = prefix;

	}

	// --------------------------------------------------------- Public Methods

	/**
	 * <p>Add the set of Rule instances defined in this RuleSet to the
	 * specified <code>Digester</code> instance, associating them with
	 * our namespace URI (if any).  This method should only be called
	 * by a Digester instance.</p>
	 *
	 * @param digester Digester instance to which the new Rule instances
	 *  should be added.
	 */
	public void addRuleInstances(Digester digester)
	{														 
		digester.addObjectCreate(prefix + "workflow-database/database","org.huihoo.willow.store.DatabaseEntry");
		digester.addSetNext("workflow-database/database","addDatabaseEntry","org.huihoo.willow.store.DatabaseEntry");
		digester.addCallMethod(prefix + "workflow-database/database/database-vendor", "setVendor", 0);
		digester.addCallMethod(prefix + "workflow-database/database/database-driver", "setDriver", 0);
		digester.addCallMethod(prefix + "workflow-database/database/userdatabase-class", "setUserDatabaseClass", 0);
		digester.addCallMethod(prefix + "workflow-database/database/casedatabase-class", "setCaseDatabaseClass", 0);
		digester.addCallMethod(prefix + "workflow-database/database/dispatcher-class","setDispatcherClass",0);
	}
}