package com.jxml.quick;
import com.jxml.quick.recycle.*;
import com.jxml.quick.engine.*;
import java.io.*;
import org.xml.sax.*;

public abstract class QSchemaFactory
{
	public abstract QDoc create()
		throws SAXException, QE, QPE, ClassNotFoundException, 
		InstantiationException, IllegalAccessException;

	public static QDoc create(String className)
		throws SAXException, QE, QPE, ClassNotFoundException, 
		InstantiationException, IllegalAccessException
	{
		return clCreate(className,null);
	}

	public static QDoc clCreate(String className, ClassLoader cl)
		throws SAXException, QE, QPE, ClassNotFoundException, 
		InstantiationException, IllegalAccessException
	{
		Class c;
		if (cl==null)
			c=Class.forName(className);
		else
			c=cl.loadClass(className);
		Object o=c.newInstance();
		QSchemaFactory f=(QSchemaFactory)o;
		QDocImpl schema=(QDocImpl)f.create();
		schema.cl=cl;
		return schema;
	}

	public static QDoc create(String className, String schemaName)
		throws SAXException, QE, QPE, ClassNotFoundException, 
		InstantiationException, IllegalAccessException, IOException
	{
		if (!"".equals(className))
			return create(className);
		return Quick.parseSchema(schemaName);
	}
}
