1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.archive.crawler.settings;
25
26 /*** List of String values.
27 *
28 * @author John Erik Halse
29 */
30 public class StringList extends ListType<String> {
31
32 private static final long serialVersionUID = 3181868189684416390L;
33
34 /*** Creates a new StringList.
35 *
36 * @param name of the list.
37 * @param description of the list. This string should be suitable for using
38 * in a user interface.
39 */
40 public StringList(String name, String description) {
41 super(name, description);
42 }
43
44 /*** Creates a new StringList and initializes it with the values from
45 * another StringList.
46 *
47 * @param name of the list.
48 * @param description of the list. This string should be suitable for using
49 * in a user interface.
50 * @param l
51 */
52 public StringList(String name, String description, StringList l) {
53 super(name, description);
54 addAll(l);
55 }
56
57 /*** Creates a new StringList and initializes it with the values from
58 * an array of Strings.
59 *
60 * @param name of the list.
61 * @param description of the list. This string should be suitable for using
62 * in a user interface.
63 * @param l the array from which this lists gets its initial values.
64 */
65 public StringList(String name, String description, String[] l) {
66 super(name, description);
67 addAll(l);
68 }
69
70 /*** Add a new {@link java.lang.String} at the specified index to this list.
71 *
72 * @param index index at which the specified element is to be inserted.
73 * @param element the value to be added.
74 */
75 public void add(int index, String element) {
76 super.add(index, element);
77 }
78
79 /*** Add a new {@link java.lang.String} at the end of this list.
80 *
81 * @param element the value to be added.
82 */
83 public void add(String element) {
84 super.add(element);
85 }
86
87 /*** Appends all of the elements in the specified list to the end of this
88 * list, in the order that they are returned by the specified lists's
89 * iterator.
90 *
91 * The behavior of this operation is unspecified if the specified
92 * collection is modified while the operation is in progress.
93 *
94 * @param l list whose elements are to be added to this list.
95 */
96 public void addAll(StringList l) {
97 super.addAll(l);
98 }
99
100 /*** Appends all of the elements in the specified array to the end of this
101 * list, in the same order that they are in the array.
102 *
103 * @param l array whose elements are to be added to this list.
104 */
105 public void addAll(String[] l) {
106 for (int i = 0; i < l.length; i++) {
107 add(l[i]);
108 }
109 }
110
111 /*** Replaces the element at the specified position in this list with the
112 * specified element.
113 *
114 * @param index index at which the specified element is to be inserted.
115 * @param element element to be inserted.
116 * @return the element previously at the specified position.
117 */
118 public String set(int index, String element) {
119 return (String) super.set(index, element);
120 }
121
122 /*** Check if element is of right type for this list.
123 *
124 * @param element element to check.
125 * @return element of the right type.
126 * @throws ClassCastException is thrown if the element was of wrong type
127 * and could not be converted.
128 */
129 public String checkType(Object element) throws ClassCastException {
130 return (String)element;
131 }
132 }