org.apache.xerces.parsers

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: XMLGrammarPreparser.java,v 1.10 2004/03/25 04:03:23 mrglavas Exp $

Author: Neil Graham, IBM

Field Summary
protected static StringENTITY_RESOLVER
Property identifier: entity resolver.
protected static StringERROR_HANDLER
Property identifier: error handler.
protected static StringERROR_REPORTER
Property identifier: error reporter.
protected XMLEntityResolverfEntityResolver
protected XMLErrorReporterfErrorReporter
protected XMLGrammarPoolfGrammarPool
protected LocalefLocale
protected SymbolTablefSymbolTable
protected static StringGRAMMAR_POOL
Property identifier: grammar pool .
protected static StringSYMBOL_TABLE
Property identifier: symbol table.
Constructor Summary
XMLGrammarPreparser()
Default constructor.
XMLGrammarPreparser(SymbolTable symbolTable)
Constructs a preparser using the specified symbol table.
Method Summary
XMLEntityResolvergetEntityResolver()
Returns the registered entity resolver.
XMLErrorHandlergetErrorHandler()
Returns the registered error handler.
booleangetFeature(String type, String featureId)
XMLGrammarPoolgetGrammarPool()
Returns the registered grammar pool.
XMLGrammarLoadergetLoader(String type)
LocalegetLocale()
Return the Locale the XMLGrammarLoader is using.
ObjectgetProperty(String type, String propertyId)
GrammarpreparseGrammar(String type, XMLInputSource is)
Parse a grammar from a location identified by an XMLInputSource.
booleanregisterPreparser(String grammarType, XMLGrammarLoader loader)
voidsetEntityResolver(XMLEntityResolver entityResolver)
Sets the entity resolver.
voidsetErrorHandler(XMLErrorHandler errorHandler)
Sets the error handler.
voidsetFeature(String featureId, boolean value)
voidsetGrammarPool(XMLGrammarPool grammarPool)
Sets the grammar pool.
voidsetLocale(Locale locale)
Set the locale to use for messages.
voidsetProperty(String propId, Object value)

Field Detail

ENTITY_RESOLVER

protected static final String ENTITY_RESOLVER
Property identifier: entity resolver.

ERROR_HANDLER

protected static final String ERROR_HANDLER
Property identifier: error handler.

ERROR_REPORTER

protected static final String ERROR_REPORTER
Property identifier: error reporter.

fEntityResolver

protected XMLEntityResolver fEntityResolver

fErrorReporter

protected XMLErrorReporter fErrorReporter

fGrammarPool

protected XMLGrammarPool fGrammarPool

fLocale

protected Locale fLocale

fSymbolTable

protected SymbolTable fSymbolTable

GRAMMAR_POOL

protected static final String GRAMMAR_POOL
Property identifier: grammar pool .

SYMBOL_TABLE

protected static final String SYMBOL_TABLE
Property identifier: symbol table.

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

getEntityResolver

public XMLEntityResolver getEntityResolver()
Returns the registered entity resolver.

getErrorHandler

public XMLErrorHandler getErrorHandler()
Returns the registered error handler.

getFeature

public boolean getFeature(String type, String featureId)

getGrammarPool

public XMLGrammarPool getGrammarPool()
Returns the registered grammar pool.

getLoader

public XMLGrammarLoader getLoader(String type)

getLocale

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

getProperty

public Object getProperty(String type, String propertyId)

preparseGrammar

public Grammar preparseGrammar(String type, XMLInputSource is)
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

registerPreparser

public boolean registerPreparser(String grammarType, XMLGrammarLoader loader)

setEntityResolver

public void setEntityResolver(XMLEntityResolver entityResolver)
Sets the entity resolver.

Parameters: entityResolver The new entity resolver.

setErrorHandler

public void setErrorHandler(XMLErrorHandler errorHandler)
Sets the error handler.

Parameters: errorHandler The error handler.

setFeature

public void setFeature(String featureId, boolean value)

setGrammarPool

public void setGrammarPool(XMLGrammarPool grammarPool)
Sets the grammar pool.

Parameters: grammarPool The new grammar pool.

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.

setProperty

public void setProperty(String propId, Object value)
Copyright B) 1999-2005 Apache XML Project. All Rights Reserved.