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.util.anvl;
26
27 /***
28 * TODO: Now values 'fold' but should but perhaps they shouldn't be stored
29 * folded. Only when we serialize should we fold (But how to know where
30 * to fold?).
31 * @author stack
32 * @version $Date: 2006-09-20 22:40:21 +0000 (Wed, 20 Sep 2006) $ $Version$
33 */
34 class Value extends SubElement {
35
36 private StringBuilder sb;
37 private boolean folding = false;
38
39 private Value() {
40 this(null);
41 }
42
43 public Value(final String s) {
44 super(s);
45 }
46
47 protected String baseCheck(String s) {
48 this.sb = new StringBuilder(s.length() * 2);
49 super.baseCheck(s);
50 return sb.toString();
51 }
52
53 @Override
54 protected void checkCharacter(char c, String srcStr, int index) {
55 checkControlCharacter(c, srcStr, index);
56
57
58 if (ANVLRecord.isCR(c)) {
59 this.folding = true;
60 this.sb.append(ANVLRecord.FOLD_PREFIX);
61 } else if (ANVLRecord.isLF(c)) {
62 if (!this.folding) {
63 this.folding = true;
64 this.sb.append(ANVLRecord.FOLD_PREFIX);
65 } else {
66
67 }
68 } else if (this.folding && Character.isWhitespace(c)) {
69
70 } else {
71 this.folding = false;
72 this.sb.append(c);
73 }
74 }
75 }