Package io.wcm.handler.link
Class Link
- java.lang.Object
-
- io.wcm.handler.link.Link
-
@ProviderType public final class Link extends java.lang.Object
Holds information about a link processed and resolved byLinkHandler
.
-
-
Constructor Summary
Constructors Constructor Description Link(@NotNull LinkType linkType, @NotNull LinkRequest linkRequest)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRedirectPage(@NotNull com.day.cq.wcm.api.Page redirectPage)
Add page to list of redirect pages (at first position of the list).@Nullable io.wcm.handler.commons.dom.Anchor
getAnchor()
@Nullable java.util.Map<java.lang.String,java.lang.String>
getAnchorAttributes()
@NotNull LinkRequest
getLinkRequest()
@NotNull LinkType
getLinkType()
@Nullable java.lang.String
getMarkup()
@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.@Nullable io.wcm.handler.media.Asset
getTargetAsset()
@Nullable com.day.cq.wcm.api.Page
getTargetPage()
@Nullable io.wcm.handler.media.Rendition
getTargetRendition()
@Nullable java.lang.String
getUrl()
boolean
isLinkReferenceInvalid()
boolean
isValid()
void
setAnchorBuilder(@NotNull java.util.function.Function<Link,io.wcm.handler.commons.dom.Anchor> anchorBuilder)
void
setLinkReferenceInvalid(boolean linkReferenceInvalid)
void
setLinkRequest(@NotNull LinkRequest linkRequest)
void
setTargetAsset(@Nullable io.wcm.handler.media.Asset targetAsset)
void
setTargetPage(@Nullable com.day.cq.wcm.api.Page targetPage)
void
setTargetRendition(@Nullable io.wcm.handler.media.Rendition targetRendition)
void
setUrl(@Nullable java.lang.String url)
java.lang.String
toString()
-
-
-
Constructor Detail
-
Link
public Link(@NotNull @NotNull LinkType linkType, @NotNull @NotNull LinkRequest linkRequest)
- Parameters:
linkType
- Link typelinkRequest
- 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 classjava.lang.Object
-
-