Interface LinkHandler


  • @ProviderType
    public interface LinkHandler
    Manages link resolving and markup generation.

    The interface is implemented by a Sling Model. You can adapt from SlingHttpServletRequest or Resource to get a context-specific handler instance.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static @NotNull java.lang.String INVALID_LINK
      Special link used to notify invalid links.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      @NotNull LinkBuilder get​(@NotNull LinkRequest linkRequest)
      Build link for the given request holding all further request properties.
      @NotNull LinkBuilder get​(@Nullable com.day.cq.wcm.api.Page page)
      Build internal link referencing the given content page.
      @NotNull LinkBuilder get​(@Nullable java.lang.String reference)
      Build link with auto-detecting the type from the given string.
      @NotNull LinkBuilder get​(@Nullable org.apache.sling.api.resource.Resource resource)
      Build link which is referenced in the resource (containing properties e.g. pointing to internal or external link).
      Link invalid()
      Returns an empty link that is marked as invalid.
    • Field Detail

      • INVALID_LINK

        @NotNull
        static final @NotNull java.lang.String INVALID_LINK
        Special link used to notify invalid links.
        See Also:
        Constant Field Values
    • Method Detail

      • get

        @NotNull
        @NotNull LinkBuilder get​(@Nullable
                                 @Nullable org.apache.sling.api.resource.Resource resource)
        Build link which is referenced in the resource (containing properties e.g. pointing to internal or external link).
        Parameters:
        resource - Resource containing properties that define the link target
        Returns:
        Link builder
      • get

        @NotNull
        @NotNull LinkBuilder get​(@Nullable
                                 @Nullable com.day.cq.wcm.api.Page page)
        Build internal link referencing the given content page.
        Parameters:
        page - Target content page
        Returns:
        Link builder
      • get

        @NotNull
        @NotNull LinkBuilder get​(@Nullable
                                 @Nullable java.lang.String reference)
        Build link with auto-detecting the type from the given string.
        Parameters:
        reference - Link reference (internal or external).
        Returns:
        Link builder
      • get

        @NotNull
        @NotNull LinkBuilder get​(@NotNull
                                 @NotNull LinkRequest linkRequest)
        Build link for the given request holding all further request properties.
        Parameters:
        linkRequest - Link handling request
        Returns:
        Link builder
      • invalid

        Link invalid()
        Returns an empty link that is marked as invalid.
        Returns:
        Invalid link