com.xpn.xwiki.content
Class Link

java.lang.Object
  extended by com.xpn.xwiki.content.Link
All Implemented Interfaces:
Cloneable

public class Link
extends Object
implements Cloneable

Represents the parsed data of a wiki link. The XWiki link format is as follows: (alias[|>])(link)(@interWikiAlias)(|target), where:

Examples of valid wiki links:

Version:
$Id: 69aeaf2776bf3dd35a485b896bf87f088ab4dfdc $

Constructor Summary
Link()
           
 
Method Summary
 String getAlias()
           
 String getAnchor()
           
 String getInterWikiAlias()
           
 Link getNormalizedLink(String currentSpace)
          Perform a series of normalization steps on the link.
 String getPage()
           
 String getQueryString()
           
 String getSpace()
           
 String getTarget()
           
 URI getURI()
           
 String getVirtualWikiAlias()
           
 boolean isExternal()
           
 boolean isUsingPipeDelimiter()
           
 void setAlias(String alias)
           
 void setAnchor(String anchor)
           
 void setInterWikiAlias(String interWikiAlias)
           
 void setPage(String page)
           
 void setQueryString(String queryString)
           
 void setSpace(String space)
           
 void setTarget(String target)
           
 void setURI(URI uri)
           
 void setUsePipeDelimiterSymbol(boolean isUsingPipeDelimiter)
           
 void setVirtualWikiAlias(String virtualWikiAlias)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Link

public Link()
Method Detail

setAlias

public void setAlias(String alias)
Parameters:
alias - see getAlias()

getAlias

public String getAlias()
Returns:
the string which will be displayed to the user when the link is rendered or null if no alias has been specified (in that case the page name or the URI will be displayed. Example: "My Page"

setTarget

public void setTarget(String target)
Parameters:
target - see getTarget()

getTarget

public String getTarget()
Returns:
the browser window in which the link should be opened into or null if not defined. This element corresponds to the HTML target attribute for the a element. It is used when rendering the link and defauts to opening the link in the current page. Example: "_self", "_blank".

setVirtualWikiAlias

public void setVirtualWikiAlias(String virtualWikiAlias)
Parameters:
virtualWikiAlias - see getVirtualWikiAlias()

getVirtualWikiAlias

public String getVirtualWikiAlias()
Returns:
the name of the virtual wiki to which the link is pointing to or null if the link is pointing to the current wiki. Example: "mywiki"

setSpace

public void setSpace(String space)
Parameters:
space - see getSpace()

getSpace

public String getSpace()
Returns:
the wiki Space name in which the link points to or null if not defined (in that case the link points to the current space). Example: "Main"

setInterWikiAlias

public void setInterWikiAlias(String interWikiAlias)
Parameters:
interWikiAlias - see getInterWikiAlias()

getInterWikiAlias

public String getInterWikiAlias()
Returns:
the Inter Wiki alias to which the link is pointing to or null if not defined. Mappings between Inter Wiki aliases and actual locations are defined in the Inter Wiki Map. Example: "wikipedia"

setAnchor

public void setAnchor(String anchor)
Parameters:
anchor - see getAnchor()

getAnchor

public String getAnchor()
Returns:
the anchor name pointing to an anchor defined in the referenced link or null if no anchor has been specified (in which case the link points to the top of the page). Note that in XWiki anchors are automatically created for titles. Example: "TableOfContentAnchor"

setQueryString

public void setQueryString(String queryString)
Parameters:
queryString - see getQueryString()

getQueryString

public String getQueryString()
Returns:
the query string for specifying parameters that will be used in the rendered URL or null if no query string has been specified. Example: "mydata1=5&mydata2=Hello"

setPage

public void setPage(String page)
Parameters:
page - see getPage()

getPage

public String getPage()
Returns:
the Wiki page pointed to by this link or null if the link is pointing to an external URI. Example: "WebHome".

setURI

public void setURI(URI uri)
Parameters:
uri - see getURI()

getURI

public URI getURI()
Returns:
the URI this link is pointing to. Valid URIs are mailto links (Example: "mailto:john@smith.com") or URL (Example: "http://www.xwiki.org").

isUsingPipeDelimiter

public boolean isUsingPipeDelimiter()
Returns:
true if the link is using the Pipe symbol ("|") as its separator between alias, target and link name, or false if it's using the greater than symbol (">")

setUsePipeDelimiterSymbol

public void setUsePipeDelimiterSymbol(boolean isUsingPipeDelimiter)
Parameters:
isUsingPipeDelimiter - see isUsingPipeDelimiter()

toString

public String toString()
Overrides:
toString in class Object

isExternal

public boolean isExternal()
Returns:
true if the link is external (ie it's not a link on the current local wiki) or false otherwise

getNormalizedLink

public Link getNormalizedLink(String currentSpace)
Perform a series of normalization steps on the link. The steps are:

Parameters:
currentSpace - the space to use when no space has been defined in the link
Returns:
the normalized link


Copyright © 2004-2013 XWiki. All Rights Reserved.