com.xpn.xwiki.content.parsers
Class RenamePageReplaceLinkHandler

java.lang.Object
  extended by com.xpn.xwiki.content.parsers.RenamePageReplaceLinkHandler
All Implemented Interfaces:
ReplaceLinkHandler

public class RenamePageReplaceLinkHandler
extends Object
implements ReplaceLinkHandler

A replacement link handler used for renaming documents and backlinks pointing to them.

Version:
$Id: 63a41b2eb23893016dbab9d4264cb049b1329f43 $

Constructor Summary
RenamePageReplaceLinkHandler()
           
 
Method Summary
 boolean compare(Link linkToLookFor, Link linkToReplace)
          Compare 2 links.
 Link getReplacementLink(Link newLink, Link linkToReplace)
          Compute the link that will be used to replace matching links in the parsed content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RenamePageReplaceLinkHandler

public RenamePageReplaceLinkHandler()
Method Detail

compare

public boolean compare(Link linkToLookFor,
                       Link linkToReplace)
Compare 2 links.

Two links are equal if they point to the same document and within the same location in that document.

Specified by:
compare in interface ReplaceLinkHandler
Parameters:
linkToLookFor - the link to look for
linkToReplace - the link to replace
Returns:
true if the 2 links are the same of false otherwise
See Also:
ReplaceLinkHandler.compare(Link, Link)

getReplacementLink

public Link getReplacementLink(Link newLink,
                               Link linkToReplace)
Compute the link that will be used to replace matching links in the parsed content. This is useful for example to implement a strategy where you only want to replace the space and page names but keep the existing alias, target, query string, etc.

Keep the query string, alias and target in the link to replace if they are not specified in the new link.

Specified by:
getReplacementLink in interface ReplaceLinkHandler
Parameters:
newLink - the link to use to replace the matched link. It's possible that only some fields are set and the replacement algorithm will compute what the others fields should be
linkToReplace - the link to be replaced
Returns:
the link to use for replacing the linkToReplace link
See Also:
ReplaceLinkHandler.getReplacementLink(Link, Link)


Copyright © 2004–2014 XWiki. All rights reserved.