Class HTMLElements.HTMLElementsWithCache

  • All Implemented Interfaces:
    HTMLElementsProvider
    Enclosing class:
    HTMLElements

    public static class HTMLElements.HTMLElementsWithCache
    extends java.lang.Object
    implements HTMLElementsProvider
    An implementation of HTMLElementsProvider that wraps an HTMLElements instance and adds a simple cache for unknown element lookups.

    This class is optimized for repeated element name lookups, especially for names that are not present in the known elements set. It avoids repeated lowercasing and unnecessary lookups for unknown elements by caching misses.

    This implementation is not thread-safe.

    • Field Detail

      • unknownElements_

        private final FastHashMap<java.lang.String,​java.lang.Boolean> unknownElements_
    • Constructor Detail

      • HTMLElementsWithCache

        public HTMLElementsWithCache​(HTMLElements htmlElements)
    • Method Detail

      • getElement

        public HTMLElements.Element getElement​(java.lang.String ename,
                                               HTMLElements.Element elementIfNotFound)
        Specified by:
        getElement in interface HTMLElementsProvider
        Parameters:
        ename - the element name.
        elementIfNotFound - the default element to return if not found.
        Returns:
        the element information for the specified element name.
      • getElementLC

        public HTMLElements.Element getElementLC​(java.lang.String enameLC,
                                                 HTMLElements.Element elementIfNotFound)
        Specified by:
        getElementLC in interface HTMLElementsProvider
        Parameters:
        enameLC - the element name in lower case
        elementIfNotFound - the default element to return if not found.
        Returns:
        the element information for the specified element name.