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 * Class for storing all command line parameters. The parameters are set by the
35 * {@link net.sf.statsvn.Main#main} method. Interested classes can read all
36 * parameter values from here.
37 *
38 * @todo Should be moved to more appropriate package and made non-public
39 *
40 * @author jentzsch
41 * @version $Id: ConfigurationOptions.java,v 1.17 2005/03/20 19:12:25 squig Exp $
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 * A utility class (only static methods) should be final and have a private
73 * constructor.
74 */
75 private SvnConfigurationOptions() {
76 }
77
78 /**
79 * Returns the cacheDir.
80 *
81 * @return String output Directory
82 */
83 public static String getCacheDir() {
84 return cacheDir;
85 }
86
87 /**
88 * Sets the cacheDir.
89 *
90 * @param cacheDir
91 * The cacheDir to set
92 * @throws ConfigurationException
93 * if the cache directory cannot be created
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 * Sets the cacheDir to the DEFAULT_CACHE_DIR
108 *
109 * @throws ConfigurationException
110 * if the cache directory cannot be created
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 * @return Returns the svnPassword.
122 */
123 public static String getSvnPassword() {
124 return svnPassword;
125 }
126
127 /**
128 * @param svnPassword
129 * The svnPassword to set.
130 */
131 public static void setSvnPassword(final String svnPassword) {
132 SvnConfigurationOptions.svnPassword = svnPassword;
133 }
134
135 /**
136 * @return Returns the svnUsername.
137 */
138 public static String getSvnUsername() {
139 return svnUsername;
140 }
141
142 /**
143 * @param svnUsername
144 * The svnUsername to set.
145 */
146 public static void setSvnUsername(final String svnUsername) {
147 SvnConfigurationOptions.svnUsername = svnUsername;
148 }
149
150 /**
151 * @return the taskLogger
152 */
153 public static TaskLogger getTaskLogger() {
154 return taskLogger;
155 }
156
157 /**
158 * @param taskLogger
159 * the taskLogger to set
160 */
161 public static void setTaskLogger(final TaskLogger taskLogger) {
162 SvnConfigurationOptions.taskLogger = taskLogger;
163 }
164
165 /**
166 * @return the numberSvnDiffThreads
167 */
168 public static int getNumberSvnDiffThreads() {
169 return numberSvnDiffThreads;
170 }
171
172 /**
173 * @param numberSvnDiffThreads
174 * the numberSvnDiffThreads to set
175 */
176 public static void setNumberSvnDiffThreads(final int numberSvnDiffThreads) {
177 SvnConfigurationOptions.numberSvnDiffThreads = numberSvnDiffThreads;
178 }
179
180 /**
181 * @return the thresholdInMsToUseConcurrency
182 */
183 public static long getThresholdInMsToUseConcurrency() {
184 return thresholdInMsToUseConcurrency;
185 }
186
187 /**
188 * @param thresholdInMsToUseConcurrency
189 * the thresholdInMsToUseConcurrency to set
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 * Following request 1692245, add option -tags-dir to the command line.
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 * Following request 1692245, add option -tags-dir to the command line.
225 */
226 public static String getTagsDirectory() {
227 return tagsDirectory;
228 }
229
230 /**
231 * Should we use a one diff per-file-per-revision or should we use the newer one diff per-revision?
232 *
233 * @return true if legacy diff should be used.
234 */
235 public static boolean isLegacyDiff() {
236 return useLegacyDiff;
237 }
238
239 /**
240 * Should we use a one diff per-file-per-revision or should we use the newer one diff per-revision?
241 *
242 * @param isLegacy true if the legacy diff should be used.
243 */
244 public static void setLegacyDiff(final boolean isLegacy) {
245 useLegacyDiff = isLegacy;
246 }
247
248 }