31
31
import net.sf.statsvn.util.TaskLogger;
34
* Class for storing all command line parameters. The parameters are set by the {@link net.sf.statsvn.Main#main} method. Interested classes can read all
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
35
36
* parameter values from here.
37
38
* @todo Should be moved to more appropriate package and made non-public
40
41
* @version $Id: ConfigurationOptions.java,v 1.17 2005/03/20 19:12:25 squig Exp $
42
43
public final class SvnConfigurationOptions {
43
private static final int DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY = 2000;
44
private static final int DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY = 2000;
44
46
private static final int DEFAULT_NUMBER_THREADS = 25;
45
48
private static String cacheDir = "";
46
private static final String DEFAULT_CACHE_DIR = System.getProperty("user.home") + FileUtils.getDirSeparator() + ".statsvn" + FileUtils.getDirSeparator();
47
private static String svnUsername = null;
48
private static String svnPassword = null;
49
private static TaskLogger taskLogger = new JavaUtilTaskLogger();
50
private static int numberSvnDiffThreads = DEFAULT_NUMBER_THREADS;
51
private static long thresholdInMsToUseConcurrency = DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY;
52
private static boolean dump = false;
55
* A utility class (only static methods) should be final and have
56
* a private constructor.
50
private static final String DEFAULT_CACHE_DIR = System.getProperty("user.home") + FileUtils.getDirSeparator() + ".statsvn" + FileUtils.getDirSeparator();
52
private static String svnUsername = null;
54
private static String svnPassword = null;
56
private static TaskLogger taskLogger = new JavaUtilTaskLogger();
58
private static int numberSvnDiffThreads = DEFAULT_NUMBER_THREADS;
60
private static long thresholdInMsToUseConcurrency = DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY;
62
private static boolean dump = false;
64
private static boolean anonymize = false;
66
private static String tagsDirectory = "/tags/";
68
// use the newer diff. will be overridden if this is not possible.
69
private static boolean useLegacyDiff = false;
72
* A utility class (only static methods) should be final and have a private
58
75
private SvnConfigurationOptions() {
62
* Returns the cacheDir.
64
* @return String output Directory
66
public static String getCacheDir() {
75
* @throws ConfigurationException
76
* if the cache directory cannot be created
78
public static void setCacheDir(String cacheDir) throws ConfigurationException {
79
if (!cacheDir.endsWith(FileUtils.getDirSeparator())) {
80
cacheDir += FileUtils.getDefaultDirSeparator();
82
final File cDir = new File(cacheDir);
83
if (!cDir.exists() && !cDir.mkdirs()) {
84
throw new ConfigurationException("Can't create cache directory: " + cacheDir);
86
SvnConfigurationOptions.cacheDir = cacheDir;
90
* Sets the cacheDir to the DEFAULT_CACHE_DIR
92
* @throws ConfigurationException
93
* if the cache directory cannot be created
95
public static void setCacheDirToDefault() throws ConfigurationException {
96
setCacheDir(DEFAULT_CACHE_DIR);
99
public static File getCheckedOutDirectoryAsFile() {
100
return new File(FileUtils.getPathWithoutEndingSlash(ConfigurationOptions.getCheckedOutDirectory()) + FileUtils.getDirSeparator());
79
* Returns the cacheDir.
81
* @return String output Directory
83
public static String getCacheDir() {
92
* @throws ConfigurationException
93
* if the cache directory cannot be created
95
public static void setCacheDir(String cacheDir) throws ConfigurationException {
96
if (!cacheDir.endsWith(FileUtils.getDirSeparator())) {
97
cacheDir += FileUtils.getDefaultDirSeparator();
99
final File cDir = new File(cacheDir);
100
if (!cDir.exists() && !cDir.mkdirs()) {
101
throw new ConfigurationException("Can't create cache directory: " + cacheDir);
103
SvnConfigurationOptions.cacheDir = cacheDir;
107
* Sets the cacheDir to the DEFAULT_CACHE_DIR
109
* @throws ConfigurationException
110
* if the cache directory cannot be created
112
public static void setCacheDirToDefault() throws ConfigurationException {
113
setCacheDir(DEFAULT_CACHE_DIR);
116
public static File getCheckedOutDirectoryAsFile() {
117
return new File(FileUtils.getPathWithoutEndingSlash(ConfigurationOptions.getCheckedOutDirectory()) + FileUtils.getDirSeparator());
104
121
* @return Returns the svnPassword.
167
* @param thresholdInMsToUseConcurrency the thresholdInMsToUseConcurrency to set
188
* @param thresholdInMsToUseConcurrency
189
* the thresholdInMsToUseConcurrency to set
169
public static void setThresholdInMsToUseConcurrency(long thresholdToUseConcurrency) {
191
public static void setThresholdInMsToUseConcurrency(final long thresholdToUseConcurrency) {
170
192
SvnConfigurationOptions.thresholdInMsToUseConcurrency = thresholdToUseConcurrency;
173
195
public static void setDumpContent(final boolean dumpContent) {
174
196
dump = dumpContent;
177
199
public static boolean isDumpContent() {
203
public static void setAnonymize(final boolean bAnon) {
207
public static boolean isAnonymize() {
212
* Following request 1692245, add option -tags-dir to the command line.
214
public static void setTagsDirectory(final String tagsDir) {
215
if (tagsDir != null) {
216
tagsDirectory = tagsDir.replace('\\', '/');
217
if (!tagsDirectory.endsWith("/")) {
218
tagsDirectory = tagsDir + "/";
224
* Following request 1692245, add option -tags-dir to the command line.
226
public static String getTagsDirectory() {
227
return tagsDirectory;
231
* Should we use a one diff per-file-per-revision or should we use the newer one diff per-revision?
233
* @return true if legacy diff should be used.
235
public static boolean isLegacyDiff() {
236
return useLegacyDiff;
240
* Should we use a one diff per-file-per-revision or should we use the newer one diff per-revision?
242
* @param isLegacy true if the legacy diff should be used.
244
public static void setLegacyDiff(final boolean isLegacy) {
245
useLegacyDiff = isLegacy;