This grammar pool is a memory sensitive cache. The grammars
stored in the pool are softly reachable and may be cleared by
the garbage collector in response to memory demand. Equality
of XMLSchemaDescription
s is determined using both
the target namespace for the schema and schema location.
Modifier and Type | Class and Description |
---|---|
pack-priv static class | SoftReferenceGrammarPool.
This class is a grammar pool entry. |
pack-priv static class | SoftReferenceGrammarPool.
This class stores a soft reference to a grammar object. |
Modifier and Type | Field and Description |
---|---|
protected int | fGrammarCount
The number of grammars in the pool |
protected SoftReferenceGrammarPool. | fGrammars
Grammars. |
protected boolean | fPoolIsLocked
Flag indicating whether this pool is locked |
protected final ReferenceQueue | fReferenceQueue
Reference queue for cleared grammar references |
protected static final int | TABLE_SIZE
Default size. |
protected static final Grammar[] | ZERO_LENGTH_GRAMMAR_ARRAY
Zero length grammar array. |
Access | Constructor and Description |
---|---|
public | |
public | SoftReferenceGrammarPool(int initialCapacity)
Constructs a grammar pool with a specified number of buckets. |
Modifier and Type | Method 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. return the final set of grammars that the validator ended up with. |
private void | |
public void | clear()
Implements com. 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 falseThe 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 valueThe grammar description desc)Returns the hash code value for the given grammar description. |
public void | lockPool()
Implements com. 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. |
private Grammar | Returns: The grammar attached to this entrythe entry to remove entryRemoves the given entry from the pool |
public Grammar | Returns: The removed grammar.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. 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
grammarType)com.sun.org.apache.xerces.internal.xni.grammars.Grammar interface.Implements com. retrieve the initial known set of grammars. |
public void | unlockPool()
Implements com. Allows the XMLGrammarPool to store grammars when its cacheGrammars(String, Grammar[]) method is called. |
fGrammarCount | back to summary |
---|---|
protected int fGrammarCount The number of grammars in the pool |
fGrammars | back to summary |
---|---|
protected SoftReferenceGrammarPool. Grammars. |
fPoolIsLocked | back to summary |
---|---|
protected boolean fPoolIsLocked Flag indicating whether this pool is locked |
fReferenceQueue | back to summary |
---|---|
protected final ReferenceQueue<Grammar> fReferenceQueue Reference queue for cleared grammar references |
TABLE_SIZE | back to summary |
---|---|
protected static final int TABLE_SIZE Default size. |
ZERO_LENGTH_GRAMMAR_ARRAY | back to summary |
---|---|
protected static final Grammar[] ZERO_LENGTH_GRAMMAR_ARRAY Zero length grammar array. |
SoftReferenceGrammarPool | back to summary |
---|---|
public SoftReferenceGrammarPool() Constructs a grammar pool with a default number of buckets. |
SoftReferenceGrammarPool | back to summary |
---|---|
public SoftReferenceGrammarPool(int initialCapacity) Constructs a grammar pool with a specified number of buckets. |
cacheGrammars | back to summary |
---|---|
public void cacheGrammars(String grammarType, Grammar[] grammars) Implements com. Doc from com. 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. |
clean | back to summary |
---|---|
private void clean() Removes stale entries from the pool. |
clear | back to summary |
---|---|
public void clear() Implements com. Doc from com. Removes all grammars from the pool. |
containsGrammar | back 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.
|
equals | back 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.
|
getGrammar | back 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.
|
hashCode | back to summary |
---|---|
public int hashCode(XMLGrammarDescription desc) Returns the hash code value for the given grammar description.
|
lockPool | back to summary |
---|---|
public void lockPool() Implements com. Doc from com. Causes the XMLGrammarPool not to store any grammars when the cacheGrammars(String, Grammar[[]) method is called. |
putGrammar | back 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.
|
removeEntry | back to summary |
---|---|
private Grammar removeEntry(SoftReferenceGrammarPool. Removes the given entry from the pool
|
removeGrammar | back 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.
|
retrieveGrammar | back to summary |
---|---|
public Grammar retrieveGrammar(XMLGrammarDescription desc) Implements com. Doc from com. 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.
|
retrieveInitialGrammarSet | back to summary |
---|---|
public Grammar[] retrieveInitialGrammarSet(String grammarType) Implements com. Doc from com. 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. |
unlockPool | back to summary |
---|---|
public void unlockPool() Implements com. Doc from com. Allows the XMLGrammarPool to store grammars when its cacheGrammars(String, Grammar[]) method is called. This is the default state of the object. |
Modifier and Type | Field and Description |
---|---|
public int | |
public XMLGrammarDescription | |
public SoftReferenceGrammarPool. | |
public int | |
public SoftReferenceGrammarPool. | |
public SoftReferenceGrammarPool. |
Access | Constructor and Description |
---|---|
protected | Entry(int hash, int bucket, XMLGrammarDescription desc, Grammar grammar, SoftReferenceGrammarPool.
|
Modifier and Type | Method and Description |
---|---|
protected void |
bucket | back to summary |
---|---|
public int bucket |
desc | back to summary |
---|---|
public XMLGrammarDescription desc |
grammar | back to summary |
---|---|
public SoftReferenceGrammarPool. |
hash | back to summary |
---|---|
public int hash |
next | back to summary |
---|---|
public SoftReferenceGrammarPool. |
prev | back to summary |
---|---|
public SoftReferenceGrammarPool. |
Entry | back to summary |
---|---|
protected Entry(int hash, int bucket, XMLGrammarDescription desc, Grammar grammar, SoftReferenceGrammarPool. |
clear | back to summary |
---|---|
protected void clear() |
Modifier and Type | Field and Description |
---|---|
public SoftReferenceGrammarPool. |
Access | Constructor and Description |
---|---|
protected | SoftGrammarReference(SoftReferenceGrammarPool.
|
entry | back to summary |
---|---|
public SoftReferenceGrammarPool. |
SoftGrammarReference | back to summary |
---|---|
protected SoftGrammarReference(SoftReferenceGrammarPool. |