Пример #1
0
  /**
   * Sets the targets to search.
   *
   * @param targets set with the targets to search.
   * @throws NullPointerException if <code>targets == null</code>
   * @throws IllegalStateException if the scanner hasn't finished processing yet (<code>
   *     isFinished() == true</code>)
   */
  public void setTargets(Set targets) {
    if (targets == null) {
      throw new NullPointerException();
    }

    if (isFinished()) {
      throw new IllegalStateException(
          ResourceBundleFactory.getBundle(BUNDLE_NAME).getString("SCANNER_RUNNING" /* NOI18N */));
    }

    Set copy = new HashSet(targets);

    for (Iterator it = copy.iterator(); it.hasNext(); ) {
      Object file = it.next();

      if (file instanceof String) {
        targets.remove(file);
        file = new File((String) file);
        targets.add(file);
      }

      if (!((File) file).isDirectory()) {
        _queue.push((File) file);
        targets.remove(file);
      }
    }

    _dirs = new File[targets.size()];
    targets.toArray(_dirs);
  }
Пример #2
0
  /**
   * Removes the given file filter.
   *
   * @param filter file filter to remove.
   * @throws IllegalStateException if the scanner hasn't finished processing yet (<code>
   *     isFinished() == true</code>)
   */
  public void removeFilter(FilenameFilter filter) {
    if (isFinished()) {
      throw new IllegalStateException(
          ResourceBundleFactory.getBundle(BUNDLE_NAME).getString("SCANNER_RUNNING" /* NOI18N */));
    }

    _filters.removeFilter(filter);
  }
Пример #3
0
  /**
   * Sets the directory depth (number of levels) to search.
   *
   * @param level directory depth to search.
   * @throws IllegalStateException if the scanner hasn't finished processing yet (<code>
   *     isFinished() == true</code>)
   * @see #isFinished
   */
  public void setMaxLevels(int level) {
    if (isFinished()) {
      throw new IllegalStateException(
          ResourceBundleFactory.getBundle(BUNDLE_NAME).getString("SCANNER_RUNNING" /* NOI18N */));
    }

    _levels = level;
  }