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


Java SimpleFileVisitor类代码示例

本文整理汇总了Java中org.uberfire.java.nio.file.SimpleFileVisitor的典型用法代码示例。如果您正苦于以下问题:Java SimpleFileVisitor类的具体用法?Java SimpleFileVisitor怎么用?Java SimpleFileVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleFileVisitor类属于org.uberfire.java.nio.file包,在下文中一共展示了SimpleFileVisitor类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: allKeys

import org.uberfire.java.nio.file.SimpleFileVisitor; //导入依赖的package包/类
@Override
public Collection<String> allKeys(final PreferenceScope scope) {
    Collection<String> keys = new ArrayList<>();
    Path path = this.objectStorage.getPath(buildScopePath(scope));

    if (ioService.exists(path)) {
        walkFileTree(checkNotNull("path",
                                  path),
                     new SimpleFileVisitor<Path>() {
                         @Override
                         public FileVisitResult visitFile(final Path file,
                                                          final BasicFileAttributes attrs) throws IOException {
                             try {
                                 checkNotNull("file",
                                              file);

                                 final String fileName = file.getFileName().toString();
                                 final int keyEndIndex = fileName.length() - FILE_FORMAT_SIZE;
                                 final String fileNameWithoutFormat = fileName.substring(0,
                                                                                         keyEndIndex);

                                 keys.add(fileNameWithoutFormat);
                             } catch (final Exception ex) {
                                 logger.error("An unexpected exception was thrown: ",
                                              ex);
                                 return FileVisitResult.TERMINATE;
                             }

                             return FileVisitResult.CONTINUE;
                         }
                     });
    }

    return keys;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:36,代码来源:PreferenceStorageImpl.java

示例2: listRuntimePlugins

import org.uberfire.java.nio.file.SimpleFileVisitor; //导入依赖的package包/类
private Collection<RuntimePlugin> listRuntimePlugins(Path path) {
    final Collection<RuntimePlugin> result = new ArrayList<RuntimePlugin>();

    if (getIoService().exists(path)) {
        walkFileTree(checkNotNull("path",
                                  path),
                     new SimpleFileVisitor<Path>() {
                         @Override
                         public FileVisitResult visitFile(final Path file,
                                                          final BasicFileAttributes attrs) throws IOException {
                             try {
                                 checkNotNull("file",
                                              file);
                                 checkNotNull("attrs",
                                              attrs);

                                 if (attrs.isRegularFile()) {
                                     result.addAll(buildPluginRuntimePlugins(file));
                                 }
                             } catch (final Exception ex) {
                                 logger.error("An unexpected exception was thrown: ",
                                              ex);
                                 return FileVisitResult.TERMINATE;
                             }
                             return FileVisitResult.CONTINUE;
                         }
                     });
    }

    return result;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:32,代码来源:PluginServicesImpl.java

示例3: listPlugins

import org.uberfire.java.nio.file.SimpleFileVisitor; //导入依赖的package包/类
@Override
public Collection<Plugin> listPlugins() {
    final Collection<Plugin> result = new ArrayList<>();

    if (getIoService().exists(root)) {
        walkFileTree(checkNotNull("root",
                                  root),
                     new SimpleFileVisitor<Path>() {
                         @Override
                         public FileVisitResult visitFile(final Path file,
                                                          final BasicFileAttributes attrs) throws IOException {
                             try {
                                 checkNotNull("file",
                                              file);
                                 checkNotNull("attrs",
                                              attrs);

                                 if (file.getFileName().toString().endsWith(".plugin") && attrs.isRegularFile()) {
                                     final org.uberfire.backend.vfs.Path path = convert(file);
                                     result.add(new Plugin(file.getParent().getFileName().toString(),
                                                           TypeConverterUtil.fromPath(path),
                                                           path));
                                 }
                             } catch (final Exception ex) {
                                 return FileVisitResult.TERMINATE;
                             }
                             return FileVisitResult.CONTINUE;
                         }
                     });
    }

    return result;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:34,代码来源:PluginServicesImpl.java

示例4: listDynamicMenus

import org.uberfire.java.nio.file.SimpleFileVisitor; //导入依赖的package包/类
@Override
public Collection<DynamicMenu> listDynamicMenus() {
    final Collection<DynamicMenu> result = new ArrayList<DynamicMenu>();

    if (getIoService().exists(root)) {
        walkFileTree(checkNotNull("root",
                                  root),
                     new SimpleFileVisitor<Path>() {
                         @Override
                         public FileVisitResult visitFile(final Path file,
                                                          final BasicFileAttributes attrs) throws IOException {
                             try {
                                 checkNotNull("file",
                                              file);
                                 checkNotNull("attrs",
                                              attrs);

                                 if (file.getFileName().toString().equalsIgnoreCase("info.dynamic") && attrs.isRegularFile()) {
                                     final String pluginName = file.getParent().getFileName().toString();
                                     result.add(new DynamicMenu(pluginName,
                                                                PluginType.DYNAMIC_MENU,
                                                                convert(file.getParent()),
                                                                loadMenuItems(pluginName)));
                                 }
                             } catch (final Exception ex) {
                                 return FileVisitResult.TERMINATE;
                             }
                             return FileVisitResult.CONTINUE;
                         }
                     });
    }

    return result;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:35,代码来源:PluginServicesImpl.java

示例5: listLayoutEditor

import org.uberfire.java.nio.file.SimpleFileVisitor; //导入依赖的package包/类
@Override
public Collection<LayoutEditorModel> listLayoutEditor(final PluginType pluginType) {
    final Collection<LayoutEditorModel> result = new ArrayList<LayoutEditorModel>();

    if (getIoService().exists(root)) {
        walkFileTree(checkNotNull("root",
                                  root),
                     new SimpleFileVisitor<Path>() {
                         @Override
                         public FileVisitResult visitFile(final Path file,
                                                          final BasicFileAttributes attrs) throws IOException {
                             try {
                                 checkNotNull("file",
                                              file);
                                 checkNotNull("attrs",
                                              attrs);
                                 if (file.getFileName().toString().equalsIgnoreCase(pluginType.toString().toLowerCase()) && attrs.isRegularFile()) {
                                     final LayoutEditorModel layoutEditorModel = getLayoutEditor(convert(file),
                                                                                                 pluginType);
                                     result.add(layoutEditorModel);
                                 }
                             } catch (final Exception ex) {
                                 return FileVisitResult.TERMINATE;
                             }
                             return FileVisitResult.CONTINUE;
                         }
                     });
    }

    return result;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:32,代码来源:PluginServicesImpl.java

示例6: loadPerspectives

import org.uberfire.java.nio.file.SimpleFileVisitor; //导入依赖的package包/类
@Override
public Set<PerspectiveDefinition> loadPerspectives() {
    final Set<PerspectiveDefinition> result = new HashSet<PerspectiveDefinition>();
    final Path perspectivesPath = userServices.buildPath("perspectives");
    if (ioService.exists(perspectivesPath)) {

        walkFileTree(perspectivesPath,
                     new SimpleFileVisitor<Path>() {
                         public FileVisitResult visitFile(final Path file,
                                                          final BasicFileAttributes attrs) throws IOException {
                             try {
                                 checkNotNull("file",
                                              file);
                                 checkNotNull("attrs",
                                              attrs);
                                 String fileName = file.getFileName().toString();
                                 if (fileName.endsWith(PERSPECTIVE_EXTENSION) && attrs.isRegularFile()) {
                                     String perspectiveName = fileName.substring(0,
                                                                                 fileName.indexOf(PERSPECTIVE_EXTENSION));
                                     PerspectiveDefinition def = loadPerspective(perspectiveName);
                                     if (def != null) {
                                         result.add(def);
                                     }
                                 }
                             } catch (final Exception ex) {
                                 return FileVisitResult.TERMINATE;
                             }
                             return FileVisitResult.CONTINUE;
                         }
                     });
    }
    return result;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:34,代码来源:WorkbenchServicesImpl.java

示例7: loadPolicyFromVfs

import org.uberfire.java.nio.file.SimpleFileVisitor; //导入依赖的package包/类
public AuthorizationPolicy loadPolicyFromVfs() {
    Path authzPath = getAuthzPath();
    if (!ioService.exists(authzPath)) {
        return null;
    }
    AuthorizationPolicyBuilder builder = permissionManager.newAuthorizationPolicy();
    AuthorizationPolicyMarshaller marshaller = new AuthorizationPolicyMarshaller();

    walkFileTree(authzPath,
                 new SimpleFileVisitor<Path>() {
                     @Override
                     public FileVisitResult visitFile(final Path file,
                                                      final BasicFileAttributes attrs) throws IOException {
                         try {
                             checkNotNull("file",
                                          file);
                             checkNotNull("attrs",
                                          attrs);

                             if (isPolicyFile(file)) {
                                 String content = ioService.readAllString(file);
                                 NonEscapedProperties props = new NonEscapedProperties();
                                 props.load(new StringReader(content));
                                 marshaller.read(builder,
                                                 props);
                             }
                         } catch (final Exception e) {
                             logger.error("Authz policy file VFS read error: " + file.getFileName(),
                                          e);
                             return FileVisitResult.TERMINATE;
                         }
                         return FileVisitResult.CONTINUE;
                     }
                 });
    return builder.build();
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:37,代码来源:AuthorizationPolicyVfsStorage.java

示例8: listDataSetDefs

import org.uberfire.java.nio.file.SimpleFileVisitor; //导入依赖的package包/类
public Collection<DataSetDef> listDataSetDefs() {
    final Collection<DataSetDef> result = new ArrayList<DataSetDef>();

    if (ioService.exists(root)) {
        walkFileTree(checkNotNull("root",
                                  root),
                     new SimpleFileVisitor<Path>() {
                         @Override
                         public FileVisitResult visitFile(final Path file,
                                                          final BasicFileAttributes attrs) throws IOException {
                             try {
                                 checkNotNull("file",
                                              file);
                                 checkNotNull("attrs",
                                              attrs);

                                 if (file.getFileName().toString().endsWith(DATASET_EXT) && attrs.isRegularFile()) {
                                     String json = ioService.readAllString(file);
                                     DataSetDef def = getDataSetDefJsonMarshaller().fromJson(json);
                                     result.add(def);
                                 }
                             } catch (final Exception e) {
                                 log.error("Data set definition read error: " + file.getFileName(),
                                           e);
                                 return FileVisitResult.TERMINATE;
                             }
                             return FileVisitResult.CONTINUE;
                         }
                     });
    }
    return result;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:33,代码来源:DataSetDefRegistryCDI.java

示例9: deleteTempFiles

import org.uberfire.java.nio.file.SimpleFileVisitor; //导入依赖的package包/类
public void deleteTempFiles() {
    Path tempPath = getTempPath();
    if (ioService.exists(tempPath)) {
        ioService.startBatch(fileSystem,
                             new CommentedOption("system",
                                                 "Delete temporal files"));
        try {
            walkFileTree(tempPath,
                         new SimpleFileVisitor<Path>() {

                             @Override
                             public FileVisitResult postVisitDirectory(Path dir,
                                                                       IOException exc) throws IOException {
                                 Files.delete(dir);
                                 return FileVisitResult.CONTINUE;
                             }

                             @Override
                             public FileVisitResult visitFile(Path file,
                                                              BasicFileAttributes attrs) throws IOException {
                                 Files.delete(file);
                                 return FileVisitResult.CONTINUE;
                             }
                         });
        } finally {
            ioService.endBatch();
        }
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:30,代码来源:DataSetDefRegistryCDI.java


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