Class WLink
This class abstracts a link target. Depending on the context, it may reference a URL, a
dynamic resource
, or (for certain usages) an internal path.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates whether some other object is "equal to" this one.Returns the internal path.Returns the link resource.Returns the location where the linked content should be displayed.getType()
Returns the link type.getUrl()
Returns the link URL.boolean
isNull()
Returns whether the link is unspecified.void
setInternalPath
(String internalPath) Sets the link internal path.void
setResource
(WResource resource) Sets the link resource.void
setTarget
(LinkTarget target) Sets the location where the linked content should be displayed.void
Sets the link URL.
-
Constructor Details
-
WLink
public WLink()Default constructor.This constructs a null link.
-
WLink
Creates a link to a (static) URL.- See Also:
-
WLink
Creates a link to a (static) URL or an internal path.Using this constructor, you can create a link to a static URL (
type
==LinkType.Url
) or an internal path (type
==LinkType.InternalPath
). For an internal path, thevalue
will be interpreted as a CharEncoding::UTF8 encoded string. -
WLink
Creates a link to a resource.- See Also:
-
-
Method Details
-
getType
Returns the link type.The type is implicitly set depending on the constructor or after calling
setUrl()
,setResource()
orsetInternalPath()
.The default type for a null link is
LinkType.Url
. -
isNull
public boolean isNull()Returns whether the link is unspecified.A null link is a link created using the default constructor and points to nowhere.
- See Also:
-
setUrl
Sets the link URL.This sets the type to
LinkType.Url
. -
getUrl
Returns the link URL.The return value is the URL set by
setUrl()
, the resource URL of the resource set usingsetResource()
, or the canonical URL of an internal path within the current application context. -
setResource
Sets the link resource.This sets the type to
LinkType.Resource
. -
getResource
Returns the link resource.This returns the resource previously set using
setResource()
, ornull
.- See Also:
-
setInternalPath
Sets the link internal path.This points the link to the given internal path.
-
getInternalPath
Returns the internal path.This returns the internal path perviously set using
setInternalPath()
, or an empty string otherwise.- See Also:
-
setTarget
Sets the location where the linked content should be displayed.By default, the linked content is displayed in the application (
LinkTarget.Self
). When the destination is an HTML document, the application is replaced with the new document. When the link is to a document that cannot be displayed in the browser, it is offered for download or opened using an external program, depending on browser settings.By setting
target
toLinkTarget.NewWindow
, the destination is displayed in a new browser window or tab.- See Also:
-
getTarget
Returns the location where the linked content should be displayed.- See Also:
-
equals
Indicates whether some other object is "equal to" this one.
-