public class Link extends Object implements ObjectSizeProvider, Serializable, com.tridion.linking.fastserialization.FastSerializable<Link>
Link object is a bean that holds information about a link
to a UDP resource. Other functional objects, like PageLink,
ComponentLink and BinaryLink use this object.
All link properties can be modified after creation, allowing Template
Designers to influence the Link object after creation.
| Constructor and Description |
|---|
Link(String url,
String anchor,
String parameters,
String targetURI,
String text,
String attributes,
boolean textOnFail)
Creates a new
Link instance. |
| Modifier and Type | Method and Description |
|---|---|
String |
getAnchor()
Returns the anchor for this link.
|
String |
getAttributes()
Returns the attributes for this link.
|
String |
getBinaryUrl() |
int |
getObjectSize()
Estimates the size in bytes of this object and the objects that it owns.
|
String |
getParameters()
Returns the QueryString for this link.
|
String |
getTargetURI()
Returns the tcm:uri if the Item targetted by this link.
|
String |
getText()
Returns the link text for this link.
|
boolean |
getTextOnFail()
Returns the textOnFail value, which indicates if the link will return
text if the targetted URI cannot be resolved or validated.
|
String |
getURL()
Returns the URL of the resolved item.
|
boolean |
isResolved()
Indicates if this link has been resolved and is targetting a valid URL.
|
Link |
makeClone()
This method creates a clone for current object.
|
void |
setAnchor(String anchor)
Sets the anchor of this
Link instance. |
void |
setAttributes(String attributes)
Sets the attributes for this
Link instance. |
void |
setBinaryUrl(String binaryUrl)
Allows to set image instead of given text.
|
void |
setParameters(String parameters)
Sets the QueryString of this
Link instance. |
void |
setText(String text)
Sets the link text for this
Link instance. |
void |
setTextOnFail(boolean textOnFail)
Sets the textOnFail property for this
Link instance. |
void |
setURL(String theUrl)
Sets the URL of this
Link instance. |
String |
toString()
The toString method returns a string representation of this instance.
|
String |
toString(LinkStringStyle linkStringStyle)
The toString method returns a string representation of this instance.
|
public Link(String url, String anchor, String parameters, String targetURI, String text, String attributes, boolean textOnFail)
Link instance.url - The URL to which this link object should point.anchor - The anchor on a page to which should point.parameters - The parameters that should be used appended to the URL.targetURI - The tcm:uri that is targeted by this link.text - The text that should be inside the link.attributes - The attributes that should be used inside the link tag.textOnFail - A boolean indicating whether or not the link text should be
returned in case the link cannot be resolved.public Link makeClone()
makeClone in interface com.tridion.linking.fastserialization.FastSerializable<Link>public int getObjectSize()
getObjectSize in interface ObjectSizeProviderpublic String getURL()
null
if it could not be resolved.public void setURL(String theUrl)
Link instance.theUrl - The new URL to which this link object should point.public String getAnchor()
public void setAnchor(String anchor)
Link instance.anchor - The new anchor for this link.public String getParameters()
public void setParameters(String parameters)
Link instance.parameters - The new QueryString for this link instance.public String getAttributes()
public void setAttributes(String attributes)
Link instance.attributes - The new attributes for this link instance.public String getText()
public void setText(String text)
Link instance.
In case binaryUrl is set, this text will be ignored.text - The new link text that should appear inside the link.public boolean getTextOnFail()
public void setTextOnFail(boolean textOnFail)
Link instance.textOnFail - The new textOnFail value.public String getTargetURI()
public String getBinaryUrl()
public void setBinaryUrl(String binaryUrl)
binaryUrl - url of image (a.k.a. 'src' attribute in <img> tag).public boolean isResolved()
public String toString()
public String toString(LinkStringStyle linkStringStyle)
linkStringStyle - the style of linktextOnFail parameter.Copyright (c) 2014-2021 All Rights Reserved by the RWS Group for and on behalf of its affiliates and subsidiaries