本文整理汇总了Java中java.nio.file.FileSystem.getPathMatcher方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystem.getPathMatcher方法的具体用法?Java FileSystem.getPathMatcher怎么用?Java FileSystem.getPathMatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.file.FileSystem
的用法示例。
在下文中一共展示了FileSystem.getPathMatcher方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import java.nio.file.FileSystem; //导入方法依赖的package包/类
private void handleMessage(CtrlRequest payload) throws JsonProcessingException {
RouteMessage message = new RouteMessage(
payload.getData(), payload.getCorrelationId(), topologyName);
List<Object> packedMessage = message.pack();
String glob = payload.getRoute();
if (Strings.isNullOrEmpty(glob)) {
glob = "**";
} else if (glob.equals("*")) {
glob = "**";
}
FileSystem fs = FileSystems.getDefault();
PathMatcher matcher = fs.getPathMatcher("glob:" + glob);
for (String bolt : endpoints.keySet()) {
Path route = fs.getPath(topologyName, bolt);
if (! matcher.matches(route)) {
continue;
}
getOutputCollector().emit(
endpoints.get(bolt), getTuple(), packedMessage);
}
}
示例2: addPattern
import java.nio.file.FileSystem; //导入方法依赖的package包/类
private static void addPattern(final String fileNameGlobPattern, final List<PathMatcher> matchers) {
if (fileNameGlobPattern.contains("/")) {
throw new IllegalArgumentException("cannot contain '/'");
}
final FileSystem fs = FileSystems.getDefault();
final PathMatcher matcher = fs.getPathMatcher(GLOB_SYNTAX + fileNameGlobPattern);
matchers.add(matcher);
}
示例3: include
import java.nio.file.FileSystem; //导入方法依赖的package包/类
public void include(final String osNameGlobPattern) {
if (osNameGlobPattern.contains("/")) {
throw new IllegalArgumentException("OS name pattern cannot contain '/'");
}
final FileSystem fs = FileSystems.getDefault();
final PathMatcher includeOsNames = fs.getPathMatcher(GLOB_SYNTAX + osNameGlobPattern);
included.add(includeOsNames);
}
示例4: getPathMatcher
import java.nio.file.FileSystem; //导入方法依赖的package包/类
public static PathMatcher getPathMatcher(FileSystem fs, String pattern) {
if (!pattern.startsWith("glob:") && !pattern.startsWith("regex:")) {
pattern = "glob:" + pattern;
}
return fs.getPathMatcher(pattern);
}
示例5: testGlobPathMatcher
import java.nio.file.FileSystem; //导入方法依赖的package包/类
@Test(dataProvider = "pathGlobPatterns")
public void testGlobPathMatcher(String pattern, String path,
boolean expectMatch) throws Exception {
FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
PathMatcher pm = fs.getPathMatcher("glob:" + pattern);
Path p = fs.getPath(path);
assertTrue(Files.exists(p), path);
assertTrue(!(pm.matches(p) ^ expectMatch),
p + (expectMatch? " should match " : " should not match ") +
pattern);
}
示例6: testRegexPathMatcher
import java.nio.file.FileSystem; //导入方法依赖的package包/类
@Test(dataProvider = "pathRegexPatterns")
public void testRegexPathMatcher(String pattern, String path,
boolean expectMatch) throws Exception {
FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
PathMatcher pm = fs.getPathMatcher("regex:" + pattern);
Path p = fs.getPath(path);
assertTrue(Files.exists(p), path);
assertTrue(!(pm.matches(p) ^ expectMatch),
p + (expectMatch? " should match " : " should not match ") +
pattern);
}
示例7: GlobPathSet
import java.nio.file.FileSystem; //导入方法依赖的package包/类
public GlobPathSet(final String rootPathString, final String pattern, final FileTreeWalker fileTreeWalker, final FileSystem fileSystem) {
this.rootPath = fileSystem.getPath(checkNotNull(rootPathString)).toAbsolutePath();
this.pattern = pattern;
this.fileTreeWalker = fileTreeWalker;
this.matcher = fileSystem.getPathMatcher(buildGlobPattern(fileSystem, rootPath, pattern));
}