1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
87 }
88 }