本文整理了Java中jodd.util.Wildcard.matchOne()
方法的一些代码示例,展示了Wildcard.matchOne()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wildcard.matchOne()
方法的具体详情如下:
包路径:jodd.util.Wildcard
类名称:Wildcard
方法名:matchOne
[英]Matches string to at least one pattern. Returns index of matched pattern, or -1
otherwise.
[中]将字符串与至少一种模式匹配。返回匹配模式的索引,否则返回-1
。
代码示例来源:origin: redisson/redisson
/**
* Accepts if a file is going to be watched.
*/
protected boolean acceptFile(File file) {
if (!file.isFile()) {
return false; // ignore non-files
}
String fileName = file.getName();
if (ignoreDotFiles) {
if (fileName.startsWith(StringPool.DOT)) {
return false; // ignore hidden files
}
}
if (patterns == null) {
return true;
}
return Wildcard.matchOne(fileName, patterns) != -1;
}
代码示例来源:origin: oblac/jodd
/**
* Accepts if a file is going to be watched.
*/
protected boolean acceptFile(final File file) {
if (!file.isFile()) {
return false; // ignore non-files
}
String fileName = file.getName();
if (ignoreDotFiles) {
if (fileName.startsWith(StringPool.DOT)) {
return false; // ignore hidden files
}
}
if (patterns == null) {
return true;
}
return Wildcard.matchOne(fileName, patterns) != -1;
}
代码示例来源:origin: redisson/redisson
Wildcard.matchOne(entryMimeType, mimeTypes) :
StringUtil.equalsOne(entryMimeType, mimeTypes);
代码示例来源:origin: oblac/jodd
@SuppressWarnings("unchecked")
protected void extractMap(
final Map target,
final Map<String, PropsEntry> map,
final String[] profiles,
final String[] wildcardPatterns,
final String prefix
) {
for (Map.Entry<String, PropsEntry> entry : map.entrySet()) {
String key = entry.getKey();
if (wildcardPatterns != null) {
if (Wildcard.matchOne(key, wildcardPatterns) == -1) {
continue;
}
}
// shorten the key
if (prefix != null) {
if (!key.startsWith(prefix)) {
continue;
}
key = key.substring(prefix.length());
}
// only append if target DOES NOT contain the key
if (!target.containsKey(key)) {
target.put(key, entry.getValue().getValue(profiles));
}
}
}
代码示例来源:origin: oblac/jodd
/**
* Finds all extensions that belong to given mime type(s).
* If wildcard mode is on, provided mime type is wildcard pattern.
* @param mimeType list of mime types, separated by comma
* @param useWildcard if set, mime types are wildcard patterns
*/
public static String[] findExtensionsByMimeTypes(String mimeType, final boolean useWildcard) {
final ArrayList<String> extensions = new ArrayList<>();
mimeType = mimeType.toLowerCase();
final String[] mimeTypes = StringUtil.splitc(mimeType, ", ");
for (final Map.Entry<String, String> entry : MIME_TYPE_MAP.entrySet()) {
final String entryExtension = entry.getKey();
final String entryMimeType = entry.getValue().toLowerCase();
final int matchResult = useWildcard ?
Wildcard.matchOne(entryMimeType, mimeTypes) :
StringUtil.equalsOne(entryMimeType, mimeTypes);
if (matchResult != -1) {
extensions.add(entryExtension);
}
}
if (extensions.isEmpty()) {
return StringPool.EMPTY_ARRAY;
}
return extensions.toArray(new String[0]);
}
代码示例来源:origin: org.jodd/jodd-core
/**
* Accepts if a file is going to be watched.
*/
protected boolean acceptFile(final File file) {
if (!file.isFile()) {
return false; // ignore non-files
}
String fileName = file.getName();
if (ignoreDotFiles) {
if (fileName.startsWith(StringPool.DOT)) {
return false; // ignore hidden files
}
}
if (patterns == null) {
return true;
}
return Wildcard.matchOne(fileName, patterns) != -1;
}
代码示例来源:origin: org.jodd/jodd-props
@SuppressWarnings("unchecked")
protected void extractMap(
final Map target,
final Map<String, PropsEntry> map,
final String[] profiles,
final String[] wildcardPatterns,
final String prefix
) {
for (Map.Entry<String, PropsEntry> entry : map.entrySet()) {
String key = entry.getKey();
if (wildcardPatterns != null) {
if (Wildcard.matchOne(key, wildcardPatterns) == -1) {
continue;
}
}
// shorten the key
if (prefix != null) {
if (!key.startsWith(prefix)) {
continue;
}
key = key.substring(prefix.length());
}
// only append if target DOES NOT contain the key
if (!target.containsKey(key)) {
target.put(key, entry.getValue().getValue(profiles));
}
}
}
代码示例来源:origin: org.jodd/jodd-core
/**
* Finds all extensions that belong to given mime type(s).
* If wildcard mode is on, provided mime type is wildcard pattern.
* @param mimeType list of mime types, separated by comma
* @param useWildcard if set, mime types are wildcard patterns
*/
public static String[] findExtensionsByMimeTypes(String mimeType, final boolean useWildcard) {
final ArrayList<String> extensions = new ArrayList<>();
mimeType = mimeType.toLowerCase();
final String[] mimeTypes = StringUtil.splitc(mimeType, ", ");
for (final Map.Entry<String, String> entry : MIME_TYPE_MAP.entrySet()) {
final String entryExtension = entry.getKey();
final String entryMimeType = entry.getValue().toLowerCase();
final int matchResult = useWildcard ?
Wildcard.matchOne(entryMimeType, mimeTypes) :
StringUtil.equalsOne(entryMimeType, mimeTypes);
if (matchResult != -1) {
extensions.add(entryExtension);
}
}
if (extensions.isEmpty()) {
return StringPool.EMPTY_ARRAY;
}
return extensions.toArray(new String[0]);
}
内容来源于网络,如有侵权,请联系作者删除!