KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > parsers > XMLParser


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.parsers;
18
19 import java.io.IOException JavaDoc;
20
21 import org.apache.xerces.impl.Constants;
22 import org.apache.xerces.xni.XNIException;
23 import org.apache.xerces.xni.parser.XMLInputSource;
24 import org.apache.xerces.xni.parser.XMLParserConfiguration;
25
26 /**
27  * Base class of all XML-related parsers.
28  * <p>
29  * In addition to the features and properties recognized by the parser
30  * configuration, this parser recognizes these additional features and
31  * properties:
32  * <ul>
33  * <li>Properties
34  * <ul>
35  * <li>http://apache.org/xml/properties/internal/error-handler</li>
36  * <li>http://apache.org/xml/properties/internal/entity-resolver</li>
37  * </ul>
38  * </ul>
39  *
40  * @author Arnaud Le Hors, IBM
41  * @author Andy Clark, IBM
42  *
43  * @version $Id: XMLParser.java,v 1.10 2004/02/24 23:15:57 mrglavas Exp $
44  */

45 public abstract class XMLParser {
46
47     //
48
// Constants
49
//
50

51     // properties
52

53     /** Property identifier: entity resolver. */
54     protected static final String JavaDoc ENTITY_RESOLVER =
55         Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
56
57     /** Property identifier: error handler. */
58     protected static final String JavaDoc ERROR_HANDLER =
59         Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
60
61     /** Recognized properties. */
62     private static final String JavaDoc[] RECOGNIZED_PROPERTIES = {
63         ENTITY_RESOLVER,
64         ERROR_HANDLER,
65     };
66
67     //
68
// Data
69
//
70

71     /** The parser configuration. */
72     protected XMLParserConfiguration fConfiguration;
73
74     //
75
// Constructors
76
//
77

78     /**
79      * Default Constructor.
80      */

81     protected XMLParser(XMLParserConfiguration config) {
82
83         // save configuration
84
fConfiguration = config;
85
86         // add default recognized properties
87
fConfiguration.addRecognizedProperties(RECOGNIZED_PROPERTIES);
88
89     } // <init>(XMLParserConfiguration)
90

91     //
92
// Public methods
93
//
94

95     /**
96      * parse
97      *
98      * @param inputSource
99      *
100      * @exception XNIException
101      * @exception java.io.IOException
102      */

103     public void parse(XMLInputSource inputSource)
104         throws XNIException, IOException JavaDoc {
105
106         reset();
107         fConfiguration.parse(inputSource);
108
109     } // parse(XMLInputSource)
110

111     //
112
// Protected methods
113
//
114

115     /**
116      * reset all components before parsing
117      */

118     protected void reset() throws XNIException {
119     } // reset()
120

121 } // class XMLParser
122
Popular Tags