src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java

Print this page




   5 /*
   6  * Copyright 2000-2005 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 com.sun.org.apache.xerces.internal.impl.Constants;
  24 import com.sun.org.apache.xerces.internal.util.SymbolTable;

  25 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
  26 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;


  27 
  28 /**
  29  * This is the main Xerces SAX parser class. It uses the abstract SAX
  30  * parser with a document scanner, a dtd scanner, and a validator, as
  31  * well as a grammar pool.
  32  *
  33  * @author Arnaud  Le Hors, IBM
  34  * @author Andy Clark, IBM
  35  *
  36  * @version $Id: SAXParser.java,v 1.7 2010-11-01 04:40:09 joehw Exp $
  37  */
  38 public class SAXParser
  39     extends AbstractSAXParser {
  40 
  41     //
  42     // Constants
  43     //
  44 
  45     // features
  46 


 103      * grammar pool.
 104      */
 105     public SAXParser(SymbolTable symbolTable, XMLGrammarPool grammarPool) {
 106         super(new XIncludeAwareParserConfiguration());
 107 
 108         // set features
 109         fConfiguration.addRecognizedFeatures(RECOGNIZED_FEATURES);
 110         fConfiguration.setFeature(NOTIFY_BUILTIN_REFS, true);
 111 
 112         // set properties
 113         fConfiguration.addRecognizedProperties(RECOGNIZED_PROPERTIES);
 114         if (symbolTable != null) {
 115             fConfiguration.setProperty(SYMBOL_TABLE, symbolTable);
 116         }
 117         if (grammarPool != null) {
 118             fConfiguration.setProperty(XMLGRAMMAR_POOL, grammarPool);
 119         }
 120 
 121     } // <init>(SymbolTable,XMLGrammarPool)
 122 




















 123 } // class SAXParser


   5 /*
   6  * Copyright 2000-2005 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 com.sun.org.apache.xerces.internal.impl.Constants;
  24 import com.sun.org.apache.xerces.internal.util.SymbolTable;
  25 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
  26 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
  27 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
  28 import org.xml.sax.SAXNotRecognizedException;
  29 import org.xml.sax.SAXNotSupportedException;
  30 
  31 /**
  32  * This is the main Xerces SAX parser class. It uses the abstract SAX
  33  * parser with a document scanner, a dtd scanner, and a validator, as
  34  * well as a grammar pool.
  35  *
  36  * @author Arnaud  Le Hors, IBM
  37  * @author Andy Clark, IBM
  38  *
  39  * @version $Id: SAXParser.java,v 1.7 2010-11-01 04:40:09 joehw Exp $
  40  */
  41 public class SAXParser
  42     extends AbstractSAXParser {
  43 
  44     //
  45     // Constants
  46     //
  47 
  48     // features
  49 


 106      * grammar pool.
 107      */
 108     public SAXParser(SymbolTable symbolTable, XMLGrammarPool grammarPool) {
 109         super(new XIncludeAwareParserConfiguration());
 110 
 111         // set features
 112         fConfiguration.addRecognizedFeatures(RECOGNIZED_FEATURES);
 113         fConfiguration.setFeature(NOTIFY_BUILTIN_REFS, true);
 114 
 115         // set properties
 116         fConfiguration.addRecognizedProperties(RECOGNIZED_PROPERTIES);
 117         if (symbolTable != null) {
 118             fConfiguration.setProperty(SYMBOL_TABLE, symbolTable);
 119         }
 120         if (grammarPool != null) {
 121             fConfiguration.setProperty(XMLGRAMMAR_POOL, grammarPool);
 122         }
 123 
 124     } // <init>(SymbolTable,XMLGrammarPool)
 125 
 126     /**
 127      * Sets the particular property in the underlying implementation of
 128      * org.xml.sax.XMLReader.
 129      */
 130     public void setProperty(String name, Object value)
 131         throws SAXNotRecognizedException, SAXNotSupportedException {
 132         XMLSecurityPropertyManager spm = new XMLSecurityPropertyManager();
 133         int index = spm.getIndex(name);
 134         if (index > -1) {
 135             /**
 136              * this is a direct call to this parser, not a subclass since
 137              * internally the support of this property is done through
 138              * XMLSecurityPropertyManager
 139              */
 140             spm.setValue(index, XMLSecurityPropertyManager.State.APIPROPERTY, (String)value);
 141             super.setProperty(Constants.XML_SECURITY_PROPERTY_MANAGER, spm);
 142         } else {
 143             super.setProperty(name, value);
 144         }
 145     }
 146 } // class SAXParser