/*
(non-Javadoc)

@see net.jawr.web.resource.bundle.generator.matcher.
ResourceGeneratorPathMatcher#matchPath(java.lang.String)
513103
@Override
	public boolean matchPath(String path) {

		boolean match = false;
		if (StringUtils.isNotEmpty(path)) {
			match = path.endsWith(suffix);
		}
		return match;
	}
722579
protected void scanResourcePaths(String startPath) throws IOException, SAXException {

        Set<String> dirList = context.getResourcePaths(startPath);
        if (dirList != null) {
            for (String path : dirList) {
                if (path.startsWith("/WEB-INF/classes/")) {
                    // Skip: JSP.7.3.1
                } else if (path.startsWith("/WEB-INF/lib/")) {
                    // Skip: JSP.7.3.1
                } else if (path.endsWith("/")) {
                    scanResourcePaths(path);
                } else if (path.startsWith("/WEB-INF/tags/")) {
                    // JSP 7.3.1: in /WEB-INF/tags only consider implicit.tld
                    if (path.endsWith("/implicit.tld")) {
                        parseTld(path);
                    }
                } else if (path.endsWith(TLD_EXT)) {
                    parseTld(path);
                }
            }
        }
    }
470668
@Override
	public String getFilePath(String resourcePath) {

		String filePath = null;
		String path = getCompletePath(resourcePath);
		URL url = null;
		try {
			url = ClassLoaderResourceUtils.getResourceURL(path, this);
			String strURL = url.toString();
			if (strURL.startsWith(JawrConstant.FILE_URL_PREFIX)) {
				filePath = new File(url.getFile()).getAbsolutePath();
			} else if (strURL.startsWith(JawrConstant.JAR_URL_PREFIX + JawrConstant.FILE_URL_PREFIX)) {
				String tmp = strURL.substring((JawrConstant.JAR_URL_PREFIX + JawrConstant.FILE_URL_PREFIX).length());
				int idxJarContentSeparator = tmp.indexOf("!");
				if (idxJarContentSeparator != -1) {
					tmp = tmp.substring(0, idxJarContentSeparator);
				}
				filePath = new File(tmp).getAbsolutePath();
			}
		} catch (ResourceNotFoundException e) {
			filePath = null;
		}

		return filePath;
	}
1009770
public boolean match(String accessPath) {
        if (extension != null) {
            for (int i = accessPath.length() - 1; i >= 0; i--) {
                if (accessPath.charAt(i) == '.') {
                    String ext = accessPath.substring(i + 1);
                    if (extension.equals(ext)) {
                        return true;
                    }
                    break;
                }
            }
        }
        if (accessPath.equals(path)) {
            return true;
        }
        if (prefix != null && accessPath.startsWith(prefix)) {
            return true;
        }
        return false;
    }
774921
private String getCompletePath(String resourcePath) {
		String path = PathNormalizer.normalizePath(classpathPrefix + resourcePath);
		return path;
	}
873148
public static boolean isPluginResoucePath(String resourcePath) {

		Matcher matcher = PLUGIN_RESOURCE_PATTERN.matcher(resourcePath);
		return matcher.find();
	}
603705
public static String getStaticResourcePathForResource(Resource resource, String contextPath) {

        if (contextPath == null) contextPath = "";
        if (resource == null) return contextPath;

        String url;
        try {
            url = resource.getURL().toString();
        }
        catch (IOException e) {
            return contextPath;
        }

        Matcher m = PLUGIN_RESOURCE_PATTERN.matcher(url);
        if (m.find()) {
            return (contextPath.length() > 0 ? contextPath + "/" : "") + m.group(1);
        }

        return contextPath;
    }
1240823
@Override
  public boolean ruleFileExists(String path) {
    String completePath = getCompleteRulesUrl(path);
    return ResourceDataBroker.class.getResource(completePath) != null;
  }
875699
public static boolean isPathNameMatch(String uri, String urlPattern) {
        if (urlPattern.startsWith("/") && urlPattern.endsWith("/*")) {
            String s = urlPattern.substring(0, urlPattern.length() - 1);
            /**
             * First case,urlPattern
             * /a/b/c/ matches /a/b/c/*
             **/
            if (s.equalsIgnoreCase(uri)) {
                return true;
            }
            /**
             * Second case
             * /a/b/c matches /a/b/c/*
             **/
            if (uri.equalsIgnoreCase(s.substring(0, s.length() - 1))) {
                return true;
            }

            /**
             * Third case
             * /a/b/c/d/e matches /a/b/c/*
             **/
            if (uri.startsWith(s)) {
                return true;
            }
        }

        return false;
    }
865818
public Map.Entry getMatch(String path)
    {
        Map.Entry entry;

        if (path==null)
            return null;
        
        int l=path.indexOf(';');
        if (l<0)
        {
            l=path.indexOf('?');
            if (l<0)
                l=path.length();
        }

        // try exact match
        entry=_exactMap.getEntry(path,0,l);
        if (entry!=null)
            return (Map.Entry) entry.getValue();
        
        // prefix search
        int i=l;
        while((i=path.lastIndexOf('/',i-1))>=0)
        {
            entry=_prefixMap.getEntry(path,0,i);
            if (entry!=null)
                return (Map.Entry) entry.getValue();
        }
        
        // Prefix Default
        if (_prefixDefault!=null)
            return _prefixDefault;
        
        // Extension search
        i=0;
        while ((i=path.indexOf('.',i+1))>0)
        {
            entry=_suffixMap.getEntry(path,i+1,l-i-1);
            if (entry!=null)
                return (Map.Entry) entry.getValue();
        }        
        
        // Default
        return _default;
    }
108152
public boolean isMatch(PathImpl path, String prefix)
  {
    String suffix = "";
    String fullPath = path.getPath();
    
    if (prefix.length() < fullPath.length()) {
      suffix = fullPath.substring(prefix.length());
    }

    for (int i = 0; i < _excludeList.size(); i++) {
      PathPatternType pattern = _excludeList.get(i);

      if (pattern.isMatch(suffix))
        return false;
    }

    if (_includeList == null)
      return true;
    
    for (int i = 0; i < _includeList.size(); i++) {
      PathPatternType pattern = _includeList.get(i);

      if (pattern.isMatch(suffix)) {
        return true;
      }
    }

    return false;
  }
1249593
public Map<String, String> findMatches(String incoming) {
        String[] pieces = incoming.split(PATH_SEPARATOR);
        int i = 0;

        //too many matchers, short circuit
        if (path.size() > pieces.length)
            return null;

        Map<String, String> values = new HashMap<String, String>();
        for (PathMatcher pathMatcher : path) {

            //sanity to prevent fencepost
            if (i == pieces.length)
                return pathMatcher.matches("") ? values : null;   //go greedy on index paths

            String piece = pieces[i];

            if (!pathMatcher.matches(piece))
                return null;

            //store variable as needed
            final String name = pathMatcher.name();
            if (null != name)
                values.put(name, piece);

            //next piece
            i++;
        }

        return (i == pieces.length) ? values : null;
    }
86446
@Override
  public boolean resourceExists(String path) {
    String completePath = getCompleteResourceUrl(path);
    return ResourceDataBroker.class.getResource(completePath) != null;
  }
1208004
private Route matchStandard(String uri, ControllerPath controllerPathObject, AppController controller, HttpMethod method) {

        String controllerPath = (controllerPathObject.getControllerPackage() != null ? "/" + controllerPathObject.getControllerPackage().replace(".", "/") : "") + "/" + controllerPathObject.getControllerName();
        String theUri = uri.endsWith("/") ? uri.substring(0, uri.length() - 1) : uri;

        //ANY    /package_suffix/controller
        if (controllerPath.length() == theUri.length()) {
            return new Route(controller, "index", method);
        }

        String[] parts;
        try {
            String tail = theUri.substring(controllerPath.length() + 1);
            parts = split(tail, "/");
        } catch (Exception e) {
            throw new RouteException("Failed to parse route from: '" + uri + "'", e);
        }


        //ANY    /package_suffix/controller/action
        if (parts.length == 1) {
            return new Route(controller, parts[0], method);
        }

        //ANY    /package_suffix/controller/action/id/
        if (parts.length == 2) {
            return new Route(controller, parts[0], parts[1], method);
        }
        LOGGER.warn("Failed to find action for request: " + uri);
        return null;
    }
1269603
@Override
   public String getTrimmedPath(String path)
   {
      if (path == null)
      {
         return "/";
      }
      if (!path.startsWith("/"))
      {
         try
         {
            path = new URL(path).getPath();
         }
         catch (MalformedURLException ex)
         {
            // ignore
            Logger.getLogger(JBossWSDestinationRegistryImpl.class).trace(ex);
         }
         if (!path.startsWith("/")) {
            path = "/" + path;
         }
      }
      return path;
   }
656657
static String root(final ResourcePath path) {
        if (path.getDepth() == 1)
            return path.getResourcePath();
        throw new JaxRxException(404, "Resource not found: " + path);
    }
427850
private String asPath(String path, boolean generatedResource) {

		String result = path;
		if (!generatedResource) {
			result = PathNormalizer.asPath(path);
		}
		return result;
	}