package webraveler.plugin; import java.util.*; import webraveler.html.HTMLPage2; import webraveler.http.HTTPRequest; import webraveler.http.HTTPResponse; import webraveler.ravel.PluginAPI; import webraveler.vurl.PluginChangePref; import webraveler.vurl.PluginConfig; /** * * A quick demo of linking to the instructor's home. * **/ public class BonkifyPlugin extends webraveler.ravel.RavelerPlugin { /* variables */ /*constructors*/ public BonkifyPlugin () { name = "BonkifyPlugin"; mimeTypes.add("text/html"); } /*methods*/ public void setDefaultAttributes () { attributes = new Hashtable(); attributes.put("InsertHtml","

Return to the course home.

"); } public boolean initialize () { return true; }//initialize() public HTTPRequest execute (HTTPRequest request, Hashtable attributes) { return request; }//execute() public HTTPResponse execute (HTTPResponse response, Hashtable attributes){ System.out.println("Executing BonkifyPlugin: "); webraveler.html.HTMLPage2 page = response.getHtmlPage(); if (page.toString().indexOf("Curtis J. Bonk") >= 0) { response.getHtmlPage().insertAtTop("

You've found a special Bonk page!

"); } /* Change the entityBytes of the passed HTTPResponse to the HTML page w/inserted text * at the top */ response.correctContentLength(); System.out.println("BonkifyPlugin: DONE"); return response; } //execute(HTTPResponse) public void terminate() { } // terminate() }// BonkifyPlugin