org.exist.validation
Class GrammarPool

java.lang.Object
  extended by org.exist.validation.GrammarPool
All Implemented Interfaces:
XMLGrammarPool

public class GrammarPool
extends Object
implements XMLGrammarPool

Wrapper around the Xerces XMLGrammarPoolImpl, so debugging of actions can be monitored. Javadoc copied from xml.apache.org.

Author:
Dannes Wessels (dizzzz@exist-db.org)
See Also:
XMLGrammarPool, XMLGrammarPoolImpl, Grammar, XMLGrammarDescription

Constructor Summary
GrammarPool()
          Constructs a grammar pool with a default number of buckets.
GrammarPool(XMLGrammarPool pool)
          Constructs a grammar pool with a default number of buckets.
 
Method Summary
 void cacheGrammars(String type, Grammar[] grammar)
          Return the final set of grammars that the validator ended up with.
 void clear()
          Removes all grammars from the pool.
 void clearDTDs()
          Removes all DTD grammars from the pool.
 void lockPool()
          Causes the XMLGrammarPool not to store any grammars when the cacheGrammars(String, Grammar[[]) method is called.
 Grammar retrieveGrammar(XMLGrammarDescription xgd)
          This method requests that the application retrieve a grammar corresponding to the given GrammarIdentifier from its cache.
 Grammar[] retrieveInitialGrammarSet(String type)
          Retrieve the initial known set of grammars.
 void unlockPool()
          Allows the XMLGrammarPool to store grammars when its cacheGrammars(String, Grammar[]) method is called.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrammarPool

public GrammarPool()
Constructs a grammar pool with a default number of buckets.


GrammarPool

public GrammarPool(XMLGrammarPool pool)
Constructs a grammar pool with a default number of buckets. The supplied grammar pool is reused

Method Detail

retrieveInitialGrammarSet

public Grammar[] retrieveInitialGrammarSet(String type)
Retrieve the initial known set of grammars. this method is called by a validator before the validation starts. the application can provide an initial set of grammars available to the current validation attempt.

Specified by:
retrieveInitialGrammarSet in interface XMLGrammarPool
Parameters:
type - The type of the grammar, from the org.apache.xerces.xni.grammars.Grammar interface.
Returns:
The set of grammars the validator may put in its "bucket"
See Also:
XMLGrammarPool.retrieveInitialGrammarSet(String)

cacheGrammars

public void cacheGrammars(String type,
                          Grammar[] grammar)
Return the final set of grammars that the validator ended up with.

Specified by:
cacheGrammars in interface XMLGrammarPool
Parameters:
type - The type of the grammars being returned
grammar - an array containing the set of grammars being returned; order is not significant.
See Also:
XMLGrammarPool.cacheGrammars(String,Grammar[])

unlockPool

public void unlockPool()
Allows the XMLGrammarPool to store grammars when its cacheGrammars(String, Grammar[]) method is called. This is the default state of the object.

Specified by:
unlockPool in interface XMLGrammarPool
See Also:
XMLGrammarPool.unlockPool()

retrieveGrammar

public Grammar retrieveGrammar(XMLGrammarDescription xgd)
This method requests that the application retrieve a grammar corresponding to the given GrammarIdentifier from its cache. If it cannot do so it must return null; the parser will then call the EntityResolver. An application must not call its EntityResolver itself from this method; this may result in infinite recursions.

Specified by:
retrieveGrammar in interface XMLGrammarPool
Parameters:
xgd - The description of the Grammar being requested.
Returns:
the Grammar corresponding to this description or null if no such Grammar is known.
See Also:
XMLGrammarPool.retrieveGrammar(XMLGrammarDescription)

lockPool

public void lockPool()
Causes the XMLGrammarPool not to store any grammars when the cacheGrammars(String, Grammar[[]) method is called.

Specified by:
lockPool in interface XMLGrammarPool
See Also:
XMLGrammarPool.lockPool()

clear

public void clear()
Removes all grammars from the pool.

Specified by:
clear in interface XMLGrammarPool
See Also:
XMLGrammarPool.clear()

clearDTDs

public void clearDTDs()
Removes all DTD grammars from the pool. Workaround for Xerces bug.

See Also:
XMLGrammarPool.clear()


Copyright (C) Wolfgang Meier. All rights reserved.