private void processPaths(String... paths) { for (final String path : paths) { final Set<String> resourcePaths = sc.getResourcePaths(path); if (resourcePaths == null) { break; } resourceFinderStack.push( new ResourceFinder() { private Deque<String> resourcePathsStack = new LinkedList<String>() { private static final long serialVersionUID = 3109256773218160485L; { for (String resourcePath : resourcePaths) { push(resourcePath); } } }; private String current; private String next; @Override public boolean hasNext() { while (next == null && !resourcePathsStack.isEmpty()) { next = resourcePathsStack.pop(); if (next.endsWith("/")) { processPaths(next); next = null; } else if (next.endsWith(".jar")) { try { resourceFinderStack.push( new JarFileScanner(sc.getResourceAsStream(next), "", true)); } catch (IOException ioe) { throw new ResourceFinderException(ioe); } next = null; } } return next != null; } @Override public String next() { if (next != null || hasNext()) { current = next; next = null; return current; } throw new NoSuchElementException(); } @Override public void remove() { throw new UnsupportedOperationException(); } @Override public InputStream open() { return sc.getResourceAsStream(current); } @Override public void reset() { throw new UnsupportedOperationException(); } }); } }
@Override public InputStream open() { return resourceFinderStack.open(); }
@Override public String next() { return resourceFinderStack.next(); }
@Override public void remove() { resourceFinderStack.remove(); }
@Override public boolean hasNext() { return resourceFinderStack.hasNext(); }