public Iterator getChildren()

in src/main/java/org/apache/sling/launchpad/base/impl/ClassLoaderResourceProvider.java [49:82]


    public Iterator<String> getChildren(String path) {
        List<String> children;

        // Guard against extra trailing slashes
        if(path.endsWith("/") && path.length() > 1) {
            path = path.substring(0, path.length()-1);
        }

        URL url = this.classLoader.getResource(path);
        if (url != null) {
            Pattern pathPattern = Pattern.compile("^" + path + "/[^/]+/?$");

            children = new ArrayList<String>();
            try {
                URLConnection conn = url.openConnection();
                if (conn instanceof JarURLConnection) {
                    JarFile jar = ((JarURLConnection) conn).getJarFile();
                    Enumeration<JarEntry> entries = jar.entries();
                    while (entries.hasMoreElements()) {
                        String entry = entries.nextElement().getName();
                        if (pathPattern.matcher(entry).matches()) {
                            children.add(entry);
                        }
                    }
                }
            } catch (IOException ioe) {
                // ignore for now
            }
        } else {
            children = Collections.emptyList();
        }

        return children.iterator();
    }