/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* CVS $Id: DocumentBuilderImpl.java,v 1.10 2004/02/08 03:50:14 vgritsenko Exp $
*/
package org.apache.xindice.xml.jaxp;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xindice.xml.dom.DOMImplementationImpl;
import org.apache.xindice.xml.dom.DOMParser;
import org.apache.xindice.xml.dom.DocumentImpl;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
/**
* DocumentBuilderImpl
*
* @version CVS $Revision: 1.10 $, $Date: 2004/02/08 03:50:14 $
*/
public class DocumentBuilderImpl extends DocumentBuilder {
private static final Log log = LogFactory.getLog(DocumentBuilderImpl.class);
private DOMParser parser = null;
private ErrorHandler errors = null;
private EntityResolver entities = null;
protected DocumentBuilderImpl() throws ParserConfigurationException {
try {
parser = new DOMParser();
} catch (Exception e) {
if (log.isWarnEnabled()) {
log.warn("ignored exception", e);
}
}
}
public DOMImplementation getDOMImplementation() {
return DOMImplementationImpl.getInstance();
}
public boolean isNamespaceAware() {
return true;
}
public boolean isValidating() {
return false;
}
public void setErrorHandler(ErrorHandler errors) {
this.errors = errors;
}
public void setEntityResolver(EntityResolver entities) {
this.entities = entities;
}
public Document parse(InputSource source) throws SAXException, IOException, IllegalArgumentException {
if (source == null) {
throw new IllegalArgumentException();
} else {
parser.parse(source);
}
return parser.getDocument();
}
public Document newDocument() {
return new DocumentImpl();
}
}