Interface IMarkupSelectorReferenceResolver


public interface IMarkupSelectorReferenceResolver

Interface modeling reference resolvers, the objects that can be used for tuning the selector matching operations done by BlockSelectorMarkupHandler and NodeSelectorMarkupHandler.

This tuning is performed by means of selector references, which look like %ref and which are passed to the reference resolvers in order to convert them to more specific selectors.

For example, a reference resolver might convert %someref to //p[data-additional="someref"] so that %someref simply becomes an easier way to specify "a paragraph element that has an attribute called 'data-additional' with value 'someref'".

As another example, this %fragment (or simply fragment) syntax is heavily used by Thymeleaf in order to search for elements with a th:fragment or data-th-fragment attribute with a specific "fragment" value.

Note: avoid creating new instances of the same class implementing this interface: better always use just one instance, unless the implementation gives non-deterministic results. The object equality of this class (its equals()) will be used for caching parsed selectors.

Since:
2.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Convert the specified value, coming from a selector reference, into a complete markup selector.
  • Method Details

    • resolveSelectorFromReference

      String resolveSelectorFromReference(String reference)

      Convert the specified value, coming from a selector reference, into a complete markup selector.

      For example given a selector reference like %someref, this method will be called with reference value "someref", and the result could be something like //p[data-additional="someref"] in order to make %ref a synonym to "a paragraph element that has an attribute called 'data-additional' with value 'someref'".

      Parameters:
      reference - the reference value (without the %).
      Returns:
      the equivalent, complete markup selector.