//----------------------------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;

import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.List;

import org.huihoo.workflow.WorkflowException;
import org.huihoo.workflow.xpdl.WorkflowPackage;
import org.huihoo.workflow.xpdl.parser.XPDLParser;
import org.huihoo.workflow.xpdl.parser.XPDLParseException;
import org.huihoo.workflow.xpdl.parser.XPDLParserFactory;

import org.huihoo.commons.jdbc.Store;

public class DefaultXPDLParser extends XPDLParser
{
	protected XPDLParserFactory xpf;
	protected List errorList ;
	
	public DefaultXPDLParser(XPDLParserFactory xpf) throws WorkflowException
	{
		this.xpf = xpf;
	}

	public WorkflowPackage parse(Store store) throws XPDLParseException,IOException
	{
		String storeType = store.getType();
		if (Store.XML_STORE.equals(storeType))
		{
			return parse(new File(store.getURL()));
		}
		else
		{
			return XPDLParserJDBC.parseJDBC(this, store);
		}
	}

	public WorkflowPackage parse(Reader is) throws XPDLParseException,IOException
	{
		return XPDLParserIO.parseReader(this, is);
	}

	public boolean isValidating()
	{
		return this.xpf.isValidating();
	}

	public boolean isXPDLValidating()
	{
		return this.xpf.isXPDLValidating();
	}
		
	public boolean isNamespaceAware()
	{
		return this.xpf.isNamespaceAware();
	}
	
	public  List getErrorList()
	{
		return errorList;
	}
}
