Coverage Report - net.sf.statsvn.output.SvnConfigurationOptions
 
Classes in this File Line Coverage Branch Coverage Complexity
SvnConfigurationOptions
44%
24/54
20%
2/10
1.217
 
 1  
 /*
 2  
  StatCvs - CVS statistics generation
 3  
  Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
 4  
  http://statcvs.sf.net/
 5  
 
 6  
  This library is free software; you can redistribute it and/or
 7  
  modify it under the terms of the GNU Lesser General Public
 8  
  License as published by the Free Software Foundation; either
 9  
  version 2.1 of the License, or (at your option) any later version.
 10  
 
 11  
  This library is distributed in the hope that it will be useful,
 12  
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  
  Lesser General Public License for more details.
 15  
 
 16  
  You should have received a copy of the GNU Lesser General Public
 17  
  License along with this library; if not, write to the Free Software
 18  
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 19  
 
 20  
  $RCSfile: ConfigurationOptions.java,v $
 21  
  $Date: 2005/03/20 19:12:25 $
 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  12
         private static String cacheDir = "";
 49  
 
 50  12
         private static final String DEFAULT_CACHE_DIR = System.getProperty("user.home") + FileUtils.getDirSeparator() + ".statsvn" + FileUtils.getDirSeparator();
 51  
 
 52  12
         private static String svnUsername = null;
 53  
 
 54  12
         private static String svnPassword = null;
 55  
 
 56  12
         private static TaskLogger taskLogger = new JavaUtilTaskLogger();
 57  
 
 58  12
         private static int numberSvnDiffThreads = DEFAULT_NUMBER_THREADS;
 59  
 
 60  12
         private static long thresholdInMsToUseConcurrency = DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY;
 61  
 
 62  12
         private static boolean dump = false;
 63  
 
 64  12
         private static boolean anonymize = false;
 65  
 
 66  12
         private static String tagsDirectory = "/tags/";
 67  
 
 68  
         // use the newer diff. will be overridden if this is not possible. 
 69  12
         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  0
         private SvnConfigurationOptions() {
 76  0
         }
 77  
 
 78  
         /**
 79  
          * Returns the cacheDir.
 80  
          * 
 81  
          * @return String output Directory
 82  
          */
 83  
         public static String getCacheDir() {
 84  6
                 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  3
                 if (!cacheDir.endsWith(FileUtils.getDirSeparator())) {
 97  3
                         cacheDir += FileUtils.getDefaultDirSeparator();
 98  
                 }
 99  3
                 final File cDir = new File(cacheDir);
 100  3
                 if (!cDir.exists() && !cDir.mkdirs()) {
 101  0
                         throw new ConfigurationException("Can't create cache directory: " + cacheDir);
 102  
                 }
 103  3
                 SvnConfigurationOptions.cacheDir = cacheDir;
 104  3
         }
 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  0
                 setCacheDir(DEFAULT_CACHE_DIR);
 114  0
         }
 115  
 
 116  
         public static File getCheckedOutDirectoryAsFile() {
 117  0
                 return new File(FileUtils.getPathWithoutEndingSlash(ConfigurationOptions.getCheckedOutDirectory()) + FileUtils.getDirSeparator());
 118  
         }
 119  
 
 120  
         /**
 121  
          * @return Returns the svnPassword.
 122  
          */
 123  
         public static String getSvnPassword() {
 124  0
                 return svnPassword;
 125  
         }
 126  
 
 127  
         /**
 128  
          * @param svnPassword
 129  
          *            The svnPassword to set.
 130  
          */
 131  
         public static void setSvnPassword(final String svnPassword) {
 132  0
                 SvnConfigurationOptions.svnPassword = svnPassword;
 133  0
         }
 134  
 
 135  
         /**
 136  
          * @return Returns the svnUsername.
 137  
          */
 138  
         public static String getSvnUsername() {
 139  0
                 return svnUsername;
 140  
         }
 141  
 
 142  
         /**
 143  
          * @param svnUsername
 144  
          *            The svnUsername to set.
 145  
          */
 146  
         public static void setSvnUsername(final String svnUsername) {
 147  0
                 SvnConfigurationOptions.svnUsername = svnUsername;
 148  0
         }
 149  
 
 150  
         /**
 151  
          * @return the taskLogger
 152  
          */
 153  
         public static TaskLogger getTaskLogger() {
 154  23501
                 return taskLogger;
 155  
         }
 156  
 
 157  
         /**
 158  
          * @param taskLogger
 159  
          *            the taskLogger to set
 160  
          */
 161  
         public static void setTaskLogger(final TaskLogger taskLogger) {
 162  0
                 SvnConfigurationOptions.taskLogger = taskLogger;
 163  0
         }
 164  
 
 165  
         /**
 166  
          * @return the numberSvnDiffThreads
 167  
          */
 168  
         public static int getNumberSvnDiffThreads() {
 169  12
                 return numberSvnDiffThreads;
 170  
         }
 171  
 
 172  
         /**
 173  
          * @param numberSvnDiffThreads
 174  
          *            the numberSvnDiffThreads to set
 175  
          */
 176  
         public static void setNumberSvnDiffThreads(final int numberSvnDiffThreads) {
 177  0
                 SvnConfigurationOptions.numberSvnDiffThreads = numberSvnDiffThreads;
 178  0
         }
 179  
 
 180  
         /**
 181  
          * @return the thresholdInMsToUseConcurrency
 182  
          */
 183  
         public static long getThresholdInMsToUseConcurrency() {
 184  0
                 return thresholdInMsToUseConcurrency;
 185  
         }
 186  
 
 187  
         /**
 188  
          * @param thresholdInMsToUseConcurrency
 189  
          *            the thresholdInMsToUseConcurrency to set
 190  
          */
 191  
         public static void setThresholdInMsToUseConcurrency(final long thresholdToUseConcurrency) {
 192  0
                 SvnConfigurationOptions.thresholdInMsToUseConcurrency = thresholdToUseConcurrency;
 193  0
         }
 194  
 
 195  
         public static void setDumpContent(final boolean dumpContent) {
 196  0
                 dump = dumpContent;
 197  0
         }
 198  
 
 199  
         public static boolean isDumpContent() {
 200  3
                 return dump;
 201  
         }
 202  
 
 203  
         public static void setAnonymize(final boolean bAnon) {
 204  0
                 anonymize = bAnon;
 205  0
         }
 206  
 
 207  
         public static boolean isAnonymize() {
 208  16653
                 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  0
                 if (tagsDir != null) {
 216  0
                         tagsDirectory = tagsDir.replace('\\', '/');
 217  0
                         if (!tagsDirectory.endsWith("/")) {
 218  0
                                 tagsDirectory = tagsDir + "/";
 219  
                         }
 220  
                 }
 221  0
         }
 222  
 
 223  
         /**
 224  
          * Following request 1692245, add option -tags-dir to the command line.
 225  
          */
 226  
         public static String getTagsDirectory() {
 227  16254
                 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  6
                 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  0
                 useLegacyDiff = isLegacy;
 246  0
         }
 247  
 
 248  
 }