Top Description Inners Fields Constructors Methods
com.sun.org.apache.xerces.internal.util

public Class XMLGrammarPoolImpl

extends Object
implements XMLGrammarPool
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool
Known Direct Subclasses
com.sun.org.apache.xerces.internal.impl.xs.util.XSGrammarPool, com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.XMLGrammarPoolImplExtension, com.sun.org.apache.xerces.internal.parsers.CachingParserPool.ShadowedGrammarPool
Imports
com.sun.org.apache.xerces.internal.xni.grammars.Grammar, .XMLGrammarDescription, .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.
Authors
Jeffrey Rodriguez, IBM, Andy Clark, IBM, Neil Graham, IBM, Pavani Mukthipudi, Sun Microsystems, Neeraj Bajaj, SUN Microsystems

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
XMLGrammarPoolImpl.Entry

This class is a grammar pool entry.

Field Summary

Modifier and TypeField and Description
private static final boolean
protected int
protected XMLGrammarPoolImpl.Entry[]
fGrammars

Grammars.

protected boolean
protected static final int
TABLE_SIZE

Default size.

Constructor Summary

AccessConstructor and Description
public
XMLGrammarPoolImpl()

Constructs a grammar pool with a default number of buckets.

public
XMLGrammarPoolImpl(int initialCapacity)

Constructs a grammar pool with a specified number of buckets.

Method Summary

Modifier and TypeMethod and Description
public void
cacheGrammars(String
the type of the grammars being returned;
grammarType
,
Grammar[]
an array containing the set of grammars being returned; order is not significant.
grammars
)

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.cacheGrammars.

return the final set of grammars that the validator ended up with.

public void
clear()

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.clear.

Removes all grammars from the pool.
public boolean
containsGrammar(XMLGrammarDescription
The Grammar Description.
desc
)

Returns true if the grammar pool contains a grammar associated to the specified grammar description.

public boolean

Returns:

True if the grammars are equal, otherwise false
equals
(XMLGrammarDescription
The grammar description
desc1
,
XMLGrammarDescription
The grammar description of the grammar to be compared to
desc2
)

This method checks whether two grammars are the same.

public Grammar
getGrammar(XMLGrammarDescription
The Grammar Description.
desc
)

Returns the grammar associated to the specified grammar description.

public int

Returns:

The hash code value
hashCode
(XMLGrammarDescription
The grammar description
desc
)

Returns the hash code value for the given grammar description.

public void
lockPool()

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.lockPool.

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

Puts the specified grammar into the grammar pool and associates it to its root element name or its target namespace.

public Grammar

Returns:

The removed grammar.
removeGrammar
(XMLGrammarDescription
The Grammar Description.
desc
)

Removes the grammar associated to the specified grammar description from the grammar pool and returns the removed grammar.

public Grammar
retrieveGrammar(XMLGrammarDescription
The description of the Grammar being requested.
desc
)

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.retrieveGrammar.

This method requests that the application retrieve a grammar corresponding to the given GrammarIdentifier from its cache.

public Grammar[]
retrieveInitialGrammarSet(String
the type of the grammar, from the com.sun.org.apache.xerces.internal.xni.grammars.Grammar interface.
grammarType
)

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.retrieveInitialGrammarSet.

retrieve the initial known set of grammars.

public void
unlockPool()

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.unlockPool.

Allows the XMLGrammarPool to store grammars when its cacheGrammars(String, Grammar[]) method is called.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
private static final boolean DEBUG
fGrammarCountback to summary
protected int fGrammarCount
fGrammarsback to summary
protected XMLGrammarPoolImpl.Entry[] fGrammars

Grammars.

fPoolIsLockedback to summary
protected boolean fPoolIsLocked
TABLE_SIZEback to summary
protected static final int TABLE_SIZE

Default size.

Constructor Detail

XMLGrammarPoolImplback to summary
public XMLGrammarPoolImpl()

Constructs a grammar pool with a default number of buckets.

XMLGrammarPoolImplback to summary
public XMLGrammarPoolImpl(int initialCapacity)

Constructs a grammar pool with a specified number of buckets.

Method Detail

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

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.cacheGrammars.

Doc from com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.cacheGrammars.

return the final set of grammars that the validator ended up with. This method is called after the validation finishes. The application may then choose to cache some of the returned grammars.

Parameters
grammarType:String

the type of the grammars being returned;

grammars:Grammar[]

an array containing the set of grammars being returned; order is not significant.

clearback to summary
public void clear()

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.clear.

Doc from com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.clear.

Removes all grammars from the pool.

containsGrammarback to summary
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:XMLGrammarDescription

The Grammar Description.

equalsback to summary
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:XMLGrammarDescription

The grammar description

desc2:XMLGrammarDescription

The grammar description of the grammar to be compared to

Returns:boolean

True if the grammars are equal, otherwise false

getGrammarback to summary
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:XMLGrammarDescription

The Grammar Description.

hashCodeback to summary
public int hashCode(XMLGrammarDescription desc)

Returns the hash code value for the given grammar description.

Parameters
desc:XMLGrammarDescription

The grammar description

Returns:int

The hash code value

lockPoolback to summary
public void lockPool()

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.lockPool.

Doc from com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.lockPool.

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

putGrammarback to summary
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:Grammar

The Grammar.

removeGrammarback to summary
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:XMLGrammarDescription

The Grammar Description.

Returns:Grammar

The removed grammar.

retrieveGrammarback to summary
public Grammar retrieveGrammar(XMLGrammarDescription desc)

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.retrieveGrammar.

Doc from com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.retrieveGrammar.

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.

Parameters
desc:XMLGrammarDescription

The description of the Grammar being requested.

Returns:Grammar

the Grammar corresponding to this description or null if no such Grammar is known.

retrieveInitialGrammarSetback to summary
public Grammar[] retrieveInitialGrammarSet(String grammarType)

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.retrieveInitialGrammarSet.

Doc from com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.retrieveInitialGrammarSet.

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.

Parameters
grammarType:String

the type of the grammar, from the com.sun.org.apache.xerces.internal.xni.grammars.Grammar interface.

Returns:Grammar[]

the set of grammars the validator may put in its "bucket"

unlockPoolback to summary
public void unlockPool()

Implements com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.unlockPool.

Doc from com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool.unlockPool.

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

com.sun.org.apache.xerces.internal.util back to summary

protected final Class XMLGrammarPoolImpl.Entry

extends Object
Class Inheritance
  • java.lang.Object
  • com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl.Entry

This class is a grammar pool entry. Each entry acts as a node in a linked list.

Field Summary

Modifier and TypeField and Description
public XMLGrammarDescription
public Grammar
public int
public XMLGrammarPoolImpl.Entry

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

descback to summary
public XMLGrammarDescription desc
grammarback to summary
public Grammar grammar
hashback to summary
public int hash
nextback to summary
public XMLGrammarPoolImpl.Entry next

Constructor Detail

Entryback to summary
protected Entry(int hash, XMLGrammarDescription desc, Grammar grammar, XMLGrammarPoolImpl.Entry next)

Method Detail

clearback to summary
protected void clear()