//----------------------------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.xpdl.parser;

import java.util.Hashtable;

import org.huihoo.workflow.WorkflowException;

public abstract class XPDLParserFactory
{
	protected boolean validating = false;	
	protected boolean validating2 = true;
	protected boolean namespaceAware = true;

	protected XPDLParserFactory()
	{
	}

	public static XPDLParserFactory newInstance(Hashtable env) throws FactoryConfigurationError
	{
		try
		{
			return (XPDLParserFactory) FactoryFinder.find(
				(String) env.get(org.huihoo.workflow.WorkflowGlobals.XPDL_PARSER_FACTORY_KEY),
				"org.huihoo.workflow.coreImpl.xpdl.parser.XPDLParserFactoryImpl");
		}
		catch (FactoryFinder.ConfigurationError e)
		{
			throw new FactoryConfigurationError(e.getException(), e.getMessage());
		}
	}

	public abstract XPDLParser newXPDLParser() throws WorkflowException;

	/**
		* Specifies that the parser produced by this code will
		* validate package as they are parsed. By default the value of this
		* is set to <code>false</code>.
		*
		* @param validating true if the parser produced will validate package
		*                   as they are parsed; false otherwise.
		*/

	public void setValidating(boolean validating)
	
	{
		this.validating = validating;
	}

	/**
	 * Indicates whether or not the factory is configured to produce
	 * parsers which validate the package content during parse.
	 *
	 * @return  true if the factory is configured to produce parsers
	 *          which validate the package content during parse; false otherwise.
	 */

	public boolean isValidating()
	{
		return validating;
	}

	/**
		* Specifies that the parser produced by this code will
		* validate XPDL package as they are parsed. By default the value of this
		* is set to <code>false</code>.
		*
		* @param validating true if the parser produced will validate package
		*                   as they are parsed; false otherwise.
		*/

	public void setXPDLValidating(boolean validating)
	
	{
		this.validating2 = validating;
	}

	/**
	 * Indicates whether or not the factory is configured to produce
	 * parsers which validate the package content during parse.
	 *
	 * @return  true if the factory is configured to produce parsers
	 *          which validate the package XPDL content during parse; false otherwise.
	 */

	public boolean isXPDLValidating()
	{
		return validating2;
	}
	
	/**
	 * Specifies that the parser produced by this code will
	 * provide support for XML namespaces. By default the value of this is set
	 * to <code>true</code>.
	 *
	 * @param awareness true if the parser produced by this code will
	 *                  provide support for XML namespaces; false otherwise.
	 */

	public void setNamespaceAware(boolean awareness)
	{
		this.namespaceAware = awareness;
	}

	/**
	 * Indicates whether or not the factory is configured to produce
	 * parsers which are namespace aware.
	 *
	 * @return true if the factory is configured to produce
	 *         parsers which are namespace aware; false otherwise.
	 */

	public boolean isNamespaceAware()
	{
		return namespaceAware;
	}
}
