Top Description Inners Fields Constructors Methods
org.apache.xerces.parsers

public Class XMLGrammarPreparser

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.Enumeration, .Hashtable, .Locale, org.apache.xerces.impl.Constants, .XMLEntityManager, .XMLErrorReporter, org.apache.xerces.util.SymbolTable, org.apache.xerces.xni.XNIException, org.apache.xerces.xni.grammars.Grammar, .XMLGrammarDescription, .XMLGrammarLoader, .XMLGrammarPool, org.apache.xerces.xni.parser.XMLEntityResolver, .XMLErrorHandler, .XMLInputSource

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.

Author
Neil Graham, IBM
Version
$Id: XMLGrammarPreparser.java 713638 2008-11-13 04:42:18Z mrglavas $

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
XMLGrammarPreparser.XMLGrammarLoaderContainer

Container for an XMLGrammarLoader.

Field Summary

Modifier and TypeField and Description
private static final String
protected static final String
ENTITY_RESOLVER

Property identifier: entity resolver.

protected static final String
ERROR_HANDLER

Property identifier: error handler.

protected static final String
ERROR_REPORTER

Property identifier: error reporter.

protected XMLEntityResolver
protected final XMLErrorReporter
protected XMLGrammarPool
private final Hashtable<K, V>
protected Locale
private int
protected final SymbolTable
protected static final String
GRAMMAR_POOL

Property identifier: grammar pool .

private static final Hashtable<K, V>
private static final String[]
RECOGNIZED_PROPERTIES

Recognized properties.

protected static final String
SYMBOL_TABLE

Property identifier: symbol table.

Constructor Summary

AccessConstructor and Description
public
XMLGrammarPreparser()

Default constructor.

public
XMLGrammarPreparser(SymbolTable
The symbol table to use.
symbolTable
)

Constructs a preparser using the specified symbol table.

Method Summary

Modifier and TypeMethod and Description
private void
public XMLEntityResolver
getEntityResolver()

Returns the registered entity resolver.

public XMLErrorHandler
getErrorHandler()

Returns the registered error handler.

public boolean
getFeature(String type, String featureId)

public XMLGrammarPool
getGrammarPool()

Returns the registered grammar pool.

public XMLGrammarLoader
public Locale
getLocale()

Return the Locale the XMLGrammarLoader is using.

public Object
getProperty(String type, String propertyId)

public Grammar

Returns:

The newly created Grammar.
preparseGrammar
(String
The type of the grammar to be constructed
type
,
XMLInputSource
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
is
)

Parse a grammar from a location identified by an XMLInputSource.

public boolean
public void
setEntityResolver(XMLEntityResolver
The new entity resolver.
entityResolver
)

Sets the entity resolver.

public void
setErrorHandler(XMLErrorHandler
The error handler.
errorHandler
)

Sets the error handler.

public void
setFeature(String featureId, boolean value)

public void
setGrammarPool(XMLGrammarPool
The new grammar pool.
grammarPool
)

Sets the grammar pool.

public void
setLocale(Locale
The locale object to use for localization of messages.
locale
)

Set the locale to use for messages.

public void
setProperty(String propId, Object value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONTINUE_AFTER_FATAL_ERRORback to summary
private static final String CONTINUE_AFTER_FATAL_ERROR
ENTITY_RESOLVERback to summary
protected static final String ENTITY_RESOLVER

Property identifier: entity resolver.

ERROR_HANDLERback to summary
protected static final String ERROR_HANDLER

Property identifier: error handler.

ERROR_REPORTERback to summary
protected static final String ERROR_REPORTER

Property identifier: error reporter.

fEntityResolverback to summary
protected XMLEntityResolver fEntityResolver
fErrorReporterback to summary
protected final XMLErrorReporter fErrorReporter
fGrammarPoolback to summary
protected XMLGrammarPool fGrammarPool
fLoadersback to summary
private final Hashtable<K, V> fLoaders
fLocaleback to summary
protected Locale fLocale
fModCountback to summary
private int fModCount
fSymbolTableback to summary
protected final SymbolTable fSymbolTable
GRAMMAR_POOLback to summary
protected static final String GRAMMAR_POOL

Property identifier: grammar pool .

KNOWN_LOADERSback to summary
private static final Hashtable<K, V> KNOWN_LOADERS
RECOGNIZED_PROPERTIESback to summary
private static final String[] RECOGNIZED_PROPERTIES

Recognized properties.

SYMBOL_TABLEback to summary
protected static final String SYMBOL_TABLE

Property identifier: symbol table.

Constructor Detail

XMLGrammarPreparserback to summary
public XMLGrammarPreparser()

Default constructor.

XMLGrammarPreparserback to summary
public XMLGrammarPreparser(SymbolTable symbolTable)

Constructs a preparser using the specified symbol table.

Parameters
symbolTable:SymbolTable

The symbol table to use.

Method Detail

clearModCountsback to summary
private void clearModCounts()
getEntityResolverback to summary
public XMLEntityResolver getEntityResolver()

Returns the registered entity resolver.

getErrorHandlerback to summary
public XMLErrorHandler getErrorHandler()

Returns the registered error handler.

getFeatureback to summary
public boolean getFeature(String type, String featureId)
getGrammarPoolback to summary
public XMLGrammarPool getGrammarPool()

Returns the registered grammar pool.

getLoaderback to summary
public XMLGrammarLoader getLoader(String type)
getLocaleback to summary
public Locale getLocale()

Return the Locale the XMLGrammarLoader is using.

getPropertyback to summary
public Object getProperty(String type, String propertyId)
preparseGrammarback to summary
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:String

The type of the grammar to be constructed

is:XMLInputSource

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:Grammar

The newly created Grammar.

Exceptions
XNIException:
thrown on an error in grammar construction
IOException:
thrown if an error is encountered in reading the file
registerPreparserback to summary
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader)
setEntityResolverback to summary
public void setEntityResolver(XMLEntityResolver entityResolver)

Sets the entity resolver.

Parameters
entityResolver:XMLEntityResolver

The new entity resolver.

setErrorHandlerback to summary
public void setErrorHandler(XMLErrorHandler errorHandler)

Sets the error handler.

Parameters
errorHandler:XMLErrorHandler

The error handler.

setFeatureback to summary
public void setFeature(String featureId, boolean value)
setGrammarPoolback to summary
public void setGrammarPool(XMLGrammarPool grammarPool)

Sets the grammar pool.

Parameters
grammarPool:XMLGrammarPool

The new grammar pool.

setLocaleback to summary
public void setLocale(Locale locale)

Set the locale to use for messages.

Parameters
locale:Locale

The locale object to use for localization of messages.

Exceptions
XNIException:
Thrown if the parser does not support the specified locale.
setPropertyback to summary
public void setProperty(String propId, Object value)
org.apache.xerces.parsers back to summary

pack-priv Class XMLGrammarPreparser.XMLGrammarLoaderContainer

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.xerces.parsers.XMLGrammarPreparser.XMLGrammarLoaderContainer

Container for an XMLGrammarLoader. Also holds the modCount that the XMLGrammarPreparser had the last time it was used.

Field Summary

Modifier and TypeField and Description
public final XMLGrammarLoader
public int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loaderback to summary
public final XMLGrammarLoader loader
modCountback to summary
public int modCount

Constructor Detail

XMLGrammarLoaderContainerback to summary
public XMLGrammarLoaderContainer(XMLGrammarLoader loader)