com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarLoader Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarLoader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLGrammarPreparser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #2
Source File: XMLGrammarPreparser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #3
Source File: XMLGrammarPreparser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #4
Source File: XMLGrammarPreparser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #5
Source File: XMLGrammarPreparser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void setFeature(String featureId, boolean value) {
    Enumeration loaders = fLoaders.elements();
    while(loaders.hasMoreElements()){
        XMLGrammarLoader gl = (XMLGrammarLoader)loaders.nextElement();
        try {
            gl.setFeature(featureId, value);
        } catch(Exception e) {
            // eat it up...
        }
    }
    // since our error reporter is a property we set later,
    // make sure features it understands are also set.
    if(featureId.equals(CONTINUE_AFTER_FATAL_ERROR)) {
        fErrorReporter.setFeature(CONTINUE_AFTER_FATAL_ERROR, value);
    }
}
 
Example #6
Source File: XMLGrammarPreparser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = (XMLGrammarLoader)fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #7
Source File: XMLGrammarPreparser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #8
Source File: XMLGrammarPreparser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = (XMLGrammarLoader)fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #9
Source File: XMLGrammarPreparser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #10
Source File: XMLGrammarPreparser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void setFeature(String featureId, boolean value) {
    Enumeration loaders = fLoaders.elements();
    while(loaders.hasMoreElements()){
        XMLGrammarLoader gl = (XMLGrammarLoader)loaders.nextElement();
        try {
            gl.setFeature(featureId, value);
        } catch(Exception e) {
            // eat it up...
        }
    }
    // since our error reporter is a property we set later,
    // make sure features it understands are also set.
    if(featureId.equals(CONTINUE_AFTER_FATAL_ERROR)) {
        fErrorReporter.setFeature(CONTINUE_AFTER_FATAL_ERROR, value);
    }
}
 
Example #11
Source File: XMLGrammarPreparser.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #12
Source File: XMLGrammarPreparser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void setFeature(String featureId, boolean value) {
    Enumeration loaders = fLoaders.elements();
    while(loaders.hasMoreElements()){
        XMLGrammarLoader gl = (XMLGrammarLoader)loaders.nextElement();
        try {
            gl.setFeature(featureId, value);
        } catch(Exception e) {
            // eat it up...
        }
    }
    // since our error reporter is a property we set later,
    // make sure features it understands are also set.
    if(featureId.equals(CONTINUE_AFTER_FATAL_ERROR)) {
        fErrorReporter.setFeature(CONTINUE_AFTER_FATAL_ERROR, value);
    }
}
 
Example #13
Source File: XMLGrammarPreparser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = (XMLGrammarLoader)fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #14
Source File: XMLGrammarPreparser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #15
Source File: XMLGrammarPreparser.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #16
Source File: XMLGrammarPreparser.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #17
Source File: XMLGrammarPreparser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #18
Source File: XMLGrammarPreparser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #19
Source File: XMLGrammarPreparser.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #20
Source File: XMLGrammarPreparser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #21
Source File: XMLGrammarPreparser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #22
Source File: XMLGrammarPreparser.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #23
Source File: XMLGrammarPreparser.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #24
Source File: XMLGrammarPreparser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
Example #25
Source File: XMLGrammarPreparser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #26
Source File: XMLGrammarPreparser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void setProperty(String propId, Object value) {
    for (Map.Entry<String, XMLGrammarLoader> entry : fLoaders.entrySet()) {
        try {
            XMLGrammarLoader gl = entry.getValue();
            gl.setProperty(propId, value);
        } catch(Exception e) {
            // eat it up...
        }
    }
}
 
Example #27
Source File: XMLGrammarPreparser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void setFeature(String featureId, boolean value) {
    for (Map.Entry<String, XMLGrammarLoader> entry : fLoaders.entrySet()) {
        try {
            XMLGrammarLoader gl = entry.getValue();
            gl.setFeature(featureId, value);
        } catch(Exception e) {
            // eat it up...
        }
    }
    // since our error reporter is a property we set later,
    // make sure features it understands are also set.
    if(featureId.equals(CONTINUE_AFTER_FATAL_ERROR)) {
        fErrorReporter.setFeature(CONTINUE_AFTER_FATAL_ERROR, value);
    }
}
 
Example #28
Source File: XMLGrammarPreparser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void setProperty(String propId, Object value) {
    for (Map.Entry<String, XMLGrammarLoader> entry : fLoaders.entrySet()) {
        try {
            XMLGrammarLoader gl = entry.getValue();
            gl.setProperty(propId, value);
        } catch(Exception e) {
            // eat it up...
        }
    }
}
 
Example #29
Source File: XMLGrammarPreparser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setProperty(String propId, Object value) {
    Enumeration loaders = fLoaders.elements();
    while(loaders.hasMoreElements()){
        XMLGrammarLoader gl = (XMLGrammarLoader)loaders.nextElement();
        try {
            gl.setProperty(propId, value);
        } catch(Exception e) {
            // eat it up...
        }
    }
}
 
Example #30
Source File: XMLGrammarPreparser.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void setProperty(String propId, Object value) {
    for (Map.Entry<String, XMLGrammarLoader> entry : fLoaders.entrySet()) {
        try {
            XMLGrammarLoader gl = entry.getValue();
            gl.setProperty(propId, value);
        } catch(Exception e) {
            // eat it up...
        }
    }
}