Package org.htmlunit.cyberneko
Class HTMLElements.HTMLElementsWithCache
- java.lang.Object
-
- org.htmlunit.cyberneko.HTMLElements.HTMLElementsWithCache
-
- All Implemented Interfaces:
HTMLElementsProvider
- Enclosing class:
- HTMLElements
public static class HTMLElements.HTMLElementsWithCache extends java.lang.Object implements HTMLElementsProvider
An implementation ofHTMLElementsProviderthat wraps anHTMLElementsinstance 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 Summary
Fields Modifier and Type Field Description private HTMLElementshtmlElements_private FastHashMap<java.lang.String,java.lang.Boolean>unknownElements_
-
Constructor Summary
Constructors Constructor Description HTMLElementsWithCache(HTMLElements htmlElements)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HTMLElements.ElementgetElement(java.lang.String ename)HTMLElements.ElementgetElement(java.lang.String ename, HTMLElements.Element elementIfNotFound)HTMLElements.ElementgetElementLC(java.lang.String enameLC, HTMLElements.Element elementIfNotFound)
-
-
-
Field Detail
-
htmlElements_
private final HTMLElements htmlElements_
-
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)
- Specified by:
getElementin interfaceHTMLElementsProvider- Parameters:
ename- the element name.- Returns:
- the element information for the specified element name.
-
getElement
public HTMLElements.Element getElement(java.lang.String ename, HTMLElements.Element elementIfNotFound)
- Specified by:
getElementin interfaceHTMLElementsProvider- 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:
getElementLCin interfaceHTMLElementsProvider- Parameters:
enameLC- the element name in lower caseelementIfNotFound- the default element to return if not found.- Returns:
- the element information for the specified element name.
-
-