//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.workflow.coreImpl.xpdl.parser.xmlrules;

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


public class DataFieldRuleSet 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 DataFieldRuleSet()
	{

		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 DataFieldRuleSet(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)
	{
		//***********************************************************************************************    
		//  RESERVED PROPERTIES (IsArray and Length)
		//  @author zosatapo 2004-03-26 
		//***********************************************************************************************		
		//digester.addCallMethod(prefix+"Length","setLength",0);

		//  [START]参数类型枚举选择============================================
		digester.addRule(prefix + "DataType/BasicType", new SetBasicTypeRule("type", "Type"));
		digester.addRule(prefix + "DataType/ExternalReference", new SetReferenceTypeRule());
		//  [STOP]参数类型枚举选择============================================

		digester.addCallMethod(prefix + "InitialValue", "setValue", 0);
		digester.addCallMethod(prefix + "Description", "setDescription", 0);

		digester.addObjectCreate(
			prefix + "ExtendedAttributes/ExtendedAttribute",
			"org.huihoo.workflow.xpdl.ExtendedAttribute");
		digester.addRule(prefix + "ExtendedAttributes/ExtendedAttribute", new SetAllPropertiesRule());
		digester.addSetNext(
			prefix + "ExtendedAttributes/ExtendedAttribute",
			"addExtendedAttribute",
			"org.huihoo.workflow.xpdl.ExtendedAttribute");

	}

}