rabbit.filter
Class AdFilter

java.lang.Object
  extended by rabbit.filter.HtmlFilter
      extended by rabbit.filter.AdFilter
All Implemented Interfaces:
HtmlFilterFactory

public class AdFilter
extends HtmlFilter

This class switches advertising images into another image.

Author:
Robert Olofsson

Field Summary
 
Fields inherited from class rabbit.filter.HtmlFilter
con, request, response
 
Constructor Summary
AdFilter()
          Create a new AdFilter factory
AdFilter(Connection con, HttpHeader request, HttpHeader response)
          Create a new AdFilter for the given request, response pair.
 
Method Summary
 void filterHtml(HtmlBlock block)
          Removes advertising from the given block.
 boolean isEvil(String str)
          Check if a string is evil (that is its probably advertising).
 HtmlFilter newFilter(Connection con, HttpHeader request, HttpHeader response)
          Get a new HtmlFilter for the given request, response pair.
 
Methods inherited from class rabbit.filter.HtmlFilter
isCacheable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdFilter

public AdFilter()
Create a new AdFilter factory


AdFilter

public AdFilter(Connection con,
                HttpHeader request,
                HttpHeader response)
Create a new AdFilter for the given request, response pair.

Parameters:
con - the Connection handling the request
request - the actual request made.
response - the actual response being sent.
Method Detail

newFilter

public HtmlFilter newFilter(Connection con,
                            HttpHeader request,
                            HttpHeader response)
Description copied from interface: HtmlFilterFactory
Get a new HtmlFilter for the given request, response pair.

Parameters:
con - the Connection handling the request.
request - the actual request made.
response - the actual response being sent.
Returns:
the new filter

filterHtml

public void filterHtml(HtmlBlock block)
Removes advertising from the given block.

Specified by:
filterHtml in class HtmlFilter
Parameters:
block - the part of the html page we are filtering.

isEvil

public boolean isEvil(String str)
Check if a string is evil (that is its probably advertising).

Parameters:
str - the String to check.
Returns:
true if the given string seems to contain advertising links