Class XMLGrammarPreparser


  • public class XMLGrammarPreparser
    extends Object

    This class provides an easy way for a user to preparse grammars of various types. By default, it knows how to preparse external DTD's and schemas; it provides an easy way for user applications to register classes that know how to parse additional grammar types. By default, it does no grammar caching; but it provides ways for user applications to do so.

    Version:
    $Id$
    Author:
    Neil Graham, IBM
    • Constructor Detail

      • XMLGrammarPreparser

        public XMLGrammarPreparser()
        Default constructor.
      • XMLGrammarPreparser

        public XMLGrammarPreparser​(SymbolTable symbolTable)
        Constructs a preparser using the specified symbol table.
        Parameters:
        symbolTable - The symbol table to use.
    • Method Detail

      • preparseGrammar

        public Grammar preparseGrammar​(String type,
                                       XMLInputSource is)
                                throws XNIException,
                                       IOException
        Parse a grammar from a location identified by an XMLInputSource. This method also adds this grammar to the XMLGrammarPool
        Parameters:
        type - The type of the grammar to be constructed
        is - The XMLInputSource containing this grammar's information If a URI is included in the systemId field, the parser will not expand this URI or make it available to the EntityResolver
        Returns:
        The newly created Grammar.
        Throws:
        XNIException - thrown on an error in grammar construction
        IOException - thrown if an error is encountered in reading the file
      • setLocale

        public void setLocale​(Locale locale)
        Set the locale to use for messages.
        Parameters:
        locale - The locale object to use for localization of messages.
        Throws:
        XNIException - Thrown if the parser does not support the specified locale.
      • getLocale

        public Locale getLocale()
        Return the Locale the XMLGrammarLoader is using.
      • setErrorHandler

        public void setErrorHandler​(XMLErrorHandler errorHandler)
        Sets the error handler.
        Parameters:
        errorHandler - The error handler.
      • getErrorHandler

        public XMLErrorHandler getErrorHandler()
        Returns the registered error handler.
      • setEntityResolver

        public void setEntityResolver​(XMLEntityResolver entityResolver)
        Sets the entity resolver.
        Parameters:
        entityResolver - The new entity resolver.
      • getEntityResolver

        public XMLEntityResolver getEntityResolver()
        Returns the registered entity resolver.
      • setGrammarPool

        public void setGrammarPool​(XMLGrammarPool grammarPool)
        Sets the grammar pool.
        Parameters:
        grammarPool - The new grammar pool.
      • getGrammarPool

        public XMLGrammarPool getGrammarPool()
        Returns the registered grammar pool.
      • setFeature

        public void setFeature​(String featureId,
                               boolean value)
      • setProperty

        public void setProperty​(String propId,
                                Object value)
      • getFeature

        public boolean getFeature​(String type,
                                  String featureId)