本文整理了Java中jodd.util.Wildcard.matchPath()
方法的一些代码示例,展示了Wildcard.matchPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wildcard.matchPath()
方法的具体详情如下:
包路径:jodd.util.Wildcard
类名称:Wildcard
方法名:matchPath
[英]Matches path against pattern using , ? and ** wildcards. Both path and the pattern are tokenized on path separators (both \ and /). '**' represents deep tree wildcard, as in Ant.
[中]使用,?将路径与模式匹配?和通配符。路径和模式都在路径分隔符(都是\和/)上标记化。“”表示深树通配符,如在Ant中。
代码示例来源:origin: redisson/redisson
public boolean accept(String value, String rule, boolean include) {
return Wildcard.matchPath(value, rule);
}
};
代码示例来源:origin: redisson/redisson
/**
* Matches path to at least one pattern.
* Returns index of matched pattern or <code>-1</code> otherwise.
* @see #matchPath(String, String)
*/
public static int matchPathOne(String path, String[] patterns) {
for (int i = 0; i < patterns.length; i++) {
if (matchPath(path, patterns[i])) {
return i;
}
}
return -1;
}
代码示例来源:origin: oblac/jodd
/**
* Matches path to at least one pattern.
* Returns index of matched pattern or <code>-1</code> otherwise.
* @see #matchPath(String, String)
*/
public static int matchPathOne(final String path, final String... patterns) {
for (int i = 0; i < patterns.length; i++) {
if (matchPath(path, patterns[i])) {
return i;
}
}
return -1;
}
代码示例来源:origin: oblac/jodd
@Override
protected boolean matchValue(final int macroIndex, final String value) {
return Wildcard.matchPath(value, patterns[macroIndex]);
}
}
代码示例来源:origin: oblac/jodd
public static boolean validate(final Object value, final String pattern) {
if (value == null) {
return true;
}
return Wildcard.matchPath(value.toString(), pattern);
}
代码示例来源:origin: oblac/jodd
@Test
void testMore() {
assertTrue(Wildcard.matchPath("/a/b/c/d", "**/b/**"));
assertTrue(Wildcard.matchPath("/a/b/c", "**/b/**"));
assertTrue(Wildcard.matchPath("/a/b/c/d", "**/c/**"));
}
}
代码示例来源:origin: oblac/jodd
@Test
void testMatchPath2() {
assertTrue(Wildcard.matchPath("/foo", "/fo*"));
assertTrue(Wildcard.matchPath("/foo", "/**"));
assertTrue(Wildcard.matchPath("/foo", "**"));
assertFalse(Wildcard.matchPath("/foo", "**/"));
assertFalse(Wildcard.matchPath("/foo", "/**/"));
assertTrue(Wildcard.matchPath("/foo/", "/**/"));
assertTrue(Wildcard.matchPath("/foo/boo", "/**/bo*"));
assertTrue(Wildcard.matchPath("/foo/soo/doo/boo", "/**/bo*"));
assertTrue(Wildcard.matchPath("/foo/boo", "/**/**/bo*"));
assertTrue(Wildcard.matchPath("/foo/one/two/three/boo", "/**/**/bo*"));
assertTrue(Wildcard.matchPath("/foo/one/two/three/boo", "/**/**/**/bo*"));
assertTrue(Wildcard.matchPath("/foo/one/two/three/boo", "/**/one/**"));
assertTrue(Wildcard.matchPath("/foo/one/two/three/boo", "/**/two/**"));
assertTrue(Wildcard.matchPath("/foo/one/two/three/boo", "**/two/**"));
assertTrue(Wildcard.matchPath("/foo/one/two/three/boo", "**/t?o/**"));
assertTrue(Wildcard.matchPath("sys/java/bin", "sys/**/bin"));
assertTrue(Wildcard.matchPath("sys/java/bin", "?ys/**/bin"));
assertTrue(Wildcard.matchPath("c:\\Users\\najgor", "?:\\**\\najgor"));
assertTrue(Wildcard.matchPath("c:\\najgor", "?:\\**\\naj**r"));
}
代码示例来源:origin: oblac/jodd
@Test
void testMatchPath1() {
assertTrue(Wildcard.matchPath("CfgOptions.class", "C*class"));
assertFalse(Wildcard.matchPath("CfgOptions.class", "C*clas"));
assertFalse(Wildcard.matchPath("C*r*class", "CfgOptions.class"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "*g*class"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "*C*g*class"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "C*g*cl*"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "*C*g*cl*"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "*g*c**ss"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "*g*c**s")); // THIS IS TRUE!!!
assertTrue(Wildcard.matchPath("CfgOptions.class", "*gOpti******ons.c**ss"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "***gOpti*ons.c**ss"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "***gOptions.c**"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "*gOpti*c?ass"));
assertFalse(Wildcard.matchPath("CfgOptions.class", "*gOpti*c?ss"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "*gOpti*c?as?"));
assertFalse(Wildcard.matchPath("CfgOptions.class", "*gOpti*c?a?"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "?fgOpti*c?ass"));
assertFalse(Wildcard.matchPath("CfgOptions.class", "?gOpti*c?as?"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "??gOpti*c?ass"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "C????ti*c?ass"));
assertFalse(Wildcard.matchPath("CfgOptions.class", "C???ti*c?ass"));
assertTrue(Wildcard.matchPath("CfgOptions.class", "C??*ti*c?ass"));
代码示例来源:origin: oblac/jodd
@Test
void testDifferences() {
assertTrue(Wildcard.match("/uphea", "*/uphea*"));
assertTrue(Wildcard.match("/prj/uphea-app.jar", "*/uphea*"));
assertTrue(Wildcard.matchPath("/uphea", "*/uphea*"));
assertTrue(Wildcard.matchPath("prj/uphea", "*/uphea*"));
assertFalse(Wildcard.matchPath("/prj/uphea-app.jar", "*/uphea*"));
assertTrue(Wildcard.matchPath("/prj/uphea-app.jar", "**/uphea*"));
assertTrue(Wildcard.match("/some/path/lib-jodd-v1", "*jodd*"));
assertTrue(Wildcard.matchPath("/some/path/lib-jodd-v1", "**/*jodd*"));
assertTrue(Wildcard.match("/some/path/lib-jodd-v1", "*/path/lib-jodd*"));
assertTrue(Wildcard.matchPath("/some/path/lib-jodd-v1", "**/path/lib-jodd*"));
assertTrue(Wildcard.match("/some/path/lib-jodd-v1", "*/lib-jodd*"));
assertTrue(Wildcard.matchPath("/some/path/lib-jodd-v1", "**/lib-jodd*"));
}
代码示例来源:origin: fivesmallq/web-data-extractor
/**
* Matches path to at least one pattern.
* Returns index of matched pattern or <code>-1</code> otherwise.
*
* @see #matchPath(String, String)
*/
public static int matchPathOne(String path, String[] patterns) {
for (int i = 0; i < patterns.length; i++) {
if (matchPath(path, patterns[i]) == true) {
return i;
}
}
return -1;
}
代码示例来源:origin: org.jodd/jodd-core
/**
* Matches path to at least one pattern.
* Returns index of matched pattern or <code>-1</code> otherwise.
* @see #matchPath(String, String)
*/
public static int matchPathOne(final String path, final String... patterns) {
for (int i = 0; i < patterns.length; i++) {
if (matchPath(path, patterns[i])) {
return i;
}
}
return -1;
}
代码示例来源:origin: fivesmallq/web-data-extractor
public boolean accept(String value, String rule, boolean include) {
return Wildcard.matchPath(value, rule);
}
};
代码示例来源:origin: org.jodd/jodd-wot
public static boolean validate(Object value, String pattern) {
if (value == null) {
return true;
}
return Wildcard.matchPath(value.toString(), pattern);
}
内容来源于网络,如有侵权,请联系作者删除!