本文整理了Java中jodd.util.Wildcard.match()
方法的一些代码示例,展示了Wildcard.match()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wildcard.match()
方法的具体详情如下:
包路径:jodd.util.Wildcard
类名称:Wildcard
方法名:match
[英]Checks whether a string matches a given wildcard pattern.
[中]检查字符串是否与给定的通配符模式匹配。
代码示例来源:origin: redisson/redisson
/**
* Checks whether a string matches a given wildcard pattern.
*
* @param string input string
* @param pattern pattern to match
* @return <code>true</code> if string matches the pattern, otherwise <code>false</code>
*/
public static boolean match(CharSequence string, CharSequence pattern) {
return match(string, pattern, 0, 0);
}
代码示例来源: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: redisson/redisson
/**
* Matches string to at least one pattern.
* Returns index of matched pattern, or <code>-1</code> otherwise.
* @see #match(CharSequence, CharSequence)
*/
public static int matchOne(String src, String[] patterns) {
for (int i = 0; i < patterns.length; i++) {
if (match(src, patterns[i])) {
return i;
}
}
return -1;
}
代码示例来源:origin: redisson/redisson
public boolean accept(String value, String rule, boolean include) {
return Wildcard.match(value, rule);
}
};
代码示例来源:origin: oblac/jodd
/**
* Matches string to at least one pattern.
* Returns index of matched pattern, or <code>-1</code> otherwise.
* @see #match(CharSequence, CharSequence)
*/
public static int matchOne(final String src, final String... patterns) {
for (int i = 0; i < patterns.length; i++) {
if (match(src, patterns[i])) {
return i;
}
}
return -1;
}
代码示例来源:origin: oblac/jodd
/**
* Checks whether a string matches a given wildcard pattern.
*
* @param string input string
* @param pattern pattern to match
* @return <code>true</code> if string matches the pattern, otherwise <code>false</code>
*/
public static boolean match(final CharSequence string, final CharSequence pattern) {
return match(string, pattern, 0, 0);
}
代码示例来源:origin: redisson/redisson
/**
* Checks if two strings are equals or if they {@link #match(CharSequence, CharSequence)}.
* Useful for cases when matching a lot of equal strings and speed is important.
*/
public static boolean equalsOrMatch(CharSequence string, CharSequence pattern) {
if (string.equals(pattern)) {
return true;
}
return match(string, pattern, 0, 0);
}
代码示例来源:origin: oblac/jodd
public static boolean validate(final Object value, final String pattern) {
if (value == null) {
return true;
}
return Wildcard.match(value.toString(), pattern);
}
代码示例来源:origin: oblac/jodd
/**
* Checks if two strings are equals or if they {@link #match(CharSequence, CharSequence)}.
* Useful for cases when matching a lot of equal strings and speed is important.
*/
public static boolean equalsOrMatch(final CharSequence string, final CharSequence pattern) {
if (string.equals(pattern)) {
return true;
}
return match(string, pattern, 0, 0);
}
代码示例来源:origin: oblac/jodd
/**
* Match class name to provided {@link jodd.util.Wildcard} pattern.
*/
default boolean matchClassName(final String wildcard) {
return Wildcard.match(getClassname(), wildcard);
}
代码示例来源:origin: oblac/jodd
/**
* Match method name to provided {@link jodd.util.Wildcard} pattern.
*/
default boolean matchMethodName(final String wildcard) {
return Wildcard.match(getMethodName(), wildcard);
}
代码示例来源:origin: oblac/jodd
@Override
public boolean accept(String propertyName, String pattern, boolean included) {
return Wildcard.match(propertyName, pattern);
}
};
代码示例来源:origin: redisson/redisson
break;
if (!match(tokens[tokNdxStart], patDir)) {
return false;
break;
if (!match(tokens[tokNdxEnd], patDir)) {
return false;
String subPat = patterns[patNdxStart + j + 1];
String subStr = tokens[tokNdxStart + i + j];
if (!match(subStr, subPat)) {
continue strLoop;
代码示例来源:origin: redisson/redisson
if (match(string, pattern, i, pNdx)) {
return true;
代码示例来源:origin: oblac/jodd
break;
if (!match(tokens[tokNdxStart], patDir)) {
return false;
break;
if (!match(tokens[tokNdxEnd], patDir)) {
return false;
String subPat = patterns[patNdxStart + j + 1];
String subStr = tokens[tokNdxStart + i + j];
if (!match(subStr, subPat)) {
continue strLoop;
代码示例来源:origin: oblac/jodd
if (match(string, pattern, i, pNdx)) {
return true;
代码示例来源:origin: oblac/jodd
@Test
void testMatchWildcard() {
assertTrue(Wildcard.match("app.nfo", "app*"));
assertFalse(Wildcard.match("\\app.nfo", "app*"));
assertTrue(Wildcard.match("\\app.nfo", "\\\\app*"));
}
代码示例来源:origin: oblac/jodd
/**
* Only match() has escaped wildcards; matchPath() does not have them
* as escape character is equal to one of the path characters..
*/
@Test
void testMatchEscapedWildcards() {
assertFalse(Wildcard.match("CfgOptions.class", "*gOpti\\*c?ass"));
assertTrue(Wildcard.match("CfgOpti*class", "*gOpti\\*class"));
assertTrue(Wildcard.match("CfgOpti*class", "*gOpti\\*c?ass"));
assertFalse(Wildcard.match("CfgOpti*class", "*gOpti\\\\*c?ass"));
assertTrue(Wildcard.match("CfgOpti\\*class", "*gOpti\\\\*c?ass"));
assertTrue(Wildcard.match("CfgOpti?class", "*gOpti\\?c*ass"));
assertFalse(Wildcard.match("CfgOpti\\?class", "*gOpti\\?c*ass"));
assertTrue(Wildcard.match("CfgOptions.class", "CfgOpti\\ons.class"));
assertTrue(Wildcard.match("What's this?", "What*\\?"));
}
代码示例来源:origin: oblac/jodd
@Test
void testMatch() {
assertTrue(Wildcard.match("CfgOptions.class", "C*class"));
assertFalse(Wildcard.match("CfgOptions.class", "C*clas"));
assertFalse(Wildcard.match("C*r*class", "CfgOptions.class"));
assertTrue(Wildcard.match("CfgOptions.class", "*g*class"));
assertTrue(Wildcard.match("CfgOptions.class", "*C*g*class"));
assertTrue(Wildcard.match("CfgOptions.class", "C*g*cl*"));
assertTrue(Wildcard.match("CfgOptions.class", "*C*g*cl*"));
assertTrue(Wildcard.match("CfgOptions.class", "*g*c**ss"));
assertTrue(Wildcard.match("CfgOptions.class", "*g*c**s")); // THIS IS TRUE!!!
assertTrue(Wildcard.match("CfgOptions.class", "*gOpti******ons.c**ss"));
assertTrue(Wildcard.match("CfgOptions.class", "***gOpti*ons.c**ss"));
assertTrue(Wildcard.match("CfgOptions.class", "***gOptions.c**"));
assertTrue(Wildcard.match("CfgOptions.class", "*gOpti*c?ass"));
assertFalse(Wildcard.match("CfgOptions.class", "*gOpti*c?ss"));
assertTrue(Wildcard.match("CfgOptions.class", "*gOpti*c?as?"));
assertFalse(Wildcard.match("CfgOptions.class", "*gOpti*c?a?"));
assertTrue(Wildcard.match("CfgOptions.class", "?fgOpti*c?ass"));
assertFalse(Wildcard.match("CfgOptions.class", "?gOpti*c?as?"));
assertTrue(Wildcard.match("CfgOptions.class", "??gOpti*c?ass"));
assertTrue(Wildcard.match("CfgOptions.class", "C????ti*c?ass"));
assertFalse(Wildcard.match("CfgOptions.class", "C???ti*c?ass"));
assertTrue(Wildcard.match("CfgOptions.class", "C??*ti*c?ass"));
代码示例来源:origin: oblac/jodd
if (Wildcard.match(propertyTypeName, excludedTypeName)) {
return false;
内容来源于网络,如有侵权,请联系作者删除!