org.apache.xerces.util

Class XMLGrammarPoolImpl

public class XMLGrammarPoolImpl extends Object implements 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 the default implementation of the GrammarPool interface. As we move forward, this will become more function-rich and robust.

Version: $Id: XMLGrammarPoolImpl.java,v 1.8 2004/03/25 04:03:22 mrglavas Exp $

Author: Jeffrey Rodriguez, IBM Andy Clark, IBM Neil Graham, IBM Pavani Mukthipudi, Sun Microsystems Neeraj Bajaj, SUN Microsystems

Nested Class Summary
protected static classXMLGrammarPoolImpl.Entry
This class is a grammar pool entry.
Field Summary
protected intfGrammarCount
protected XMLGrammarPoolImpl.Entry[]fGrammars
Grammars.
protected booleanfPoolIsLocked
protected static intTABLE_SIZE
Default size.
Constructor Summary
XMLGrammarPoolImpl()
Constructs a grammar pool with a default number of buckets.
XMLGrammarPoolImpl(int initialCapacity)
Constructs a grammar pool with a specified number of buckets.
Method Summary
voidcacheGrammars(String grammarType, Grammar[] grammars)
voidclear()
booleancontainsGrammar(XMLGrammarDescription desc)
Returns true if the grammar pool contains a grammar associated to the specified grammar description.
booleanequals(XMLGrammarDescription desc1, XMLGrammarDescription desc2)
This method checks whether two grammars are the same.
GrammargetGrammar(XMLGrammarDescription desc)
Returns the grammar associated to the specified grammar description.
inthashCode(XMLGrammarDescription desc)
Returns the hash code value for the given grammar description.
voidlockPool()
voidputGrammar(Grammar grammar)
Puts the specified grammar into the grammar pool and associates it to its root element name or its target namespace.
GrammarremoveGrammar(XMLGrammarDescription desc)
Removes the grammar associated to the specified grammar description from the grammar pool and returns the removed grammar.
GrammarretrieveGrammar(XMLGrammarDescription desc)
Grammar[]retrieveInitialGrammarSet(String grammarType)
voidunlockPool()

Field Detail

fGrammarCount

protected int fGrammarCount

fGrammars

protected XMLGrammarPoolImpl.Entry[] fGrammars
Grammars.

fPoolIsLocked

protected boolean fPoolIsLocked

TABLE_SIZE

protected static final int TABLE_SIZE
Default size.

Constructor Detail

XMLGrammarPoolImpl

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

XMLGrammarPoolImpl

public XMLGrammarPoolImpl(int initialCapacity)
Constructs a grammar pool with a specified number of buckets.

Method Detail

cacheGrammars

public void cacheGrammars(String grammarType, Grammar[] grammars)

clear

public void clear()

containsGrammar

public boolean containsGrammar(XMLGrammarDescription desc)
Returns true if the grammar pool contains a grammar associated to the specified grammar description. Currently, the root element name is used as the key for DTD grammars and the target namespace is used as the key for Schema grammars.

Parameters: desc The Grammar Description.

equals

public boolean equals(XMLGrammarDescription desc1, XMLGrammarDescription desc2)
This method checks whether two grammars are the same. Currently, we compare the root element names for DTD grammars and the target namespaces for Schema grammars. The application can override this behaviour and add its own logic.

Parameters: desc1 The grammar description desc2 The grammar description of the grammar to be compared to

Returns: True if the grammars are equal, otherwise false

getGrammar

public Grammar getGrammar(XMLGrammarDescription desc)
Returns the grammar associated to the specified grammar description. Currently, the root element name is used as the key for DTD grammars and the target namespace is used as the key for Schema grammars.

Parameters: desc The Grammar Description.

hashCode

public int hashCode(XMLGrammarDescription desc)
Returns the hash code value for the given grammar description.

Parameters: desc The grammar description

Returns: The hash code value

lockPool

public void lockPool()

putGrammar

public void putGrammar(Grammar grammar)
Puts the specified grammar into the grammar pool and associates it to its root element name or its target namespace.

Parameters: grammar The Grammar.

removeGrammar

public Grammar removeGrammar(XMLGrammarDescription desc)
Removes the grammar associated to the specified grammar description from the grammar pool and returns the removed grammar. Currently, the root element name is used as the key for DTD grammars and the target namespace is used as the key for Schema grammars.

Parameters: desc The Grammar Description.

Returns: The removed grammar.

retrieveGrammar

public Grammar retrieveGrammar(XMLGrammarDescription desc)

retrieveInitialGrammarSet

public Grammar[] retrieveInitialGrammarSet(String grammarType)

unlockPool

public void unlockPool()
Copyright © 1999-2005 Apache XML Project. All Rights Reserved.