FileDocCategorySizeDatePackage
FilterMap.javaAPI DocApache Tomcat 6.0.149626Fri Jul 20 04:20:30 BST 2007org.apache.catalina.deploy

FilterMap

public class FilterMap extends Object implements Serializable
Representation of a filter mapping for a web application, as represented in a <filter-mapping> element in the deployment descriptor. Each filter mapping must contain a filter name plus either a URL pattern or a servlet name.
author
Craig R. McClanahan
version
$Revision: 504726 $ $Date: 2007-02-07 23:53:07 +0100 (mer., 07 févr. 2007) $

Fields Summary
public static final int
ERROR
The name of this filter to be executed when this mapping matches a particular request.
public static final int
FORWARD
public static final int
FORWARD_ERROR
public static final int
INCLUDE
public static final int
INCLUDE_ERROR
public static final int
INCLUDE_ERROR_FORWARD
public static final int
INCLUDE_FORWARD
public static final int
REQUEST
public static final int
REQUEST_ERROR
public static final int
REQUEST_ERROR_FORWARD
public static final int
REQUEST_ERROR_FORWARD_INCLUDE
public static final int
REQUEST_ERROR_INCLUDE
public static final int
REQUEST_FORWARD
public static final int
REQUEST_INCLUDE
public static final int
REQUEST_FORWARD_INCLUDE
private static final int
NOT_SET
private int
dispatcherMapping
private String
filterName
private String[]
servletNames
The servlet name this mapping matches.
private boolean
matchAllUrlPatterns
The flag that indicates this mapping will match all url-patterns
private boolean
matchAllServletNames
The flag that indicates this mapping will match all servlet-names
private String[]
urlPatterns
The URL pattern this mapping matches.
Constructors Summary
Methods Summary
public voidaddServletName(java.lang.String servletName)

        if ("*".equals(servletName)) {
            this.matchAllServletNames = true;
        } else {
            String[] results = new String[servletNames.length + 1];
            System.arraycopy(servletNames, 0, results, 0, servletNames.length);
            results[servletNames.length] = servletName;
            servletNames = results;
        }
    
public voidaddURLPattern(java.lang.String urlPattern)

        if ("*".equals(urlPattern)) {
            this.matchAllUrlPatterns = true;
        } else {
            String[] results = new String[urlPatterns.length + 1];
            System.arraycopy(urlPatterns, 0, results, 0, urlPatterns.length);
            results[urlPatterns.length] = RequestUtil.URLDecode(urlPattern);
            urlPatterns = results;
        }
    
public intgetDispatcherMapping()

        // per the SRV.6.2.5 absence of any dispatcher elements is
        // equivelant to a REQUEST value
        if (dispatcherMapping == NOT_SET) return REQUEST;
        else return dispatcherMapping; 
    
public java.lang.StringgetFilterName()

    

       
        return (this.filterName);
    
public booleangetMatchAllServletNames()

    
       
        return matchAllServletNames;
    
public booleangetMatchAllUrlPatterns()

    
       
        return matchAllUrlPatterns;
    
public java.lang.String[]getServletNames()


       
        return (this.servletNames);
    
public java.lang.String[]getURLPatterns()


       
        return (this.urlPatterns);
    
public voidsetDispatcher(java.lang.String dispatcherString)
This method will be used to set the current state of the FilterMap representing the state of when filters should be applied: ERROR FORWARD FORWARD_ERROR INCLUDE INCLUDE_ERROR INCLUDE_ERROR_FORWARD REQUEST REQUEST_ERROR REQUEST_ERROR_INCLUDE REQUEST_ERROR_FORWARD_INCLUDE REQUEST_INCLUDE REQUEST_FORWARD, REQUEST_FORWARD_INCLUDE

        String dispatcher = dispatcherString.toUpperCase();
        
        if (dispatcher.equals("FORWARD")) {

            // apply FORWARD to the global dispatcherMapping.
            switch (dispatcherMapping) {
                case NOT_SET  :  dispatcherMapping = FORWARD; break;
                case ERROR : dispatcherMapping = FORWARD_ERROR; break;
                case INCLUDE  :  dispatcherMapping = INCLUDE_FORWARD; break;
                case INCLUDE_ERROR  :  dispatcherMapping = INCLUDE_ERROR_FORWARD; break;
                case REQUEST : dispatcherMapping = REQUEST_FORWARD; break;
                case REQUEST_ERROR : dispatcherMapping = REQUEST_ERROR_FORWARD; break;
                case REQUEST_ERROR_INCLUDE : dispatcherMapping = REQUEST_ERROR_FORWARD_INCLUDE; break;
                case REQUEST_INCLUDE : dispatcherMapping = REQUEST_FORWARD_INCLUDE; break;
            }
        } else if (dispatcher.equals("INCLUDE")) {
            // apply INCLUDE to the global dispatcherMapping.
            switch (dispatcherMapping) {
                case NOT_SET  :  dispatcherMapping = INCLUDE; break;
                case ERROR : dispatcherMapping = INCLUDE_ERROR; break;
                case FORWARD  :  dispatcherMapping = INCLUDE_FORWARD; break;
                case FORWARD_ERROR  :  dispatcherMapping = INCLUDE_ERROR_FORWARD; break;
                case REQUEST : dispatcherMapping = REQUEST_INCLUDE; break;
                case REQUEST_ERROR : dispatcherMapping = REQUEST_ERROR_INCLUDE; break;
                case REQUEST_ERROR_FORWARD : dispatcherMapping = REQUEST_ERROR_FORWARD_INCLUDE; break;
                case REQUEST_FORWARD : dispatcherMapping = REQUEST_FORWARD_INCLUDE; break;
            }
        } else if (dispatcher.equals("REQUEST")) {
            // apply REQUEST to the global dispatcherMapping.
            switch (dispatcherMapping) {
                case NOT_SET  :  dispatcherMapping = REQUEST; break;
                case ERROR : dispatcherMapping = REQUEST_ERROR; break;
                case FORWARD  :  dispatcherMapping = REQUEST_FORWARD; break;
                case FORWARD_ERROR  :  dispatcherMapping = REQUEST_ERROR_FORWARD; break;
                case INCLUDE  :  dispatcherMapping = REQUEST_INCLUDE; break;
                case INCLUDE_ERROR  :  dispatcherMapping = REQUEST_ERROR_INCLUDE; break;
                case INCLUDE_FORWARD : dispatcherMapping = REQUEST_FORWARD_INCLUDE; break;
                case INCLUDE_ERROR_FORWARD : dispatcherMapping = REQUEST_ERROR_FORWARD_INCLUDE; break;
            }
        }  else if (dispatcher.equals("ERROR")) {
            // apply ERROR to the global dispatcherMapping.
            switch (dispatcherMapping) {
                case NOT_SET  :  dispatcherMapping = ERROR; break;
                case FORWARD  :  dispatcherMapping = FORWARD_ERROR; break;
                case INCLUDE  :  dispatcherMapping = INCLUDE_ERROR; break;
                case INCLUDE_FORWARD : dispatcherMapping = INCLUDE_ERROR_FORWARD; break;
                case REQUEST : dispatcherMapping = REQUEST_ERROR; break;
                case REQUEST_INCLUDE : dispatcherMapping = REQUEST_ERROR_INCLUDE; break;
                case REQUEST_FORWARD : dispatcherMapping = REQUEST_ERROR_FORWARD; break;
                case REQUEST_FORWARD_INCLUDE : dispatcherMapping = REQUEST_ERROR_FORWARD_INCLUDE; break;
            }
        }
    
public voidsetFilterName(java.lang.String filterName)

        this.filterName = filterName;
    
public java.lang.StringtoString()
Render a String representation of this object.


        StringBuffer sb = new StringBuffer("FilterMap[");
        sb.append("filterName=");
        sb.append(this.filterName);
        for (int i = 0; i < servletNames.length; i++) {
            sb.append(", servletName=");
            sb.append(servletNames[i]);
        }
        for (int i = 0; i < urlPatterns.length; i++) {
            sb.append(", urlPattern=");
            sb.append(urlPatterns[i]);
        }
        sb.append("]");
        return (sb.toString());