private Resource seek()

in src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java [160:190]


    private Resource seek() {
        while (entries.hasNext()) {
            String entry = entries.next();

            // require leading slash (sanity check, should always be the case)
            if (!entry.startsWith("/")) {
                entry = "/".concat(entry);
            }

            // another sanity check if the prefix is correct
            final int slash = entry.indexOf('/', prefixLength);
            if (slash < 0 || slash == entry.length() - 1) {
                log.debug("seek: Using entry {}", entry);
                final boolean isFolder = entry.endsWith("/");
                final String entryPath = isFolder ? entry.substring(0, entry.length() - 1) : entry;
                return new BundleResource(
                        resourceResolver,
                        cache,
                        mappedPath,
                        mappedPath.getResourcePath(entryPath),
                        this.subResources != null ? this.subResources.get(ResourceUtil.getName(entryPath)) : null,
                        isFolder);
            }

            log.debug("seek: Ignoring entry {}", entry);
        }

        // no more results
        log.debug("seek: No more nodes, iterator exhausted");
        return null;
    }