1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.statsvn.output;
24
25 import java.io.File;
26
27 import net.sf.statcvs.output.ConfigurationException;
28 import net.sf.statcvs.output.ConfigurationOptions;
29 import net.sf.statcvs.util.FileUtils;
30 import net.sf.statsvn.util.JavaUtilTaskLogger;
31 import net.sf.statsvn.util.TaskLogger;
32
33
34
35
36
37
38
39
40
41
42
43 public final class SvnConfigurationOptions {
44 private static final int DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY = 2000;
45
46 private static final int DEFAULT_NUMBER_THREADS = 25;
47
48 private static String cacheDir = "";
49
50 private static final String DEFAULT_CACHE_DIR = System.getProperty("user.home") + FileUtils.getDirSeparator() + ".statsvn" + FileUtils.getDirSeparator();
51
52 private static String svnUsername = null;
53
54 private static String svnPassword = null;
55
56 private static TaskLogger taskLogger = new JavaUtilTaskLogger();
57
58 private static int numberSvnDiffThreads = DEFAULT_NUMBER_THREADS;
59
60 private static long thresholdInMsToUseConcurrency = DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY;
61
62 private static boolean dump = false;
63
64 private static boolean anonymize = false;
65
66 private static String tagsDirectory = "/tags/";
67
68
69 private static boolean useLegacyDiff = false;
70
71
72
73
74
75 private SvnConfigurationOptions() {
76 }
77
78
79
80
81
82
83 public static String getCacheDir() {
84 return cacheDir;
85 }
86
87
88
89
90
91
92
93
94
95 public static void setCacheDir(String cacheDir) throws ConfigurationException {
96 if (!cacheDir.endsWith(FileUtils.getDirSeparator())) {
97 cacheDir += FileUtils.getDefaultDirSeparator();
98 }
99 final File cDir = new File(cacheDir);
100 if (!cDir.exists() && !cDir.mkdirs()) {
101 throw new ConfigurationException("Can't create cache directory: " + cacheDir);
102 }
103 SvnConfigurationOptions.cacheDir = cacheDir;
104 }
105
106
107
108
109
110
111
112 public static void setCacheDirToDefault() throws ConfigurationException {
113 setCacheDir(DEFAULT_CACHE_DIR);
114 }
115
116 public static File getCheckedOutDirectoryAsFile() {
117 return new File(FileUtils.getPathWithoutEndingSlash(ConfigurationOptions.getCheckedOutDirectory()) + FileUtils.getDirSeparator());
118 }
119
120
121
122
123 public static String getSvnPassword() {
124 return svnPassword;
125 }
126
127
128
129
130
131 public static void setSvnPassword(final String svnPassword) {
132 SvnConfigurationOptions.svnPassword = svnPassword;
133 }
134
135
136
137
138 public static String getSvnUsername() {
139 return svnUsername;
140 }
141
142
143
144
145
146 public static void setSvnUsername(final String svnUsername) {
147 SvnConfigurationOptions.svnUsername = svnUsername;
148 }
149
150
151
152
153 public static TaskLogger getTaskLogger() {
154 return taskLogger;
155 }
156
157
158
159
160
161 public static void setTaskLogger(final TaskLogger taskLogger) {
162 SvnConfigurationOptions.taskLogger = taskLogger;
163 }
164
165
166
167
168 public static int getNumberSvnDiffThreads() {
169 return numberSvnDiffThreads;
170 }
171
172
173
174
175
176 public static void setNumberSvnDiffThreads(final int numberSvnDiffThreads) {
177 SvnConfigurationOptions.numberSvnDiffThreads = numberSvnDiffThreads;
178 }
179
180
181
182
183 public static long getThresholdInMsToUseConcurrency() {
184 return thresholdInMsToUseConcurrency;
185 }
186
187
188
189
190
191 public static void setThresholdInMsToUseConcurrency(final long thresholdToUseConcurrency) {
192 SvnConfigurationOptions.thresholdInMsToUseConcurrency = thresholdToUseConcurrency;
193 }
194
195 public static void setDumpContent(final boolean dumpContent) {
196 dump = dumpContent;
197 }
198
199 public static boolean isDumpContent() {
200 return dump;
201 }
202
203 public static void setAnonymize(final boolean bAnon) {
204 anonymize = bAnon;
205 }
206
207 public static boolean isAnonymize() {
208 return anonymize;
209 }
210
211
212
213
214 public static void setTagsDirectory(final String tagsDir) {
215 if (tagsDir != null) {
216 tagsDirectory = tagsDir.replace('\\', '/');
217 if (!tagsDirectory.endsWith("/")) {
218 tagsDirectory = tagsDir + "/";
219 }
220 }
221 }
222
223
224
225
226 public static String getTagsDirectory() {
227 return tagsDirectory;
228 }
229
230
231
232
233
234
235 public static boolean isLegacyDiff() {
236 return useLegacyDiff;
237 }
238
239
240
241
242
243
244 public static void setLegacyDiff(final boolean isLegacy) {
245 useLegacyDiff = isLegacy;
246 }
247
248 }