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

Print this page




  59         NOTIFY_BUILTIN_REFS,
  60         REPORT_WHITESPACE
  61     };
  62 
  63     // properties
  64 
  65     /** Property identifier: symbol table. */
  66     protected static final String SYMBOL_TABLE =
  67         Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  68 
  69     /** Property identifier: XML grammar pool. */
  70     protected static final String XMLGRAMMAR_POOL =
  71         Constants.XERCES_PROPERTY_PREFIX+Constants.XMLGRAMMAR_POOL_PROPERTY;
  72 
  73     /** Recognized properties. */
  74     private static final String[] RECOGNIZED_PROPERTIES = {
  75         SYMBOL_TABLE,
  76         XMLGRAMMAR_POOL,
  77     };
  78 

  79     //
  80     // Constructors
  81     //
  82 
  83     /**
  84      * Constructs a SAX parser using the specified parser configuration.
  85      */
  86     public SAXParser(XMLParserConfiguration config) {
  87         super(config);
  88     } // <init>(XMLParserConfiguration)
  89 
  90     /**
  91      * Constructs a SAX parser using the dtd/xml schema parser configuration.
  92      */
  93     public SAXParser() {
  94         this(null, null);
  95     } // <init>()
  96 
  97     /**
  98      * Constructs a SAX parser using the specified symbol table.


 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


  59         NOTIFY_BUILTIN_REFS,
  60         REPORT_WHITESPACE
  61     };
  62 
  63     // properties
  64 
  65     /** Property identifier: symbol table. */
  66     protected static final String SYMBOL_TABLE =
  67         Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  68 
  69     /** Property identifier: XML grammar pool. */
  70     protected static final String XMLGRAMMAR_POOL =
  71         Constants.XERCES_PROPERTY_PREFIX+Constants.XMLGRAMMAR_POOL_PROPERTY;
  72 
  73     /** Recognized properties. */
  74     private static final String[] RECOGNIZED_PROPERTIES = {
  75         SYMBOL_TABLE,
  76         XMLGRAMMAR_POOL,
  77     };
  78 
  79     XMLSecurityPropertyManager securityPropertyManager;
  80     //
  81     // Constructors
  82     //
  83 
  84     /**
  85      * Constructs a SAX parser using the specified parser configuration.
  86      */
  87     public SAXParser(XMLParserConfiguration config) {
  88         super(config);
  89     } // <init>(XMLParserConfiguration)
  90 
  91     /**
  92      * Constructs a SAX parser using the dtd/xml schema parser configuration.
  93      */
  94     public SAXParser() {
  95         this(null, null);
  96     } // <init>()
  97 
  98     /**
  99      * Constructs a SAX parser using the specified symbol table.


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