public abstract class AbstractPageLink extends AbstractContentEntityLink
Modifier and Type | Field and Description |
---|---|
protected String |
anchor |
protected AbstractPage |
destinationPage |
protected String |
spaceKey |
entityName
Constructor and Description |
---|
AbstractPageLink(com.atlassian.renderer.links.GenericLinkParser parser,
PageContext context) |
Modifier and Type | Method and Description |
---|---|
static String |
generateAnchor(PageContext context,
String anchor)
This method generates a HTML encoded anchor
|
static String |
generateUnencodedAnchor(PageContext context,
String anchor)
Generates a valid HTML5 anchor with a prefix added to the anchor name.
|
static String |
generateUniqueAnchor(PageContext context,
String anchor)
Similar in most respects to
generateAnchor(com.atlassian.confluence.renderer.PageContext, String) . |
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) |
hasDestination, isNoLinkBodyProvided
equals, getOriginalParser, hashCode, setI18nTitle, setTitle
protected String spaceKey
protected AbstractPage destinationPage
protected String anchor
public AbstractPageLink(com.atlassian.renderer.links.GenericLinkParser parser, PageContext context) throws ParseException
ParseException
protected void setUrlAndTitle(PageContext pageContext)
protected abstract boolean isOnSamePage(PageContext pageContext)
public String getAnchor(PageContext pageContext)
public String getSpaceKey()
public String getPageTitle()
public ContentEntityObject getDestinationContent()
getDestinationContent
in class AbstractContentEntityLink
public OutgoingLink toOutgoingLink(ContentEntityObject sourceContent)
public String getLinkBody()
getLinkBody
in class AbstractContentEntityLink
public static String generateUnencodedAnchor(PageContext context, String anchor)
The prefix is the title of the page currently being viewed or, if the page title is not available, the space key of the space in which the anchor resides.
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).
context
- the page object which the prefix (title) is derived fromanchor
- the string which the context-unique ID will be derived frompublic static String generateAnchor(PageContext context, String anchor)
context
- anchor
- public static String generateUniqueAnchor(PageContext context, String anchor)
generateAnchor(com.atlassian.confluence.renderer.PageContext, String)
.
The difference here is that generateUniqueAnchor ensures that the output of the identifier is unique within the page.Copyright © 2003–2016 Atlassian. All rights reserved.