KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > xml > parsers > AbstractDocumentBuilder


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.xml.parsers;
30
31 import com.caucho.xml.QDOMImplementation;
32 import com.caucho.xml.Xml;
33 import com.caucho.xml.XmlParser;
34
35 import org.w3c.dom.DOMImplementation JavaDoc;
36 import org.w3c.dom.Document JavaDoc;
37 import org.xml.sax.EntityResolver JavaDoc;
38 import org.xml.sax.ErrorHandler JavaDoc;
39 import org.xml.sax.InputSource JavaDoc;
40 import org.xml.sax.SAXException JavaDoc;
41
42 import javax.xml.parsers.DocumentBuilder JavaDoc;
43 import java.io.IOException JavaDoc;
44 import java.io.InputStream JavaDoc;
45
46 /**
47  * JAXP document builder factory for strict XML parsing.
48  */

49 public class AbstractDocumentBuilder extends DocumentBuilder JavaDoc {
50   // The parser implementation.
51
protected XmlParser _parser;
52
53   public DOMImplementation getDOMImplementation()
54   {
55     return new QDOMImplementation();
56   }
57
58   /**
59    * Parses the document based on an input source.
60    *
61    * @param is the SAX input source
62    *
63    * @return the parsed document
64    */

65   public Document JavaDoc parse(InputSource JavaDoc is)
66     throws IOException JavaDoc, SAXException JavaDoc
67   {
68     return _parser.parseDocument(is);
69   }
70
71   /**
72    * Parses the document based on an input stream.
73    *
74    * @param is the input stream.
75    *
76    * @return the parsed document
77    */

78   public Document JavaDoc parse(InputStream JavaDoc is)
79     throws IOException JavaDoc, SAXException JavaDoc
80   {
81     return _parser.parseDocument(is);
82   }
83
84   /**
85    * Parses the document based on an input stream.
86    *
87    * @param is the input stream.
88    * @param systemId the stream's URL.
89    *
90    * @return the parsed document
91    */

92   public Document JavaDoc parse(InputStream JavaDoc is, String JavaDoc systemId)
93     throws IOException JavaDoc, SAXException JavaDoc
94   {
95     return _parser.parseDocument(is, systemId);
96   }
97
98   public boolean isNamespaceAware()
99   {
100     return _parser.isNamespaceAware();
101   }
102     
103   public boolean isValidating()
104   {
105     return false;
106   }
107
108   /**
109    * Sets the callback to lookup included files.
110    *
111    * @param er the callback object to find included files.
112    */

113   public void setEntityResolver(EntityResolver JavaDoc er)
114   {
115     _parser.setEntityResolver(er);
116   }
117     
118   public void setErrorHandler(ErrorHandler JavaDoc eh)
119   {
120     _parser.setErrorHandler(eh);
121   }
122     
123   public Document JavaDoc newDocument()
124   {
125     return Xml.createDocument();
126   }
127 }
128
Popular Tags