本文整理了Java中org.uberfire.java.nio.file.DirectoryStream.iterator()
方法的一些代码示例,展示了DirectoryStream.iterator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DirectoryStream.iterator()
方法的具体详情如下:
包路径:org.uberfire.java.nio.file.DirectoryStream
类名称:DirectoryStream
方法名:iterator
暂无
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-data-modeller-core
public boolean isEmpty(final IOService ioService, Path dirPath) throws IOException {
if (dirPath == null) return true;
final DirectoryStream<Path> children = ioService.newDirectoryStream(dirPath);
if (children == null) return true;
Iterator<Path> iterator = children.iterator();
return iterator == null || !iterator.hasNext();
}
代码示例来源:origin: kiegroup/jbpm-wb
protected boolean isCaseProject(Path rootProjectPath) {
org.uberfire.java.nio.file.DirectoryStream<Path> found = ioService.newDirectoryStream(rootProjectPath,
f -> f.endsWith(CASE_PROJECT_DOT_FILE));
return found.iterator().hasNext();
}
}
代码示例来源:origin: org.uberfire/uberfire-metadata-commons-io
private boolean hasContent(Path dir) {
// TODO remove this filter when AF-1073 is resolved
try (DirectoryStream<Path> children = newDirectoryStream(dir, path -> !path.endsWith("readme.md"))) {
return children.iterator().hasNext();
}
}
代码示例来源:origin: org.jbpm/jbpm-wb-integration-backend
protected boolean isCaseProject(Path rootProjectPath) {
org.uberfire.java.nio.file.DirectoryStream<Path> found = ioService.newDirectoryStream(rootProjectPath,
f -> f.endsWith(CASE_PROJECT_DOT_FILE));
return found.iterator().hasNext();
}
}
代码示例来源:origin: org.uberfire/uberfire-wires-bpmn-backend
@Override
public List<Path> listFiles() {
final DirectoryStream<org.uberfire.java.nio.file.Path> stream = ioService.newDirectoryStream(root,
new DirectoryStream.Filter<org.uberfire.java.nio.file.Path>() {
@Override
public boolean accept(org.uberfire.java.nio.file.Path entry) throws IOException {
return typeDefinition.accept(Paths.convert(entry));
}
});
final List<Path> files = new ArrayList<Path>();
final Iterator<org.uberfire.java.nio.file.Path> itr = stream.iterator();
while (itr.hasNext()) {
files.add(Paths.convert(itr.next()));
}
return files;
}
代码示例来源:origin: kiegroup/appformer
@Override
public List<Path> listFiles() {
final DirectoryStream<org.uberfire.java.nio.file.Path> stream = ioService.newDirectoryStream(root,
new DirectoryStream.Filter<org.uberfire.java.nio.file.Path>() {
@Override
public boolean accept(org.uberfire.java.nio.file.Path entry) throws IOException {
return typeDefinition.accept(Paths.convert(entry));
}
});
final List<Path> files = new ArrayList<Path>();
final Iterator<org.uberfire.java.nio.file.Path> itr = stream.iterator();
while (itr.hasNext()) {
files.add(Paths.convert(itr.next()));
}
return files;
}
代码示例来源:origin: kiegroup/appformer
private boolean hasContent(Path dir) {
// TODO remove this filter when AF-1073 is resolved
try (DirectoryStream<Path> children = newDirectoryStream(dir, path -> !path.endsWith("readme.md"))) {
return children.iterator().hasNext();
}
}
代码示例来源:origin: kiegroup/appformer
private void retrieveLocks(final org.uberfire.java.nio.file.Path path,
final List<Path> accu) {
if (!Files.exists(path)) {
return;
}
Filter<org.uberfire.java.nio.file.Path> filter = new Filter<org.uberfire.java.nio.file.Path>() {
@Override
public boolean accept(final org.uberfire.java.nio.file.Path entry) throws org.uberfire.java.nio.IOException {
if (Paths.convert(entry).toURI().endsWith(PathFactory.LOCK_FILE_EXTENSION)) {
accu.add(Paths.convert(entry));
} else if (Files.isDirectory(entry)) {
retrieveLocks(ioService.get(entry.toUri()),
accu);
}
return true;
}
};
Iterator<org.uberfire.java.nio.file.Path> it = ioService.newDirectoryStream(path,
filter).iterator();
while (it.hasNext()) {
it.next();
}
}
代码示例来源:origin: kiegroup/appformer
private List<ConfigGroup> getConfiguration(final Path dir,
final ConfigType type) {
final List<ConfigGroup> configGroups = new ArrayList<>();
if (!ioService.exists(dir)) {
return configGroups;
}
final DirectoryStream<Path> foundConfigs = getDirectoryStreamForFilesWithParticularExtension(dir,
type.getExt());
//Only load and cache if a file was found!
final Iterator<Path> it = foundConfigs.iterator();
if (it.hasNext()) {
while (it.hasNext()) {
final String content = ioService.readAllString(it.next());
final ConfigGroup configGroup = marshaller.unmarshall(content);
configGroups.add(configGroup);
}
return configGroups;
}
return null;
}
代码示例来源:origin: org.guvnor/guvnor-structure-backend
final Iterator<Path> it = foundConfigs.iterator();
if (it.hasNext()) {
while (it.hasNext()) {
代码示例来源:origin: org.uberfire/backend-server
@Override
public DirectoryStream<Path> newDirectoryStream(final Path dir)
throws IllegalArgumentException, NotDirectoryException, IOException {
final Iterator<org.uberfire.java.nio.file.Path> content = Files.newDirectoryStream(fromPath(dir)).iterator();
return newDirectoryStream(content);
}
代码示例来源:origin: kiegroup/appformer
@Override
public DirectoryStream<Path> newDirectoryStream(final Path dir)
throws IllegalArgumentException, NotDirectoryException, IOException {
final Iterator<org.uberfire.java.nio.file.Path> content = ioService.newDirectoryStream(Paths.convert(dir)).iterator();
return newDirectoryStream(content);
}
代码示例来源:origin: org.kie.workbench/kie-wb-common-cli-project-migration
@Override
public List<ConfigGroup> getConfiguration(ConfigType configType) {
if (ConfigType.SPACE.equals(configType)) {
configType = ConfigType.ORGANIZATIONAL_UNIT;
}
final ConfigType type = configType;
final List<ConfigGroup> configGroups = new ArrayList<>();
final DirectoryStream<Path> foundConfigs = ioService.newDirectoryStream(ioService.get(systemRepository.getUri()),
entry -> {
if (!Files.isDirectory(entry) &&
!entry.getFileName().toString().startsWith(".") &&
entry.getFileName().toString().endsWith(type.getExt())) {
return true;
}
return false;
}
);
//Only load and cache if a file was found!
final Iterator<Path> it = foundConfigs.iterator();
if (it.hasNext()) {
while (it.hasNext()) {
final String content = ioService.readAllString(it.next());
final ConfigGroup configGroup = marshaller.unmarshall(content);
configGroups.add(configGroup);
}
configGroupsByTypeWithoutNamespace.put(type,
configGroups);
}
return configGroups;
}
代码示例来源:origin: org.jbpm/jbpm-wb-integration-backend
@Test
public void testConfigureNewPackage() {
Path packagePath = Mockito.mock(Path.class);
when(packagePath.toUri()).thenReturn(URI.create("default://p0/Evaluation/src/main/resources/org"));
DirectoryStream directoryStream = Mockito.mock(DirectoryStream.class);
when(ioService.newDirectoryStream(any(),
any())).thenReturn((DirectoryStream<Path>) directoryStream);
when(directoryStream.iterator()).thenReturn(Arrays.asList(packagePath).iterator());
org.guvnor.common.services.project.model.Package pkg = Mockito.mock(org.guvnor.common.services.project.model.Package.class);
when(pkg.getModuleRootPath()).thenReturn(projectPath);
when(pkg.getPackageMainResourcesPath()).thenReturn(projectPath);
NewPackageEvent event = new NewPackageEvent(pkg);
caseProjectService.configurePackage(event);
verify(ioService,
times(1)).write(any(),
any(byte[].class));
}
代码示例来源:origin: kiegroup/appformer
@Override
public DirectoryStream<Path> newDirectoryStream(final Path dir,
final DirectoryStream.Filter<Path> filter)
throws IllegalArgumentException, NotDirectoryException, IOException {
final Iterator<org.uberfire.java.nio.file.Path> content = ioService.newDirectoryStream(Paths.convert(dir),
path -> filter.accept(Paths.convert(path))).iterator();
return newDirectoryStream(content);
}
代码示例来源:origin: kiegroup/appformer
@Override
public Map<String, List<ConfigGroup>> getConfigurationByNamespace(final ConfigType type) {
if (!type.hasNamespace()) {
throw new RuntimeException("The ConfigType " + type.toString() + " does not support namespaces.");
}
final Path typeDir = ioService.get(systemRepository.getUri()).resolve(type.getDir());
if (!ioService.exists(typeDir)) {
return Collections.emptyMap();
}
final DirectoryStream<Path> foundNamespaces = getDirectoryStreamForDirectories(typeDir);
// Force cache update for all namespaces in that type
final Iterator<Path> it = foundNamespaces.iterator();
while (it.hasNext()) {
final String namespace = Paths.convert(it.next()).getFileName();
getConfiguration(type,
namespace);
}
// Return the updated cache
return configGroupsByTypeWithNamespace.get(type);
}
代码示例来源:origin: kiegroup/jbpm-wb
@Test
public void testConfigureNewPackage() {
Path packagePath = Mockito.mock(Path.class);
when(packagePath.toUri()).thenReturn(URI.create("default://p0/Evaluation/src/main/resources/org"));
DirectoryStream directoryStream = Mockito.mock(DirectoryStream.class);
when(ioService.newDirectoryStream(any(),
any())).thenReturn((DirectoryStream<Path>) directoryStream);
when(directoryStream.iterator()).thenReturn(Arrays.asList(packagePath).iterator());
org.guvnor.common.services.project.model.Package pkg = Mockito.mock(org.guvnor.common.services.project.model.Package.class);
when(pkg.getModuleRootPath()).thenReturn(projectPath);
when(pkg.getPackageMainResourcesPath()).thenReturn(projectPath);
NewPackageEvent event = new NewPackageEvent(pkg);
caseProjectService.configurePackage(event);
verify(ioService,
times(1)).write(any(),
any(byte[].class));
}
代码示例来源:origin: org.kie.workbench/kie-wb-common-ala-registry-vfs
private void prepareReadEntries() throws Exception {
entryPaths = mockList(Path.class,
ENTRY_COUNT);
Iterator<Path> pathIterator = entryPaths.iterator();
expectedObjects = mockList(Object.class,
ENTRY_COUNT);
entries = mockList(VFSRegistryEntry.class,
ENTRY_COUNT);
DirectoryStream<Path> directoryStream = mock(DirectoryStream.class);
when(directoryStream.iterator()).thenReturn(pathIterator);
when(ioService.newDirectoryStream(rootPath,
filter)).thenReturn(directoryStream);
for (int i = 0; i < ENTRY_COUNT; i++) {
VFSRegistryEntry entry = entries.get(i);
when(ioService.readAllString(entryPaths.get(i))).thenReturn(MARSHALLED_ENTRY + i);
when(entryMarshaller.unmarshal(MARSHALLED_ENTRY + i)).thenReturn(entry);
when(entry.getContentType()).thenReturn(Object.class.getName());
when(entry.getContent()).thenReturn(MARSHALLED_VALUE + i);
when(marshallerRegistry.get(any(Class.class))).thenReturn(marshaller);
when(marshaller.unmarshal(MARSHALLED_VALUE + i)).thenReturn(expectedObjects.get(i));
}
}
}
代码示例来源:origin: org.guvnor/guvnor-ala-registry-vfs
private void prepareReadEntries() throws Exception {
entryPaths = mockList(Path.class,
ENTRY_COUNT);
Iterator<Path> pathIterator = entryPaths.iterator();
expectedObjects = mockList(Object.class,
ENTRY_COUNT);
entries = mockList(VFSRegistryEntry.class,
ENTRY_COUNT);
DirectoryStream<Path> directoryStream = mock(DirectoryStream.class);
when(directoryStream.iterator()).thenReturn(pathIterator);
when(ioService.newDirectoryStream(rootPath,
filter)).thenReturn(directoryStream);
for (int i = 0; i < ENTRY_COUNT; i++) {
VFSRegistryEntry entry = entries.get(i);
when(ioService.readAllString(entryPaths.get(i))).thenReturn(MARSHALLED_ENTRY + i);
when(entryMarshaller.unmarshal(MARSHALLED_ENTRY + i)).thenReturn(entry);
when(entry.getContentType()).thenReturn(Object.class.getName());
when(entry.getContent()).thenReturn(MARSHALLED_VALUE + i);
when(marshallerRegistry.get(any(Class.class))).thenReturn(marshaller);
when(marshaller.unmarshal(MARSHALLED_VALUE + i)).thenReturn(expectedObjects.get(i));
}
}
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-data-modeller-core
deleteable = true;
} else {
Iterator<Path> iterator = children.iterator();
if (iterator == null) {
deleteable = true;
内容来源于网络,如有侵权,请联系作者删除!