org.sitemesh.webapp.contentfilter
Class BasicSelector

java.lang.Object
  extended by org.sitemesh.webapp.contentfilter.BasicSelector
All Implemented Interfaces:
Selector

public class BasicSelector
extends Object
implements Selector

Basic implementation of Selector. Will select OK responses that match a particular MIME type, and (optionally) error pages. It will also only kick in once per request.

For more control, this can be subclassed, or replaced with a different implementation of Selector.

Author:
Joe Walnes

Constructor Summary
BasicSelector(boolean includeErrorPages, String... mimeTypesToBuffer)
           
BasicSelector(String... mimeTypesToBuffer)
           
 
Method Summary
protected  boolean filterAlreadyAppliedForRequest(javax.servlet.http.HttpServletRequest request)
           
 boolean shouldAbortBufferingForHttpStatusCode(int statusCode)
          Determine whether buffering should be used for a particular HTTP status code.
 boolean shouldBufferForContentType(String contentType, String mimeType, String encoding)
          Determine whether buffering should be used for a particular content-type.
 boolean shouldBufferForRequest(javax.servlet.http.HttpServletRequest request)
          Determine whether buffering should be used for a particular request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicSelector

public BasicSelector(String... mimeTypesToBuffer)

BasicSelector

public BasicSelector(boolean includeErrorPages,
                     String... mimeTypesToBuffer)
Method Detail

shouldBufferForContentType

public boolean shouldBufferForContentType(String contentType,
                                          String mimeType,
                                          String encoding)
Description copied from interface: Selector
Determine whether buffering should be used for a particular content-type. Use this to ensure that only content-types you care about are intercepted.

Specified by:
shouldBufferForContentType in interface Selector
Parameters:
contentType - e.g. "text/html; charset=iso-8859-1"
mimeType - e.g "text/html"
encoding - e.g. "iso-8859-1" (may be null)

shouldAbortBufferingForHttpStatusCode

public boolean shouldAbortBufferingForHttpStatusCode(int statusCode)
Description copied from interface: Selector
Determine whether buffering should be used for a particular HTTP status code. For example, some applications may choose to rewrite content of 404 error pages.

Specified by:
shouldAbortBufferingForHttpStatusCode in interface Selector
Parameters:
statusCode - e.g. 200, 302, 404, 500, etc. See constants in HttpServletResponse.

shouldBufferForRequest

public boolean shouldBufferForRequest(javax.servlet.http.HttpServletRequest request)
Description copied from interface: Selector
Determine whether buffering should be used for a particular request. For example, elements like path, attributes, cookies, etc may influence this.

Specified by:
shouldBufferForRequest in interface Selector

filterAlreadyAppliedForRequest

protected boolean filterAlreadyAppliedForRequest(javax.servlet.http.HttpServletRequest request)


Copyright © 2011. All Rights Reserved.