Save This Page
Home » Xerces-J-src.2.9.1 » org.apache.xerces » parsers » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    * 
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    * 
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   
   18   package org.apache.xerces.parsers;
   19   
   20   import java.io.IOException;
   21   
   22   import org.apache.xerces.impl.Constants;
   23   import org.apache.xerces.xni.XNIException;
   24   import org.apache.xerces.xni.parser.XMLInputSource;
   25   import org.apache.xerces.xni.parser.XMLParserConfiguration;
   26   
   27   /**
   28    * Base class of all XML-related parsers.
   29    * <p>
   30    * In addition to the features and properties recognized by the parser
   31    * configuration, this parser recognizes these additional features and
   32    * properties:
   33    * <ul>
   34    * <li>Properties
   35    *  <ul>
   36    *   <li>http://apache.org/xml/properties/internal/error-handler</li>
   37    *   <li>http://apache.org/xml/properties/internal/entity-resolver</li>
   38    *  </ul>
   39    * </ul>
   40    *
   41    * @author Arnaud  Le Hors, IBM
   42    * @author Andy Clark, IBM
   43    *
   44    * @version $Id: XMLParser.java 447239 2006-09-18 05:08:26Z mrglavas $
   45    */
   46   public abstract class XMLParser {
   47   
   48       //
   49       // Constants
   50       //
   51   
   52       // properties
   53   
   54       /** Property identifier: entity resolver. */
   55       protected static final String ENTITY_RESOLVER = 
   56           Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
   57   
   58       /** Property identifier: error handler. */
   59       protected static final String ERROR_HANDLER = 
   60           Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
   61   
   62       /** Recognized properties. */
   63       private static final String[] RECOGNIZED_PROPERTIES = {
   64           ENTITY_RESOLVER,
   65           ERROR_HANDLER,
   66       };
   67   
   68       //
   69       // Data
   70       //
   71   
   72       /** The parser configuration. */
   73       protected XMLParserConfiguration fConfiguration;
   74   
   75       //
   76       // Constructors
   77       //
   78   
   79       /**
   80        * Default Constructor.
   81        */
   82       protected XMLParser(XMLParserConfiguration config) {
   83   
   84           // save configuration
   85           fConfiguration = config;
   86   
   87           // add default recognized properties
   88           fConfiguration.addRecognizedProperties(RECOGNIZED_PROPERTIES);
   89   
   90       } // <init>(XMLParserConfiguration)
   91   
   92       //
   93       // Public methods
   94       //
   95   
   96       /**
   97        * parse
   98        *
   99        * @param inputSource
  100        *
  101        * @exception XNIException
  102        * @exception java.io.IOException
  103        */
  104       public void parse(XMLInputSource inputSource) 
  105           throws XNIException, IOException {
  106   
  107           reset();
  108           fConfiguration.parse(inputSource);
  109   
  110       } // parse(XMLInputSource) 
  111   
  112       //
  113       // Protected methods
  114       //
  115   
  116       /**
  117        * reset all components before parsing
  118        */
  119       protected void reset() throws XNIException {
  120       } // reset()
  121   
  122   } // class XMLParser

Save This Page
Home » Xerces-J-src.2.9.1 » org.apache.xerces » parsers » [javadoc | source]