Exemplo n.º 1
0
  /**
   * Durchsucht die Verzeichnisse und verarbeitet die gefundenen Dateien.
   *
   * @return Statistic mit den verarbeiteten Dateien
   */
  @Override
  public DirectoryStatistic process() {
    LOG.debug("Processing directory " + directory);
    final DirectoryStatistic stat = new DirectoryStatistic(directory);

    final Scanner scanner = buildFileScanner(directory, suffix, false);
    final List<File> files = scanner.find();

    LOG.debug("Found " + files.size() + " files for processing");
    for (final File f : files) {
      final FileProcessor p = new FileProcessor(f, outputFormat);
      stat.add(p.process());
    }

    if (recursive) {
      LOG.debug("Start recursive for " + directory);
      final Scanner directoryScanner = buildDirectoryScanner(directory, false);
      final List<File> subDirectories = directoryScanner.find();
      for (final File d : subDirectories) {
        final DirectoryProcessor p = new DirectoryProcessor(d, suffix, outputFormat, true);

        stat.add(p.process());
      }
    }

    return stat;
  }
Exemplo n.º 2
0
 /** {@inheritDoc} */
 public Document read(InputStream input) throws DocumentException {
   try {
     ZipInputStream zip = new ZipInputStream(input);
     ZipEntry entry = zip.getNextEntry();
     while (entry != null) {
       FileProcessor processor = processors.get(entry.getName());
       if (processor != null) {
         processor.process(zip);
       }
       entry = zip.getNextEntry();
     }
     if (document != null) {
       document.postProcess(this);
     }
     zip.close();
     return document;
   } catch (IOException e) {
     throw new DocumentException(e);
   }
 }