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.io.Serializable;
28
29 import org.archive.util.TextUtils;
30
31 /*** Class to hold values for text fields.
32 *
33 * Objects of this class could be used instead of {@link java.lang.String} to
34 * hold text strings with newlines in it. SimpleTypes with values wrapped in
35 * objects of this class will show up in the UI as multiline text areas.
36 *
37 * @author John Erik Halse
38 *
39 */
40 public class TextField implements CharSequence, Serializable {
41 private static final long serialVersionUID = -2853908867414076703L;
42 private String value;
43
44 /*** Constructs a new TextField object.
45 *
46 * @param value the string represented by this TextField.
47 */
48 public TextField(String value) {
49 this.value = TextUtils.replaceAll("\r\n", value, "\n").trim();
50 }
51
52
53
54
55 public int length() {
56 return value.length();
57 }
58
59
60
61
62 public char charAt(int index) {
63 return value.charAt(index);
64 }
65
66
67
68
69 public CharSequence subSequence(int start, int end) {
70 return value.subSequence(start, end);
71 }
72
73 public boolean equals(Object obj) {
74 return obj instanceof TextField && value.equals(obj);
75 }
76
77
78
79
80 public int hashCode() {
81 return value.hashCode();
82 }
83
84
85
86
87 public String toString() {
88 return value;
89 }
90 }