Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 
 package org.apache.catalina.deploy;
 
 
 
 
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(s):
Craig R. McClanahan
Version:
$Revision: 1473 $ $Date: 2010-05-17 19:46:58 +0200 (Mon, 17 May 2010) $
 
 
 public class FilterMap implements Serializable {
 
 
     // ------------------------------------------------------------- Properties
 

    
The name of this filter to be executed when this mapping matches a particular request.
 
     
     public static final int ERROR = 1;
     public static final int FORWARD = 2;
     public static final int INCLUDE = 4;
     public static final int REQUEST = 8;
     public static final int ASYNC = 16;
     
     // represents nothing having been set. This will be seen 
     // as equal to a REQUEST
     private static final int NOT_SET = 0;
     
     private int dispatcherMapping = ;
     
     private String filterName = null;    
 
     public String getFilterName() {
         return (this.);
     }
 
     public void setFilterName(String filterName) {
         this. = filterName;
     }


    
The servlet name this mapping matches.
 
     private String[] servletNames = new String[0];
 
     public String[] getServletNames() {
         return (this.);
     }
 
     public void addServletName(String servletName) {
         if ("*".equals(servletName)) {
             this. = true;
         } else {
             String[] results = new String[. + 1];
             System.arraycopy(, 0, results, 0, .);
             results[.] = servletName;
              = results;
         }
     }

    
    
The flag that indicates this mapping will match all url-patterns
 
     private boolean matchAllUrlPatterns = false;
     
    public boolean getMatchAllUrlPatterns() {
        return ;
    }
    

    
The flag that indicates this mapping will match all servlet-names
    private boolean matchAllServletNames = false;
    
    public boolean getMatchAllServletNames() {
        return ;
    }

    
    
The URL pattern this mapping matches.
    private String[] urlPatterns = new String[0];
    public String[] getURLPatterns() {
        return (this.);
    }
    public void addURLPattern(String urlPattern) {
        if ("*".equals(urlPattern)) {
            this. = true;
        } else {
            String[] results = new String[. + 1];
            System.arraycopy(, 0, results, 0, .);
            results[.] = RequestUtil.URLDecode(urlPattern);
             = results;
        }
    }
    
    
This method will be used to set the current state of the FilterMap representing the state of when filters should be applied.
    public void setDispatcher(String dispatcherString) {
        String dispatcher = dispatcherString.toUpperCase(.);
        
        if (dispatcher.equals(..name())) {
            // apply FORWARD to the global dispatcherMapping.
             |= ;
        } else if (dispatcher.equals(..name())) {
            // apply INCLUDE to the global dispatcherMapping.
             |= ;
        } else if (dispatcher.equals(..name())) {
            // apply REQUEST to the global dispatcherMapping.
             |= ;
        }  else if (dispatcher.equals(..name())) {
            // apply ERROR to the global dispatcherMapping.
             |= ;
        }  else if (dispatcher.equals(..name())) {
            // apply ASYNC to the global dispatcherMapping.
             |= ;
        }
    }
    
    public int getDispatcherMapping() {
        // per the SRV.6.2.5 absence of any dispatcher elements is
        // equivelant to a REQUEST value
        if ( == )
            return ;
        else
            return 
    }
    // --------------------------------------------------------- Public Methods


    
Render a String representation of this object.
    public String toString() {
        StringBuilder sb = new StringBuilder("FilterMap[");
        sb.append("filterName=");
        sb.append(this.);
        for (int i = 0; i < .i++) {
            sb.append(", servletName=");
            sb.append([i]);
        }
        for (int i = 0; i < .i++) {
            sb.append(", urlPattern=");
            sb.append([i]);
        }
        sb.append("]");
        return (sb.toString());
    }
New to GrepCode? Check out our FAQ X