1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.shared.filtering;
20
21 import java.io.FilterReader;
22 import java.io.Reader;
23 import java.util.LinkedHashSet;
24
25 import org.codehaus.plexus.interpolation.multi.DelimiterSpecification;
26
27
28
29
30 public abstract class AbstractFilterReaderLineEnding extends FilterReader {
31
32 private String escapeString;
33
34
35
36
37 protected boolean useEscape = false;
38
39
40
41
42 private boolean preserveEscapeString = false;
43
44 protected LinkedHashSet<DelimiterSpecification> delimiters = new LinkedHashSet<>();
45
46
47
48
49
50 protected int markLength = 255;
51
52
53 protected AbstractFilterReaderLineEnding(Reader in) {
54 super(in);
55 }
56
57
58
59
60 public String getEscapeString() {
61 return escapeString;
62 }
63
64
65
66
67 public void setEscapeString(String escapeString) {
68
69 if (escapeString != null && escapeString.length() >= 1) {
70 this.escapeString = escapeString;
71 this.useEscape = true;
72 calculateMarkLength();
73 }
74 }
75
76
77
78
79 public boolean isPreserveEscapeString() {
80 return preserveEscapeString;
81 }
82
83
84
85
86 public void setPreserveEscapeString(boolean preserveEscapeString) {
87 this.preserveEscapeString = preserveEscapeString;
88 }
89
90 protected void calculateMarkLength() {
91
92 markLength = 255;
93
94
95 if (escapeString != null) {
96 markLength += escapeString.length();
97 }
98 for (DelimiterSpecification spec : delimiters) {
99 markLength += spec.getBegin().length();
100 markLength += spec.getEnd().length();
101 }
102 }
103 }