View Javadoc

    1   /* ModuleType
    2    *
    3    * $Id: ModuleType.java 4657 2006-09-25 21:44:36Z paul_jack $
    4    *
    5    * Created on Dec 17, 2003
    6    *
    7    * Copyright (C) 2004 Internet Archive.
    8    *
    9    * This file is part of the Heritrix web crawler (crawler.archive.org).
    10   *
    11   * Heritrix is free software; you can redistribute it and/or modify
    12   * it under the terms of the GNU Lesser Public License as published by
    13   * the Free Software Foundation; either version 2.1 of the License, or
    14   * any later version.
    15   *
    16   * Heritrix is distributed in the hope that it will be useful,
    17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19   * GNU Lesser Public License for more details.
    20   *
    21   * You should have received a copy of the GNU Lesser Public License
    22   * along with Heritrix; if not, write to the Free Software
    23   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24   */
    25  package org.archive.crawler.settings;
    26
    27  import java.util.List;
    28
    29  import javax.management.InvalidAttributeValueException;
    30
    31  /***
    32   * Superclass of all modules that should be configurable.
    33   *
    34   * @author John Erik Halse
    35   */
    36  public class ModuleType extends ComplexType {
    37
    38      private static final long serialVersionUID = 3686678928531236811L;
    39
    40      /*** Creates a new ModuleType.
    41       *
    42       * This constructor is made to help implementors of subclasses. It is an
    43       * requirement that subclasses at the very least implements a constructor
    44       * that takes only the name as an argument.
    45       *
    46       * @param name the name of the module.
    47       * @param description the description of the module.
    48       */
    49      public ModuleType(String name, String description) {
    50          super(name, description);
    51      }
    52
    53      /*** Every subclass should implement this constructor
    54       *
    55       * @param name of the module
    56       */
    57      public ModuleType(String name) {
    58          super(name, name);
    59      }
    60
    61      public Type addElement(CrawlerSettings settings, Type type)
    62              throws InvalidAttributeValueException {
    63          if (isInitialized()) {
    64              throw new IllegalStateException(
    65                      "Not allowed to add elements to modules after"
    66                              + " initialization. (Module: " + getName()
    67                              + ", Element: " + type.getName() + ", Settings: "
    68                              + settings.getName() + " (" + settings.getScope()
    69                              + ")");
    70          }
    71          return super.addElement(settings, type);
    72      }
    73
    74      /***
    75       * Those Modules that use files on disk should list them all when this
    76       * method is called.
    77       *
    78       * <p>Each file (as a string name with full path) should be added to the
    79       * provided list.
    80       *
    81       * <p>Modules that do not use any files can safely ignore this method.
    82       *
    83       * @param list The list to add files to.
    84       */
    85      protected void listUsedFiles(List<String> list){
    86          // By default do nothing
    87      }
    88  }