/* this belongs to the WebRaveler2.Plugins package */ package webraveler.plugin; import java.util.*; import webraveler.html.HTMLPage2; import webraveler.http.HTTPRequest; import webraveler.http.HTTPResponse; /** * A Web Raveler plugin to insert text at the bottom of an * HTML page * * @author The Web Raveler Development Squad * @version 1.0 */ public class InsertInHeadPlugin extends webraveler.ravel.RavelerPlugin { String htmlToInsert; String targetTag; /** * */ public InsertInHeadPlugin() { name = "InsertInHeadPlugin"; mimeTypes.add("text/html"); } // InsertAtBottomPlugin() /** * */ public boolean initialize() { return true; } // initialize() /** * */ public HTTPRequest execute(HTTPRequest request, Hashtable attributes) { return request; } // execute(HTTPRequest) /** * */ public HTTPResponse execute(HTTPResponse response, Hashtable attributes) { System.out.println("InsertInHeadPlugin: Executing..."); System.out.println("InsertInHeadPlugin: Inserting text..."); htmlToInsert = (String) attributes.get("htmlToInsert"); targetTag = (String) attributes.get("targetTag"); // response.getHtmlPage().insertInHead("<"+targetTag+">"+htmlToInsert+""); response.correctContentLength(); System.out.println("InsertInHeadPlugin: DONE"); // otherwise just return the original response return response; } //execute(HTTPResponse) /** * */ public void terminate() { } // terminate() /** * Return the default configuration for this plugin as a hash table. * */ public void setDefaultAttributes() { attributes = new Hashtable(); attributes.put("htmlToInsert"," Chillin' in header!"); attributes.put("targetTag","foobar"); } } // InsertInHeadPlugin