Package org.apache.xindice.xml.jaxp

Source Code of org.apache.xindice.xml.jaxp.DocumentBuilderImpl

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
* $Id: DocumentBuilderImpl.java 541508 2007-05-25 01:54:12Z vgritsenko $
*/

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 $Revision: 541508 $, $Date: 2007-05-24 21:54:12 -0400 (Thu, 24 May 2007) $
*/
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();
    }
}
TOP

Related Classes of org.apache.xindice.xml.jaxp.DocumentBuilderImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.