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

Save This Page
Home » openjdk-7 » com.sun.org.apache.xerces.internal » parsers » [javadoc | source]