Class LinkAnnotationEditor

public abstract class LinkAnnotationEditor
extends HttpEditor

An abstract Editor that modifies an HTML document by editing the information in the links. The extender of this class needs to implement the editLink(LinkInfo) method. The MaxLinksToEditPerPage property can be set to specify the maximum number of links that should be edited on a single page. This property can be used to limit the amount of computation that is performed on a single page. If the property is set to -1 (the default) then all of the links of the page will be edited.

Inner Class Summary
 class LinkAnnotationEditor.LinkInfo
          A class for containing the relevant information for a particular link in an HTML document.
 class LinkAnnotationEditor.NoMoreEditingException
          An exception that may be thrown by editLink(LinkInfo) when it has determined that it no longer wishes to annotate links in this document
Field Summary
static java.lang.String COPYRIGHT
          IBM copyright information
Fields inherited from class
Constructor Summary
          default constructor.
LinkAnnotationEditor(java.lang.String encoding)
          Allow the user to specify the encoding BUGBUG should we have this method??
Method Summary
protected abstract  void editLink(LinkAnnotationEditor.LinkInfo linkInfo)
          Extender of this class should supply this method. Each link of a document will be converted into a LinkInfo object and passed to this method.
 int getMaxLinksToEditPerPage()
          Access the MaxLinksToEditPerPage property.
 void handleRequest(RequestEvent e)
          the method used by WBI to edit the document.
 void setMaxLinksToEditPerPage(int max)
          set the MaxLinksToEditPerPage property.
Methods inherited from class
Methods inherited from class
forwardRequest, getCondition, getEnabled, getMegProperty, getMegProperty, getMegPropertyKeys, getName, getPlugin, getPriority, getSystemContext, initialize, initialize, isEnabled, isMegApplicable, loadMegResources, run, setCondition, setEnabled, setMegProperty, setName, setPriority, setSystemContext, setup, setup, setup, setup

Field Detail


public static final java.lang.String COPYRIGHT
IBM copyright information
Constructor Detail


public LinkAnnotationEditor()
default constructor. Sets the MaxLinksToEditPerPage property to -1 (edit all links)


public LinkAnnotationEditor(java.lang.String encoding)
Allow the user to specify the encoding BUGBUG should we have this method??
Method Detail


public void setMaxLinksToEditPerPage(int max)
set the MaxLinksToEditPerPage property. After the specified number of links have been edited, the rest of the links will pass through without editing. Set to -1 to edit all of the links on the page.
max - the maximum number of links to edit on a single page


public int getMaxLinksToEditPerPage()
Access the MaxLinksToEditPerPage property.
Maximum links to edit per page.


public void handleRequest(RequestEvent e)
                   throws RequestRejectedException,
the method used by WBI to edit the document. Note that this method does not alter documents if they have a response code other than 200 (Ok). It does not check to ensure that the document is truly HTML and may mangle other document types. It successively calls editLink(LinkInfo) on each link of the page until the MaxLinksToEditPerPage value is reached or the editLink(LinkInfo) method throws a NoMoreEditingException.
handleRequest in class HttpEditor
e - Request event object.
RequestRejectedException - if the HTTP response code is different than 200.


protected abstract void editLink(LinkAnnotationEditor.LinkInfo linkInfo)
                          throws LinkAnnotationEditor.NoMoreEditingException
Extender of this class should supply this method. Each link of a document will be converted into a LinkInfo object and passed to this method. The extender of this class should write a method which then modifies the link in the desired way, i.e. change the link text, add annotations before and after the link, etc.
linkInfo - On entry this contains the information for the current link, including the link HTMLItem itself, the link text (everything between the and tags, and the URL being linked to. The preLink and postLink fields are initially null.
This method is allowed to modify any of the information in this object. (Note that changes to the linkURL do not affect the results, if the target URL should be changed, replace the linkTag field with an appropriate tag. If the linkTag is set to null, the anchor is removed from the text. The preLink and postLink strings will be prepended and postpended before and after any ... structure. Note that the linkURL field may be 'null' if Java couldn't understand the URL (i.e. if it were a news://... link)