Ejemplo n.º 1
0
  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();
            }
          });
    }
  }
Ejemplo n.º 2
0
 @Override
 public InputStream open() {
   return resourceFinderStack.open();
 }
Ejemplo n.º 3
0
 @Override
 public String next() {
   return resourceFinderStack.next();
 }
Ejemplo n.º 4
0
 @Override
 public void remove() {
   resourceFinderStack.remove();
 }
Ejemplo n.º 5
0
 @Override
 public boolean hasNext() {
   return resourceFinderStack.hasNext();
 }