package ciir.jfoley.chai.io.inputs;

import ciir.jfoley.chai.io.Directory;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.logging.Logger;

/**
 * @author jfoley
 */
public class InputFinder {
  public static final Logger logger = Logger.getLogger(InputFinder.class.getName());
  public final List<FileHandler> handlers;

  public static List<FileHandler> defaultHandlers = new Vector<>();
  static {
    defaultHandlers.add(new ZipInputHandler());
    defaultHandlers.add(new TarInputHandler());
  }

  public static InputFinder Default() {
    return new InputFinder(defaultHandlers);
  }

  public InputFinder(List<FileHandler> handlers) {
    this.handlers = handlers;
  }

  public interface FileHandler {
    boolean matches(File input);
    InputContainer getContainer(File input) throws IOException;
  }

  public List<? extends InputContainer> findAllInputs(Directory dir) throws IOException {
    ArrayList<InputContainer> output = new ArrayList<>();
    for (File child : dir.recursiveChildren()) {
      output.add(asInputContainer(child));
    }
    return output;
  }

  public InputContainer asInputContainer(File child) throws IOException {
    for (FileHandler handler : this.handlers) {
      if(handler.matches(child)) {
        return handler.getContainer(child);
      }
    }
    return new SingletonInputContainer(child.getName(), new FileInput(child));
  }

}

@@ -142,24 +142,54 @@
 .ArrayList;%0A
+import java.util.Collections;%0A
 import java.
@@ -927,24 +927,562 @@
 ption;%0A  %7D%0A%0A
+  public List%3C? extends InputContainer%3E findAllInputs(List%3CString%3E paths) throws IOException %7B%0A    ArrayList%3CInputContainer%3E output = new ArrayList%3C%3E();%0A    for (String path : paths) %7B%0A      output.addAll(findAllInputs(path));%0A    %7D%0A    return output;%0A  %7D%0A%0A  public List%3C? extends InputContainer%3E findAllInputs(String path) throws IOException %7B%0A    File fp = new File(path);%0A    if(fp.isDirectory()) %7B%0A      return findAllInputs(Directory.Read(path));%0A    %7D else %7B%0A      return Collections.singletonList(asInputContainer(fp));%0A    %7D%0A  %7D%0A%0A
   public Lis

Add some helper fns to InputFinder