//----------------------------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.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.List;

import org.huihoo.workflow.xpdl.WorkflowPackage;

import org.huihoo.commons.jdbc.Store;

public abstract class XPDLParser
{
  protected XPDLParser() 
  {
  }
  
  /**
   * Parse the content of the given file as an XML document
   * and return a new Package {@link org.huihoo.workflow.core.WorkflowPackage} object.
   *
   * @param f The file containing the XML to parse.
   * @exception IOException If any IO errors occur.
   * @exception wfException If any parse errors occur.
   * @exception IllegalArgumentException If the file is null.
   * @return A new Package object.
   */
  public  WorkflowPackage parse(File f)
  throws XPDLParseException,IOException
  {
		return parse(f,System.getProperty("file.encoding"));
  }
  
	public  WorkflowPackage parse(File f,String charsetName)
	throws XPDLParseException,IOException
	{
		return parse(new FileInputStream(f),charsetName);
	}
	  
  /**
   * Parse the content of the given file as an XML document
   * and return a new Package {@link org.huihoo.workflow.core.WorkflowPackage} object.
   *
   * @param f The file containing the XML to parse.
   * @exception IOException If any IO errors occur.
   * @exception wfException If any parse errors occur.
   * @exception IllegalArgumentException If the file is null.
   * @return A new Package object.
   */

  public  WorkflowPackage parse(InputStream is)
  throws XPDLParseException,IOException
  {
  	return parse(is,System.getProperty("file.encoding"));
  }
  
	public  WorkflowPackage parse(InputStream is,String charsetName)
		throws XPDLParseException,IOException
	{
		return parse(new InputStreamReader(is,charsetName));
	}

	public abstract WorkflowPackage parse(Reader in)
		throws XPDLParseException,IOException;

			 
  public abstract WorkflowPackage parse(Store store)
  throws XPDLParseException,IOException;
  
	/**
	 * 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 abstract boolean isValidating();
	
	/**
	 * Indicates whether or not the factory is configured to produce
	 * parsers which validate the package XPDL content during parse.
	 *
	 * @return  true if the factory is configured to produce parsers
	 *          which validate the package XPDL content during parse; false otherwise.
	 */

	public abstract boolean isXPDLValidating();
	
	/**
	 * Indicates whether or not this parser is configured to
	 * understand namespaces.
	 *
	 * @return true if this parser is configured to
	 *         understand namespaces; false otherwise.
	 */
    
	public abstract boolean isNamespaceAware();
	
	public abstract List getErrorList();
}
