//----------------------------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.willow.xmlrules;

import org.apache.commons.digester.Rule;
import org.huihoo.commons.util.IntrospectionUtils;
import org.xml.sax.Attributes;


public class SetAllPropertiesRule extends Rule
{
	// --------------------------------------------------------- Public Methods
	/**
	 * Handle the beginning of an XML element.
	 * @param namespace the namespace URI of the matching element, or an 
	 *   empty string if the parser is not namespace aware or the element has
	 *   no namespace
	 * @param name the local name if the parser is namespace aware, or just 
	 *   the element name otherwise
	 *
	 * @param attributes The attributes of this element
	 *
	 * @exception Exception if a processing error occurs
	 */
	public void begin(String namespace, String name, Attributes attributes) throws Exception
	{
		for (int i = 0; i < attributes.getLength(); i++)
		{
			String localName = attributes.getLocalName(i);
			if ("".equals(localName))
			{
				localName = attributes.getQName(i);
			}
			String value = attributes.getValue(i);
			IntrospectionUtils.setProperty(digester.peek(), localName, value);
		}
	}
}