FileDocCategorySizeDatePackage
XMLParserFactory.javaAPI DocExample1093Sun Nov 23 18:03:36 GMT 2003pool

XMLParserFactory

public class XMLParserFactory extends Object implements ResourceFactory
A factory that generates XML parsers

Fields Summary
DocumentBuilderFactory
dbf
the single DocumentBuilderFactory
Constructors Summary
public XMLParserFactory()
Constructor. Create the factory.

        dbf = DocumentBuilderFactory.newInstance();
    
Methods Summary
public java.lang.ObjectcreateResource()
Create a new DocumentBuilder to add to the pool

        try {
            return dbf.newDocumentBuilder();
        } catch (ParserConfigurationException pce) {
            pce.printStackTrace();
            return null;
        }
    
public booleanvalidateResource(java.lang.Object o)
Check that a returned DocumentBuilder is valid. Reset parameters to defaults.

        if (!(o instanceof DocumentBuilder)) {
            return false;
        }
        
        DocumentBuilder db = (DocumentBuilder) o;
        db.setEntityResolver(null);
        db.setErrorHandler(null);
        
        return true;