com.ibm.wbi.protocol.http.beans
Class TagAnnotationEditor

com.ibm.wbi.Meg
  |
  +--com.ibm.wbi.Editor
        |
        +--com.ibm.wbi.protocol.http.HttpEditor
              |
              +--com.ibm.wbi.protocol.http.beans.TagAnnotationEditor

public abstract class TagAnnotationEditor
extends HttpEditor

An abstract Editor that modifies an HTML document by editing the information in the tags. The extender of this class needs to implement the editTag(TagInfo) method.


Inner Class Summary
 class TagAnnotationEditor.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
protected  class TagAnnotationEditor.TagInfo
          A class for containing the relevant information for a particular tag in an Html document.
 
Field Summary
protected  boolean environment
          Flag indicating whether the tag to be annotated has an environment.
protected  java.lang.String tag
          Tag name, default is "IMG".
 
Fields inherited from class com.ibm.wbi.protocol.http.HttpEditor
COPYRIGHT
 
Fields inherited from class com.ibm.wbi.Meg
EDITOR, GENERATOR, MONITOR, REQUEST_EDITOR, UNDEFINED
 
Constructor Summary
TagAnnotationEditor()
          The TagAnnotationEditor constructor
 
Method Summary
abstract  void editTag(RequestEvent e, TagAnnotationEditor.TagInfo taginfo)
          Extender of this class should supply this method. Each appropriate tag of a document will be converted into a TagInfo object and passed to this method.
 java.lang.String getTag()
          Gets the type of tag we are editing (e.g., IMG, A).
 void handleRequest(RequestEvent e)
          Handle the request by editing the tags in the document.
 boolean isEnvironment()
          Whether this is an environment tag or not.
 void setEnvironment(boolean b)
          Sets whether this is an Environment tag.
 void setTag(java.lang.String t)
          Sets the type of tag to edit, e.g., IMG, A, etc.
 
Methods inherited from class com.ibm.wbi.Editor
getType
 
Methods inherited from class com.ibm.wbi.Meg
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

environment

protected boolean environment
Flag indicating whether the tag to be annotated has an environment.
See Also:
setEnvironment(boolean)

tag

protected java.lang.String tag
Tag name, default is "IMG".
Constructor Detail

TagAnnotationEditor

public TagAnnotationEditor()
The TagAnnotationEditor constructor
Method Detail

getTag

public java.lang.String getTag()
Gets the type of tag we are editing (e.g., IMG, A).
Returns:
the type of tag we are editing

setTag

public void setTag(java.lang.String t)
Sets the type of tag to edit, e.g., IMG, A, etc. The default is IMG. These values are case insensitive.
Parameters:
t - The new tag type

isEnvironment

public boolean isEnvironment()
Whether this is an environment tag or not.
Returns:
Whether this is an environment tag or not
See Also:
setEnvironment(boolean)

setEnvironment

public void setEnvironment(boolean b)
Sets whether this is an Environment tag. An environment tag is one which has a body and closing tag, like <B> -- body -- </B> as opposed to <A href='#foo'>.
Parameters:
b - Whether this tag is an environment tag

handleRequest

public void handleRequest(RequestEvent e)
                   throws RequestRejectedException
Handle the request by editing the tags in the document.
Overrides:
handleRequest in class HttpEditor
Parameters:
e - The RequestEvent object
Throws:
RequestRejectedException - is thrown if the document response code is not 200 (http ok).

editTag

public abstract void editTag(RequestEvent e,
                             TagAnnotationEditor.TagInfo taginfo)
                      throws TagAnnotationEditor.NoMoreEditingException
Extender of this class should supply this method. Each appropriate tag of a document will be converted into a TagInfo object and passed to this method. The extender of this class should write a method which then modifies the tag/environment in the desired way, i.e. change the text, add annotations before and after it, etc.
Parameters:
taginfo - On entry this contains the information for the current tag, including the starting HtmlTag, the text (everything between the and tags, and the ending tag (eg, ). The preTag and postTag 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 startTag is set to null, the entire environment (start, text, end) is removed from the text. The preTag and postTag strings will be prepended and postpended before and after the env, eg before and after the ... structure.