Class Link


  • @ProviderType
    public final class Link
    extends java.lang.Object
    Holds information about a link processed and resolved by LinkHandler.
    • Constructor Detail

      • Link

        public Link​(@NotNull
                    @NotNull LinkType linkType,
                    @NotNull
                    @NotNull LinkRequest linkRequest)
        Parameters:
        linkType - Link type
        linkRequest - Processed link reference
    • Method Detail

      • getLinkType

        @NotNull
        public @NotNull LinkType getLinkType()
        Returns:
        Link type
      • getLinkRequest

        @NotNull
        public @NotNull LinkRequest getLinkRequest()
        Returns:
        Link request
      • setLinkRequest

        public void setLinkRequest​(@NotNull
                                   @NotNull LinkRequest linkRequest)
        Parameters:
        linkRequest - Link request
      • isLinkReferenceInvalid

        public boolean isLinkReferenceInvalid()
        Returns:
        true if a link reference was set, but the reference was invalid and could not be resolved
      • setLinkReferenceInvalid

        public void setLinkReferenceInvalid​(boolean linkReferenceInvalid)
        Parameters:
        linkReferenceInvalid - true if a link reference was set, but the reference was invalid and could not be resolved
      • getAnchor

        @Nullable
        public @Nullable io.wcm.handler.commons.dom.Anchor getAnchor()
        Returns:
        Anchor element
      • getAnchorAttributes

        @Nullable
        public @Nullable java.util.Map<java.lang.String,​java.lang.String> getAnchorAttributes()
        Returns:
        Map with all attributes of the anchor element. Returns null if anchor element is null.
      • setAnchorBuilder

        public void setAnchorBuilder​(@NotNull
                                     @NotNull java.util.function.Function<Link,​io.wcm.handler.commons.dom.Anchor> anchorBuilder)
        Parameters:
        anchorBuilder - Function that builds an anchor representation on demand
      • getMarkup

        @Nullable
        public @Nullable java.lang.String getMarkup()
        Returns:
        Link markup (only the opening anchor tag) or null if resolving was not successful.
      • getUrl

        @Nullable
        public @Nullable java.lang.String getUrl()
        Returns:
        Link URL
      • setUrl

        public void setUrl​(@Nullable
                           @Nullable java.lang.String url)
        Parameters:
        url - Link URL
      • getTargetPage

        @Nullable
        public @Nullable com.day.cq.wcm.api.Page getTargetPage()
        Returns:
        Target page referenced by the link (applies only for internal links)
      • setTargetPage

        public void setTargetPage​(@Nullable
                                  @Nullable com.day.cq.wcm.api.Page targetPage)
        Parameters:
        targetPage - Target page referenced by the link (applies only for internal links)
      • getTargetAsset

        @Nullable
        public @Nullable io.wcm.handler.media.Asset getTargetAsset()
        Returns:
        Target media item (applies only for media links)
      • setTargetAsset

        public void setTargetAsset​(@Nullable
                                   @Nullable io.wcm.handler.media.Asset targetAsset)
        Parameters:
        targetAsset - Target media item (applies only for media links)
      • getTargetRendition

        @Nullable
        public @Nullable io.wcm.handler.media.Rendition getTargetRendition()
        Returns:
        Target media rendition (applies only for media links)
      • setTargetRendition

        public void setTargetRendition​(@Nullable
                                       @Nullable io.wcm.handler.media.Rendition targetRendition)
        Parameters:
        targetRendition - Target media rendition (applies only for media links)
      • getRedirectPages

        @NotNull
        public @NotNull java.util.List<com.day.cq.wcm.api.Page> getRedirectPages()
        During link resolution one or multiple redirect pages may get resolved and replaced by the referenced link target. This page list gives access to all redirect pages that where visited and resolved during the link resolution process.
        Returns:
        List of links in the "resolve history".
      • addRedirectPage

        public void addRedirectPage​(@NotNull
                                    @NotNull com.day.cq.wcm.api.Page redirectPage)
        Add page to list of redirect pages (at first position of the list).
        Parameters:
        redirectPage - Redirect page
      • isValid

        public boolean isValid()
        Returns:
        true if link is valid and was resolved successfully
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object