private function matchFiltersURL(\Serphlet\Config\FilterMap $filterMap, $requestPath, $caseSensitiveMapping = true)
 {
     if ($requestPath == null) {
         return false;
     }
     // Match on context relative request path
     $testPath = $filterMap->getURLPattern();
     if ($testPath == null) {
         return false;
     }
     if (!$caseSensitiveMapping) {
         $requestPath = strtolower($requestPath);
         $testPath = strtolower($testPath);
     }
     // Case 1 - Exact Match
     if ($testPath == $requestPath) {
         return true;
     }
     // Case 2 - Path Match ("/.../*")
     if ($testPath == '/*') {
         return true;
     }
     if (preg_match('/\\/\\*$/', $testPath)) {
         if (substr($testPath, 0, strlen($testPath) - 2) == substr($requestPath, 0, strlen($testPath) - 2)) {
             if (strlen($requestPath) == strlen($testPath) - 2) {
                 return true;
             } elseif ('/' == substr($requestPath, strlen($testPath) - 2, 1)) {
                 return true;
             }
         }
         return false;
     }
     // Case 3 - Extension Match
     if (preg_match('/^\\*\\./', $testPath)) {
         $slash = strrpos($requestPath, '/');
         $period = strrpos($requestPath, '.');
         if ($slash >= 0 && $period > $slash && $period != strlen($requestPath) - 1 && strlen($requestPath) - $period == strlen($testPath) - 1) {
             return substr($testPath, 2) == substr($requestPath, $period);
         }
     }
     // Case 4 - "Default" Match
     return false;
     // NOTE - Not relevant for selecting filters
 }
 /**
  * Add a filter mapping to this Context->
  *
  * @param filterMap The filter mapping to be added
  *
  * @exception \Serphlet\Exception\IllegalArgumentException if the specified filter name
  *  does not match an existing filter definition, or the filter mapping
  *  is malformed
  * @todo: Lookup the error message
  */
 public function addFilterMap(\Serphlet\Config\FilterMap $filterMap)
 {
     // Validate the proposed filter mapping
     $filterName = $filterMap->getFilterName();
     $servletName = $filterMap->getServletName();
     $urlPattern = $filterMap->getURLPattern();
     if ($this->findFilterDef($filterName) == null) {
         throw new \Serphlet\Exception\IllegalArgumentException("applicationConfig->filterMap->name not found");
     }
     if ($servletName == null && $urlPattern == null) {
         throw new \Serphlet\Exception\IllegalArgumentException("applicationConfig->filterMap->either specify servlet name or url filter");
     }
     if ($servletName != null && $urlPattern != null) {
         throw new \Serphlet\Exception\IllegalArgumentException("applicationConfig->filterMap->either specify only a servlet name or url filter");
     }
     if ($urlPattern != null && !$this->validateURLPattern($urlPattern)) {
         throw new \Serphlet\Exception\IllegalArgumentException("applicationConfig->filterMap->pattern url pattern not valid");
     }
     // Add this filter mapping to our registered set
     $this->filterMaps[] = $filterMap;
 }