com.atlassian.confluence.links.linktypes
Class AbstractPageLink

java.lang.Object
  extended by com.atlassian.renderer.links.Link
      extended by com.atlassian.renderer.links.BaseLink
          extended by com.atlassian.confluence.links.linktypes.AbstractContentEntityLink
              extended by com.atlassian.confluence.links.linktypes.AbstractPageLink
Direct Known Subclasses:
BlogPostLink, PageCreateLink, PageLink

public abstract class AbstractPageLink
extends AbstractContentEntityLink


Field Summary
protected  String anchor
           
protected  AbstractPage destinationPage
           
protected  String spaceKey
           
 
Fields inherited from class com.atlassian.confluence.links.linktypes.AbstractContentEntityLink
entityName
 
Fields inherited from class com.atlassian.renderer.links.Link
aliasSpecified, iconName, linkBody, relativeUrl, title, titleArgs, titleKey, url, wikiDestination, wikiTitle
 
Constructor Summary
AbstractPageLink(com.atlassian.renderer.links.GenericLinkParser parser, PageContext context)
           
 
Method Summary
static String generateAnchor(PageContext context, String anchor)
          Used predominantly to generate an anchor in the format: #<title>-<anchor>
 String getAnchor(PageContext pageContext)
           
 ContentEntityObject getDestinationContent()
           
 String getLinkBody()
           
 String getPageTitle()
           
 String getSpaceKey()
           
protected abstract  boolean isOnSamePage(PageContext pageContext)
           
protected  void setUrlAndTitle(PageContext pageContext)
           
 OutgoingLink toOutgoingLink(ContentEntityObject sourceContent)
           
 
Methods inherited from class com.atlassian.confluence.links.linktypes.AbstractContentEntityLink
hasDestination, isNoLinkBodyProvided
 
Methods inherited from class com.atlassian.renderer.links.BaseLink
equals, getOriginalParser, hashCode, setI18nTitle, setTitle
 
Methods inherited from class com.atlassian.renderer.links.Link
getIconName, getLinkAttributes, getOriginalLinkText, getTitle, getTitleArgs, getTitleKey, getUnpermittedLinkBody, getUrl, getWikiDestination, getWikiTitle, isAliasSpecified, isRelativeUrl
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spaceKey

protected String spaceKey

destinationPage

protected AbstractPage destinationPage

anchor

protected String anchor
Constructor Detail

AbstractPageLink

public AbstractPageLink(com.atlassian.renderer.links.GenericLinkParser parser,
                        PageContext context)
                 throws ParseException
Throws:
ParseException
Method Detail

setUrlAndTitle

protected void setUrlAndTitle(PageContext pageContext)

isOnSamePage

protected abstract boolean isOnSamePage(PageContext pageContext)

getAnchor

public String getAnchor(PageContext pageContext)

getSpaceKey

public String getSpaceKey()

getPageTitle

public String getPageTitle()

getDestinationContent

public ContentEntityObject getDestinationContent()
Specified by:
getDestinationContent in class AbstractContentEntityLink

toOutgoingLink

public OutgoingLink toOutgoingLink(ContentEntityObject sourceContent)

getLinkBody

public String getLinkBody()
Overrides:
getLinkBody in class AbstractContentEntityLink

generateAnchor

public static String generateAnchor(PageContext context,
                                    String anchor)
Used predominantly to generate an anchor in the format: #<title>-<anchor>

For ease of documentation, I will use "page" to refer to content that can contain an anchor or anchor link.

The title component of the anchor is normally the title of the page.

However, when we render an anchor or an anchor link for a page that is included by another (via the include page macro) the title component is the title of the including page. This allows anchors links that have been declared on the including page to point to anchors declared on the included page.

For example, say page "A" contains an include page macro that includes page "B". And say if the body of page B has an anchor declared on it <a name="foo">. Page A can link to this anchor using [#foo].

If we are rendering an anchor that is several levels deep (that is, on a page, that is being included by page, that is being included by a page), the title component is assigned the title of the outer-most content's title. This is largely because PageContext.getOriginalContext() returns a reference to the top most context (PageContext does not maintain a stack of contexts).

Parameters:
context - the context
anchor - the anchor name
Returns:
the anchor (does not include the leading '#' symbol)


Copyright © 2003-2012 Atlassian. All Rights Reserved.