org.apache.xerces.impl.validation
Class XMLGrammarPoolImpl

java.lang.Object
  |
  +--org.apache.xerces.impl.validation.XMLGrammarPoolImpl
All Implemented Interfaces:
org.apache.xerces.xni.grammars.XMLGrammarPool
Direct Known Subclasses:
CachingParserPool.ShadowedGrammarPool

public class XMLGrammarPoolImpl
extends java.lang.Object
implements org.apache.xerces.xni.grammars.XMLGrammarPool

Stores grammars in a pool associated to a specific key. This grammar pool implementation stores two types of grammars: those keyed by the root element name, and those keyed by the grammar's target namespace. This is for now, a very simple default implementation of the GrammarPool interface. As we move forward, this will become more function-rich and robust.

Version:
$Id: XMLGrammarPoolImpl.java,v 1.2 2002/01/28 19:33:35 lehors Exp $
Author:
Jeffrey Rodriguez, IBM, Andy Clark, IBM, Neil Graham, IBM

Field Summary
protected  java.util.Hashtable fGrammars
          Grammars associated with element root name.
protected  java.util.Hashtable fGrammarsNS
          Grammars associated with namespaces.
protected  org.apache.xerces.xni.grammars.Grammar fNoNSGrammar
           
 
Constructor Summary
XMLGrammarPoolImpl()
          Default constructor.
 
Method Summary
 void cacheGrammars(java.lang.String grammarType, org.apache.xerces.xni.grammars.Grammar[] grammars)
           
 boolean containsGrammar(java.lang.String rootElement)
          Returns true if the grammar pool contains a grammar associated to the specified root element name.
 boolean containsGrammarNS(java.lang.String namespace)
          Returns true if the grammar pool contains a grammar associated to the specified target namespace.
 org.apache.xerces.xni.grammars.Grammar getGrammar(java.lang.String rootElement)
          Returns the grammar associated to the specified root element name.
 org.apache.xerces.xni.grammars.Grammar getGrammarNS(java.lang.String namespace)
          Returns the grammar associated to the specified target namespace.
 org.apache.xerces.xni.grammars.Grammar[] getGrammars()
           
 org.apache.xerces.xni.grammars.Grammar[] getGrammarsNS()
          Returns all grammars associated with namespaces.
 void putGrammar(java.lang.String rootElement, org.apache.xerces.xni.grammars.Grammar grammar)
          Puts the specified grammar into the grammar pool and associate it to a root element name.
 void putGrammarNS(java.lang.String namespace, org.apache.xerces.xni.grammars.Grammar grammar)
          Puts the specified grammar into the grammar pool and associate it to a target namespace.
 org.apache.xerces.xni.grammars.Grammar removeGrammar(java.lang.String rootElement)
          Removes the grammar associated to the specified root elememt name from the grammar pool and returns the removed grammar.
 org.apache.xerces.xni.grammars.Grammar removeGrammarNS(java.lang.String namespace)
          Removes the grammar associated to the specified namespace from the grammar pool and returns the removed grammar.
 org.apache.xerces.xni.grammars.Grammar retrieveGrammar(org.apache.xerces.xni.grammars.XMLGrammarDescription desc)
           
 org.apache.xerces.xni.grammars.Grammar[] retrieveInitialGrammarSet(java.lang.String grammarType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fGrammars

protected java.util.Hashtable fGrammars
Grammars associated with element root name.

fGrammarsNS

protected java.util.Hashtable fGrammarsNS
Grammars associated with namespaces.

fNoNSGrammar

protected org.apache.xerces.xni.grammars.Grammar fNoNSGrammar
Constructor Detail

XMLGrammarPoolImpl

public XMLGrammarPoolImpl()
Default constructor.
Method Detail

retrieveInitialGrammarSet

public org.apache.xerces.xni.grammars.Grammar[] retrieveInitialGrammarSet(java.lang.String grammarType)
Specified by:
retrieveInitialGrammarSet in interface org.apache.xerces.xni.grammars.XMLGrammarPool

cacheGrammars

public void cacheGrammars(java.lang.String grammarType,
                          org.apache.xerces.xni.grammars.Grammar[] grammars)
Specified by:
cacheGrammars in interface org.apache.xerces.xni.grammars.XMLGrammarPool

retrieveGrammar

public org.apache.xerces.xni.grammars.Grammar retrieveGrammar(org.apache.xerces.xni.grammars.XMLGrammarDescription desc)
Specified by:
retrieveGrammar in interface org.apache.xerces.xni.grammars.XMLGrammarPool

putGrammar

public void putGrammar(java.lang.String rootElement,
                       org.apache.xerces.xni.grammars.Grammar grammar)
Puts the specified grammar into the grammar pool and associate it to a root element name.
Parameters:
rootElement - Root element name.
grammar - The grammar.

putGrammarNS

public void putGrammarNS(java.lang.String namespace,
                         org.apache.xerces.xni.grammars.Grammar grammar)
Puts the specified grammar into the grammar pool and associate it to a target namespace.
Parameters:
namespace - The grammar namespace.
grammar - The grammar.

getGrammar

public org.apache.xerces.xni.grammars.Grammar getGrammar(java.lang.String rootElement)
Returns the grammar associated to the specified root element name.
Parameters:
rootElement - Root element name.

getGrammarNS

public org.apache.xerces.xni.grammars.Grammar getGrammarNS(java.lang.String namespace)
Returns the grammar associated to the specified target namespace.
Parameters:
namespace - Target namespace.

removeGrammar

public org.apache.xerces.xni.grammars.Grammar removeGrammar(java.lang.String rootElement)
Removes the grammar associated to the specified root elememt name from the grammar pool and returns the removed grammar.
Parameters:
rootElement - Root element name.

removeGrammarNS

public org.apache.xerces.xni.grammars.Grammar removeGrammarNS(java.lang.String namespace)
Removes the grammar associated to the specified namespace from the grammar pool and returns the removed grammar.
Parameters:
namespace - Target namespace.

containsGrammar

public boolean containsGrammar(java.lang.String rootElement)
Returns true if the grammar pool contains a grammar associated to the specified root element name.
Parameters:
rootElement - Root element name.

containsGrammarNS

public boolean containsGrammarNS(java.lang.String namespace)
Returns true if the grammar pool contains a grammar associated to the specified target namespace.
Parameters:
namespace - Target namespace.

getGrammars

public org.apache.xerces.xni.grammars.Grammar[] getGrammars()

getGrammarsNS

public org.apache.xerces.xni.grammars.Grammar[] getGrammarsNS()
Returns all grammars associated with namespaces.


Copyright © 1999-2001 Apache XML Project. All Rights Reserved.