Class LSPXMLGrammarPool

  • All Implemented Interfaces:
    org.apache.xerces.xni.grammars.XMLGrammarPool
    Direct Known Subclasses:
    LSPXMLGrammarPoolWrapper

    public class LSPXMLGrammarPool
    extends Object
    implements org.apache.xerces.xni.grammars.XMLGrammarPool
    LSP XML grammar pool.

    This class is a copy/paste of org.apache.xerces.util.XMLGrammarPoolImpl.XMLGrammarPoolImpl from Xerces adapated to use .lemminx cache.

    Author:
    Jeffrey Rodriguez, IBM, Andy Clark, IBM, Neil Graham, IBM, Pavani Mukthipudi, Sun Microsystems, Neeraj Bajaj, SUN Microsystems, Angelo ZERR
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  LSPXMLGrammarPool.Entry
      This class is a grammar pool entry.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cacheGrammars​(String grammarType, org.apache.xerces.xni.grammars.Grammar[] grammars)  
      void clear()  
      boolean equals​(org.apache.xerces.xni.grammars.XMLGrammarDescription desc1, org.apache.xerces.xni.grammars.XMLGrammarDescription desc2)
      This method checks whether two grammars are the same.
      int hashCode​(org.apache.xerces.xni.grammars.XMLGrammarDescription desc)
      Returns the hash code value for the given grammar description.
      void lockPool()  
      void removeGrammar​(String grammarURI)  
      org.apache.xerces.xni.grammars.Grammar removeGrammar​(org.apache.xerces.xni.grammars.XMLGrammarDescription desc)
      Removes the grammar associated to the specified grammar description 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​(String grammarType)  
      boolean setInternalSubset​(org.apache.xerces.impl.dtd.XMLDTDDescription desc, String internalSubset)
      Update the DTD internal subset entry for the given XML DTD description and return true if the cached DTD grammar internal subset is equal to the given internal subset and false otherwise.
      void unlockPool()  
    • Constructor Detail

      • LSPXMLGrammarPool

        public LSPXMLGrammarPool()
      • LSPXMLGrammarPool

        public LSPXMLGrammarPool​(int initialCapacity)
    • Method Detail

      • retrieveInitialGrammarSet

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

        public void cacheGrammars​(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
      • removeGrammar

        public org.apache.xerces.xni.grammars.Grammar removeGrammar​(org.apache.xerces.xni.grammars.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.
      • removeGrammar

        public void removeGrammar​(String grammarURI)
      • lockPool

        public void lockPool()
        Specified by:
        lockPool in interface org.apache.xerces.xni.grammars.XMLGrammarPool
      • unlockPool

        public void unlockPool()
        Specified by:
        unlockPool in interface org.apache.xerces.xni.grammars.XMLGrammarPool
      • clear

        public void clear()
        Specified by:
        clear in interface org.apache.xerces.xni.grammars.XMLGrammarPool
      • equals

        public boolean equals​(org.apache.xerces.xni.grammars.XMLGrammarDescription desc1,
                              org.apache.xerces.xni.grammars.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
      • hashCode

        public int hashCode​(org.apache.xerces.xni.grammars.XMLGrammarDescription desc)
        Returns the hash code value for the given grammar description.
        Parameters:
        desc - The grammar description
        Returns:
        The hash code value
      • setInternalSubset

        public boolean setInternalSubset​(org.apache.xerces.impl.dtd.XMLDTDDescription desc,
                                         String internalSubset)
        Update the DTD internal subset entry for the given XML DTD description and return true if the cached DTD grammar internal subset is equal to the given internal subset and false otherwise.
        Parameters:
        desc - the XML DTD description.
        internalSubset - the internal subset.
        Returns:
        true if the cached DTD grammar internal subset is equal to the given internal subset and false otherwise.