当前位置: 首页>>代码示例>>Java>>正文


Java AntPathMatcher.match方法代码示例

本文整理汇总了Java中org.springframework.util.AntPathMatcher.match方法的典型用法代码示例。如果您正苦于以下问题:Java AntPathMatcher.match方法的具体用法?Java AntPathMatcher.match怎么用?Java AntPathMatcher.match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.util.AntPathMatcher的用法示例。


在下文中一共展示了AntPathMatcher.match方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matchesPathPattern

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
public static boolean matchesPathPattern(String pattern) {
    String path = (String)RequestContextHolder.getRequestAttributes().getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
    // If They are both blank, then there is a default pattern
    if (StringUtils.isEmpty(path) && StringUtils.isEmpty(pattern)) {
        return true;
    }
    AntPathMatcher apm = new AntPathMatcher();
    return apm.match(pattern, path);
}
 
开发者ID:thunderbird,项目名称:pungwecms,代码行数:10,代码来源:Utils.java

示例2: testAntMatcher

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
@Test
public void testAntMatcher(){
	AntPathMatcher path = new AntPathMatcher();
	boolean rs = path.match("/user.*", "/user.json?aaa=bbb&cc=ddd");
	Assert.assertTrue(rs);
	//后缀的点号变成可选的写法?
	rs = path.match("/user.*", "/user");
	Assert.assertFalse(rs);
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:10,代码来源:UrlResourceInfoParserTest.java

示例3: getRoutingInfo

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
/**
 * getRoutingInfo: Returns the routing info for the given request and method.
 * @param requestUri
 * @param httpMethod
 * @return RoutingInfo The routing info for the matching route or <code>null</code> 
 * if no match was found.
 */
public RoutingInfo getRoutingInfo(String requestUri, String httpMethod) {

	// create a new path matcher instance.
	AntPathMatcher matcher = new AntPathMatcher();

	// define a map to hold parameter versions.
	Map<String, String> pathParams = null;

	// for each defined route
	for (IRoute route : _routes) {

		// extract the URI.
		String routeUri = route.getUri();

		// if the defined route uses the given http method and the URIs match
		if (httpMethod.equals(route.getHttpMethod()) && matcher.match(routeUri, requestUri)) {

			// extract the template parameters from the uri.
			pathParams = matcher.extractUriTemplateVariables(routeUri, requestUri);

			// define a new routing info object
			RoutingInfo routingInfo = new RoutingInfo();

			// set the values
			routingInfo.setRoute(route);
			routingInfo.setPathParameters(pathParams);

			// return the instance
			return routingInfo;
		}
	}

	// if we get here, no match.
	return null;
}
 
开发者ID:xtivia,项目名称:xsf,代码行数:43,代码来源:DefaultRouter.java

示例4: matchLatestByPattern

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
private VersionEntry matchLatestByPattern(List<VersionEntry> results, String version) {
    AntPathMatcher matcher = new AntPathMatcher();
    for (VersionEntry result : results) {
        if (matcher.match(version, result.getVersion())) {
            return result;
        }
    }
    return null;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:10,代码来源:ArtifactLatestVersionSearchResource.java

示例5: matchByPattern

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
private void matchByPattern(ArtifactVersionsResult artifactVersions, String version) {
    List<VersionEntry> filteredResults = Lists.newArrayList();
    AntPathMatcher matcher = new AntPathMatcher();
    for (VersionEntry result : artifactVersions.getResults()) {
        if (matcher.match(version, result.getVersion())) {
            filteredResults.add(result);
        }
    }

    artifactVersions.setResults(filteredResults);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:12,代码来源:ArtifactVersionsSearchResource.java

示例6: getInterceptors

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
public List<Interceptor> getInterceptors(String path, AntPathMatcher matcher) {
    List<Interceptor> interceptors = new ArrayList<Interceptor>();
    for (InterceptorConfigHolder.InterceptorConfig interceptorConfig : interceptorConfigs) {
        if (matcher.match(interceptorConfig.getPath(), path)) {
            interceptors.add(SpringContainer.getBean(interceptorConfig.getClazz()));
        }
    }
    return interceptors;
}
 
开发者ID:nullcodeexecutor,项目名称:rural,代码行数:10,代码来源:InterceptorConfigBean.java

示例7: listFilesAndDirsFromDirectory

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
protected List<FileInfo> listFilesAndDirsFromDirectory(String pattern, String fileSpecification,
        IDirectory resourceDirectory, AntPathMatcher pathMatcher) {        
    List<FileInfo> files = new ArrayList<FileInfo>();
    List<FileInfo> matchedFiles = new ArrayList<FileInfo>();
    files = resourceDirectory.listFiles(pattern);
    for (FileInfo file : files) {
        if (pathMatcher.match(fileSpecification, file.getName())) {
            matchedFiles.add(file);
        }
    }
    return matchedFiles;
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:13,代码来源:FilePoller.java

示例8: isBranchNotExcluded

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
private boolean isBranchNotExcluded(String branchName) {
    AntPathMatcher matcher = new AntPathMatcher();
    for (String excludePattern : excludedBranches) {
        if (matcher.match(excludePattern, branchName)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:10,代码来源:NameBasedFilter.java

示例9: isBranchIncluded

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
private boolean isBranchIncluded(String branchName) {
    AntPathMatcher matcher = new AntPathMatcher();
    for (String includePattern : includedBranches) {
        if (matcher.match(includePattern, branchName)) {
            return true;
        }
    }
    return includedBranches.isEmpty();
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:10,代码来源:NameBasedFilter.java

示例10: antTest

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
@Test
public void antTest() {
	AntPathMatcher antPathMatcher = new AntPathMatcher();
	String pattern = "/webjars/{webjar}/**/{partialPath:.+}";
	String path = "/webjars/boostrap/js/boostrap.js";
	boolean result = antPathMatcher.match(pattern, path);
	Assert.assertTrue(result);
}
 
开发者ID:momega,项目名称:spacesimulator,代码行数:9,代码来源:AntPathTester.java

示例11: testAntMatcher

import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
@Test
public void testAntMatcher(){
	AntPathMatcher req = new AntPathMatcher();
	boolean res = req.match("/user.*", "/user.json");
	Assert.assertTrue(res);
	

	res = req.match("/**/api/**", "/service/api/user");
	res = req.match("/**/api/**", "/api/user");
	res = req.match("/**/api/**", "/api/user/1");
	res = req.match("/**/api/**", "/api/user/1?aa=bb&cc=dd");
	Assert.assertTrue(res);

	res = req.match("*zh.*", "user_zh.html");
	Assert.assertTrue(res);
	res = req.match("*zh.*", "/user_zh.html");
	Assert.assertFalse(res);
	res = req.match("**zh.*", "user_zh.html");
	Assert.assertTrue(res);
	res = req.match("**zh.*", "/user_zh.html");
	Assert.assertFalse(res);
	res = req.match("**/*zh.*", "/user_zh.html");
	Assert.assertFalse(res);
	res = req.match("/*zh.*", "/user_zh.html");
	Assert.assertTrue(res);
	
	res = req.match("/user*", "/user");
	Assert.assertTrue(res);
	res = req.match("/user*", "/user.json");
	Assert.assertTrue(res);
	res = req.match("/user*", "/userInfo");
	Assert.assertTrue(res);
	res = req.match("/user*", "/user/1");
	Assert.assertFalse(res);

	res = req.match("/user**", "/user");
	Assert.assertTrue(res);
	res = req.match("/user**", "/user.json");
	Assert.assertTrue(res);
	res = req.match("/user**", "/userInfo");
	Assert.assertTrue(res);
	res = req.match("/user*/**", "/userInfo");
	Assert.assertTrue(res);
	res = req.match("/user*/**", "/user/1.json");
	Assert.assertTrue(res);

	res = req.match("/user/*", "/user/1");
	Assert.assertTrue(res);
	res = req.match("/user/*", "/user/1.json");
	Assert.assertTrue(res);
	res = req.match("/user/*", "/user/aaa/1.json");
	Assert.assertFalse(res);

	res = req.match("/user/**", "/user/1.json");
	Assert.assertTrue(res);
	res = req.match("/user/**", "/user/aaa/1.json");
	Assert.assertTrue(res);

	res = req.match("/service/swagger**", "/service/swagger-resources");
	Assert.assertTrue(res);

	res = req.match("/service/swagger**/**", "/service/swagger-resources/configuration");
	Assert.assertTrue(res);
	res = req.match("/service/swagger**/**", "/service/swagger-resources");
	Assert.assertTrue(res);
	res = req.match("/service/swagger**", "/service/swagger-resources/configuration/ui");
	Assert.assertFalse(res);
	
	res = req.match("/service/webjars/**/**", "/service/webjars/springfox-swagger-ui/css/typography.css");
	Assert.assertTrue(res);
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:72,代码来源:AntPathMatcherTest.java


注:本文中的org.springframework.util.AntPathMatcher.match方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。