package com.jxml.quick.recycle;
import org.xml.sax.*;
import org.xml.sax.helpers.XMLReaderAdapter;
import javax.xml.parsers.SAXParserFactory;

public class JAXP
{
	public static SAXParserFactory pf=null;

	static 
	{
		try
		{
			pf=SAXParserFactory.newInstance();
			XMLReader sp=pf.newSAXParser().getXMLReader();
			new XMLReaderAdapter(sp);
		}
		catch(Exception e)
		{
			pf=null;
		}
	}

	public static boolean selectingParser()
	{
		return pf!=null;
	}

	public static Parser newParser()
	{
		try
		{
			XMLReader sp=pf.newSAXParser().getXMLReader();
			return new XMLReaderAdapter(sp);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			throw new Error(e.toString());
		}
	}
}