當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。