creadur-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From codesite-nore...@google.com
Subject [apache-rat-pd] r45 committed - Support to define language of source code from command line is added. ...
Date Sat, 01 Aug 2009 12:58:15 GMT
Revision: 45
Author: maka82
Date: Sat Aug  1 05:56:47 2009
Log: Support to define language of source code from command line is added.  
If language is not defined from command line option, it can be retrieved  
from current heuristic checker. Verbose option in command line is added. It  
manage how much information will be displayed in console in run-time. Tests  
are updated.
http://code.google.com/p/apache-rat-pd/source/detail?r=45

Modified:
  /trunk/src/main/java/org/apache/rat/pd/core/PdCommandLine.java
  /trunk/src/main/java/org/apache/rat/pd/core/PlagiarismDetector.java
  /trunk/src/main/java/org/apache/rat/pd/core/SourceCodeAnalyser.java
  /trunk/src/main/java/org/apache/rat/pd/engines/RetryManager.java
   
/trunk/src/main/java/org/apache/rat/pd/engines/google/GoogleCodeSearchParser.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ActionScriptCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CPPCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CSharpCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CobolCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ColdFusionCommentsheuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/DelphiCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/FortranCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/HTMLCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/JavaCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/JavaScriptCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/LispCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PHPCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PascalCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PerlCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PythonCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/RubyCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/SQLCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ShellCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/VisualBasicCommentHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/ActionScriptFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CPPFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CSharpFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/DelphiFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/FortranFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/FunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/JavaFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/JavaScriptFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/PHPFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/PascalFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/VisualBasicFunctionHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/misspellings/MisspellingsHeuristicChecker.java
  /trunk/src/test/java/org/apache/rat/pd/core/PdCommandLineTest.java
  /trunk/src/test/java/org/apache/rat/pd/core/SlidingWindowAlgorithmTest.java
   
/trunk/src/test/java/org/apache/rat/pd/engines/google/GoogleCodeSearchParserTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/CCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/CobolCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/ColdFusionCommentsheuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/DelphiCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/FortranCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/HTMLCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/JavaCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/LispCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/PHPCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/PascalCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/PythonCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/RubyCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/SQLCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/VisualBasicCommentHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/ActionScriptFeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/CFunctionHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/CPPFunctionHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/CSharpFunctionHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/DelphiFunctionsHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/FortranFunctionHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/JavaFunctionHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/JavaScriptFunctionHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/PHPFunctionHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/PascalFunctionHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/functions/VisualBasicFunctionHeuristicCheckerTest.java
   
/trunk/src/test/java/org/apache/rat/pd/heuristic/misspellings/CodeHeuristicsSpellCheckerTest.java
  /trunk/src/test/resources/configuration/resources/config_test1.conf

=======================================
--- /trunk/src/main/java/org/apache/rat/pd/core/PdCommandLine.java	Sat Jun   
6 18:25:20 2009
+++ /trunk/src/main/java/org/apache/rat/pd/core/PdCommandLine.java	Sat Aug   
1 05:56:47 2009
@@ -21,6 +21,7 @@
  package org.apache.rat.pd.core;

  import java.io.IOException;
+import java.io.PrintStream;
  import java.util.ArrayList;
  import java.util.List;

@@ -57,6 +58,8 @@
   *
   */
  public class PdCommandLine {
+	private static final String VERBOSE_OPT_DESC = "verbose description of  
current actions";
+	private static final String LANGUAGE_OPT_DESC = "name of a language";
  	private static final String HEURISTICS_OPT_DESC = "list of heuristics";
  	private static final String ENGINES_OPT_DESC = "list of engines";
  	private static final String CONFIG_OPT_DESC = "name of the config file";
@@ -64,6 +67,8 @@
  	private static final String CODEBASE_OPT_DESC = "name of source code  
directory";
  	private static final String REPORT_OPT_DESC = "name of the report file";
  	private static final String HELP_OPT_DESC = "print this message";
+	private static final String VERBOSE_OPT_SHORT = "v";
+	private static final String LANGUAGE_OPT_SHORT = "lang";
  	private static final String HEURISTIC_OPT_SHORT = "heur";
  	private static final String ENGINES_OPT_SHORT = "e";
  	private static final String CONFIG_OPT_SHORT = "c";
@@ -79,6 +84,8 @@
  	private static final String DEFAULT_ENGINE_MSG = "Engines is not set.In  
use is default engine: ";
  	private static final String DEFAULT_LIMIT_MSG = "Limit is not set.In use  
is default limit: ";
  	private static final String DEFAULT_RAPORT_MSG = "Report is not set.In  
use is default report: ";
+	private static final String VERBOSE_OPT_LONG = "verbose";
+	private static final String LANGUAGE_OPT_LONG = "language";
  	private static final String HEURISTICS_OPT_LONG = "heuristics";
  	private static final String ENGINES_OPT_LONG = "engines";
  	private static final String CONFIG_OPT_LONG = "config";
@@ -103,7 +110,10 @@
  	private String config = "config.conf";
  	private List<String> heuristics = new ArrayList<String>();
  	private boolean allArgumentsCorrect = true;
-
+	private String language;
+	private boolean verbose = false;
+
+	private final PrintStream out;
  	// available options
  	private Option helpOption = new Option(HELP_OPT_SHORT, HELP_OPT_LONG,
  			false, HELP_OPT_DESC);
@@ -134,6 +144,14 @@
  			.withDescription(HEURISTICS_OPT_DESC).withLongOpt(
  					HEURISTICS_OPT_LONG).create(HEURISTIC_OPT_SHORT);

+	private Option languageOption = OptionBuilder.hasArg(true).withArgName(
+			"name").withDescription(LANGUAGE_OPT_DESC).withLongOpt(
+			LANGUAGE_OPT_LONG).create(LANGUAGE_OPT_SHORT);
+
+	private Option verboseOption =  
OptionBuilder.hasArg(false).withDescription(
+			VERBOSE_OPT_DESC).withLongOpt(VERBOSE_OPT_LONG).create(
+			VERBOSE_OPT_SHORT);
+
  	/**
  	 * Arguments passed to constructor are parsed and values are set to proper
  	 * class member. After that configuration file is parsed. If path to
@@ -145,7 +163,8 @@
  	 * @param args
  	 *            command line arguments
  	 */
-	public PdCommandLine(String[] args) {
+	public PdCommandLine(String[] args, PrintStream out) {
+		this.out = out;
  		initializeOptions();
  		// we parse command line
  		try {
@@ -161,19 +180,21 @@
  			configureUninitializedValues();
  		} catch (Exception e) {
  			// oops, something went wrong
-			System.out.println("Parsing failed.  Reason: " + e.getMessage());
+			this.out.println("Parsing failed.  Reason: " + e.getMessage());
  			// if any error is happened, we can say that not all arguments are
  			// correct
  			allArgumentsCorrect = false;
  		}

  		// TODO for debugging, delete me
-		System.out.println("codebase : " + this.codebase);
-		System.out.println("limit    : " + this.limit);
-		System.out.println("engines  : " + this.engines);
-		System.out.println("heuristic: " + this.heuristics);
-		System.out.println("config   : " + this.config);
-		System.out.println("report   : " + this.report);
+		this.out.println("codebase : " + this.codebase);
+		this.out.println("limit    : " + this.limit);
+		this.out.println("engines  : " + this.engines);
+		this.out.println("heuristic: " + this.heuristics);
+		this.out.println("config   : " + this.config);
+		this.out.println("report   : " + this.report);
+		this.out.println("language : " + this.language);
+		this.out.println("verbose  : " + this.verbose);
  	}

  	/**
@@ -194,19 +215,19 @@
  	 */
  	private void configureUninitializedValues() {
  		if (this.report == null) {
-			System.out.println(DEFAULT_RAPORT_MSG + DEFAULT_REPORT);
+			this.out.println(DEFAULT_RAPORT_MSG + DEFAULT_REPORT);
  			this.report = DEFAULT_REPORT;
  		}
  		if (this.limit == 0) {
-			System.out.println(DEFAULT_LIMIT_MSG + DEFAULT_LIMIT);
+			this.out.println(DEFAULT_LIMIT_MSG + DEFAULT_LIMIT);
  			this.limit = DEFAULT_LIMIT;
  		}
  		if (this.engines.isEmpty()) {
-			System.out.println(DEFAULT_ENGINE_MSG + DEFAULT_ENGINE);
+			this.out.println(DEFAULT_ENGINE_MSG + DEFAULT_ENGINE);
  			this.engines.add(DEFAULT_ENGINE);
  		}
  		if (this.heuristics.isEmpty()) {
-			System.out.println(DEFAULT_HEURISTIC_MSG + DEFAULT_HEURISTIC);
+			this.out.println(DEFAULT_HEURISTIC_MSG + DEFAULT_HEURISTIC);
  			this.heuristics.add(DEFAULT_HEURISTIC);
  		}
  	}
@@ -218,7 +239,7 @@
  		StringBuffer footer = new StringBuffer("\n");

  		footer
-				.append("Example: java -jar apache-rat-pd.jar -cb c:\\src -r  
c:\\report.txt\n");
+				.append("Example: java -jar apache-rat-pd.jar -cb c:\\src -r  
c:\\report.txt -lang java -v\n");
  		footer.append("NOTE:\n");
  		footer
  				.append("This tool shows report in console and save it to file\n");
@@ -241,6 +262,8 @@
  		options.addOption(configOption);
  		options.addOption(enginesOption);
  		options.addOption(heuristicsOption);
+		options.addOption(languageOption);
+		options.addOption(verboseOption);
  	}

  	/**
@@ -276,6 +299,10 @@
  				heuristics.add(temp[i]);
  			}
  		}
+
+		if (line.hasOption(LANGUAGE_OPT_LONG)) {
+			this.language = line.getOptionValue(LANGUAGE_OPT_LONG);
+		}

  		if (line.hasOption(HELP_OPT_LONG)) {
  			allArgumentsCorrect = false;
@@ -288,11 +315,18 @@
  					"Number must be in interval [1,100] inclusive");
  			this.limit = temp;
  		}
+		if (line.hasOption(VERBOSE_OPT_LONG)) {
+			this.verbose = true;
+		}
  	}

  	public int getLimit() {
  		return this.limit;
  	}
+
+	public boolean isVerbose() {
+		return this.verbose;
+	}

  	public String getReport() {
  		return this.report;
@@ -309,6 +343,10 @@
  	public List<String> getHeuristics() {
  		return this.heuristics;
  	}
+
+	public String getLanguage() {
+		return this.language;
+	}

  	/**
  	 * @return true if all arguments are parsed properly
@@ -329,15 +367,15 @@
  	 */
  	private void parseConfigFile(String config) throws NumberFormatException,
  			ParseException {
-		System.out.println("Trying to read configuration options from: "
-				+ config);
+		this.out
+				.println("Trying to read configuration options from: " + config);
  		String[] args = null;
  		try {
  			String content = FileManipulator.readFile(config);
  			content = content.replaceAll("\n", " ");
  			args = content.split(" ");
  		} catch (IOException e) {
-			System.out.println("Error parsing configuration options from: "
+			this.out.println("Error parsing configuration options from: "
  					+ config);
  		}
  		parseArguments(args);
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/core/PlagiarismDetector.java	Sat  
Jul 25 03:08:02 2009
+++ /trunk/src/main/java/org/apache/rat/pd/core/PlagiarismDetector.java	Sat  
Aug  1 05:56:47 2009
@@ -20,10 +20,12 @@
   */
  package org.apache.rat.pd.core;

+import java.io.ByteArrayOutputStream;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.InputStream;
+import java.io.PrintStream;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Set;
@@ -88,16 +90,20 @@
  	public static void main(String[] args) throws RatReportFailedException,
  			IOException {

-		PdCommandLine pdCommandLine = new PdCommandLine(args);
+		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
  		if (!pdCommandLine.isAllArgumentsCorrect()) {
  			pdCommandLine.printUsage();
  			System.exit(1);
  		}
+		//stream for printing current information
+		final PrintStream out = getProperPrintStream(pdCommandLine);
  		// we add all rules we are interested in
-		final List<IHeuristicChecker> algorithmsForChecking =  
configureHeuristicCheckers(pdCommandLine);
+		final List<IHeuristicChecker> algorithmsForChecking =  
configureHeuristicCheckers(
+				pdCommandLine, out);
  		// making one or more parsers
  		final List<ISearchEngine> searchEngines = configureSearchEngines(
-				pdCommandLine, getLanguage(algorithmsForChecking));
+				pdCommandLine, getLanguage(pdCommandLine,
+						algorithmsForChecking, out), out);

  		// we check whole directory
  		final DirectoryWalker walker = new DirectoryWalker(new File(
@@ -106,7 +112,7 @@
  		final ReportDocument reportDocument = new ReportDocument();
  		// analyser is sliding-window checker
  		final SourceCodeAnalyser analyser = new SourceCodeAnalyser(
-				searchEngines, algorithmsForChecking, reportDocument);
+				searchEngines, algorithmsForChecking, reportDocument, out);

  		final PlagiarismDetectorReport plagiarismDetectorReport = new  
PlagiarismDetectorReport(
  				analyser);
@@ -125,11 +131,11 @@
  	 * @return
  	 */
  	private static List<ISearchEngine> configureSearchEngines(
-			PdCommandLine pdCommandLine, String language) {
+			PdCommandLine pdCommandLine, String language, PrintStream out) {
  		List<ISearchEngine> toret = new ArrayList<ISearchEngine>();
  		for (String searchEngine : pdCommandLine.getEngines()) {
  			if (searchEngine.equals("GoogleCodeSearchParser")) {
-				toret.add(new GoogleCodeSearchParser(language));
+				toret.add(new GoogleCodeSearchParser(language, out));
  			}
  			// TODO add more parsers
  		}
@@ -145,7 +151,7 @@
  	 * @throws IOException
  	 */
  	private static List<IHeuristicChecker> configureHeuristicCheckers(
-			PdCommandLine pdCommandLine) throws IOException {
+			PdCommandLine pdCommandLine, PrintStream out) throws IOException {
  		List<IHeuristicChecker> toret = new ArrayList<IHeuristicChecker>();

  		for (String heuristicChecker : pdCommandLine.getHeuristics()) {
@@ -158,70 +164,69 @@
  			// //////////////////////////////////////////////////
  			else if (heuristicChecker.equals("JavaCommentHeuristicChecker")) {
  				toret.add(new JavaCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("PascalCommentHeuristicChecker")) {
  				toret.add(new PascalCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("CCommentHeuristicChecker")) {
-				toret
-						.add(new CCommentHeuristicChecker(pdCommandLine
-								.getLimit()));
+				toret.add(new CCommentHeuristicChecker(
+						pdCommandLine.getLimit(), out));
  			} else if (heuristicChecker.equals("CobolCommentHeuristicChecker")) {
  				toret.add(new CobolCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker
  					.equals("ColdFusionCommentsheuristicChecker")) {
  				toret.add(new ColdFusionCommentsheuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("DelphiCommentHeuristicChecker")) {
  				toret.add(new DelphiCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker
  					.equals("FortranCommentHeuristicChecker")) {
  				toret.add(new FortranCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("HTMLCommentHeuristicChecker")) {
  				toret.add(new HTMLCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("LispCommentHeuristicChecker")) {
  				toret.add(new LispCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("PHPCommentHeuristicChecker")) {
  				toret.add(new PHPCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("PythonCommentHeuristicChecker")) {
  				toret.add(new PythonCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("RubyCommentHeuristicChecker")) {
  				toret.add(new RubyCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("SQLCommentHeuristicChecker")) {
  				toret.add(new SQLCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker
  					.equals("VisualBasicCommentHeuristicChecker")) {
  				toret.add(new VisualBasicCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker
  					.equals("ActionScriptCommentHeuristicChecker")) {
  				toret.add(new ActionScriptCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("CPPCommentHeuristicChecker")) {
  				toret.add(new CPPCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("CSharpCommentHeuristicChecker")) {
  				toret.add(new CSharpCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker
  					.equals("JavaScriptCommentHeuristicChecker")) {
  				toret.add(new JavaScriptCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("PerlCommentHeuristicChecker")) {
  				toret.add(new PerlCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("ShellCommentHeuristicChecker")) {
  				toret.add(new ShellCommentHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			}
  			// ///////////////////////////////////////////////////
  			// Functions heuristic checkers
@@ -229,35 +234,35 @@
  			else if (heuristicChecker
  					.equals("ActionScriptFunctionHeuristicChecker")) {
  				toret.add(new ActionScriptFunctionHeuristicChecker(
-						pdCommandLine.getLimit()));
+						pdCommandLine.getLimit(), out));
  			} else if (heuristicChecker.equals("CFunctionHeuristicChecker")) {
  				toret.add(new CFunctionHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("CPPFunctionHeuristicChecker")) {
  				toret.add(new CPPFunctionHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker
  					.equals("CSharpFunctionHeuristicChecker")) {
  				toret.add(new CSharpFunctionHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker
  					.equals("DelphiFunctionHeuristicChecker")) {
  				toret.add(new DelphiFunctionHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("JavaFunctionHeuristicChecker")) {
  				toret.add(new JavaFunctionHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker
  					.equals("JavaScriptFunctionHeuristicChecker")) {
  				toret.add(new JavaScriptFunctionHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker
  					.equals("PascalFunctionHeuristicChecker")) {
  				toret.add(new PascalFunctionHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			} else if (heuristicChecker.equals("PHPFunctionHeuristicChecker")) {
  				toret.add(new PHPFunctionHeuristicChecker(pdCommandLine
-						.getLimit()));
+						.getLimit(), out));
  			}
  			// ///////////////////////////////////////////////////
  			// Misspellings heuristic checkers
@@ -267,12 +272,12 @@
  						.getResourceAsStream("/misspellings/english.dict");
  				IDictionary dictionary = new Dictionary(is);
  				toret.add(new MisspellingsHeuristicChecker(dictionary,
-						IHeuristicChecker.ALL_LANGUAGES));
+						IHeuristicChecker.ALL_LANGUAGES, out));
  			}

  			else {
  				System.err.println("Cannot find propper class for "
-						+ heuristicChecker);
+								+ heuristicChecker);
  			}
  		}
  		return toret;
@@ -293,8 +298,8 @@
  	 * @return Language of source code. It depends by selected heuristic
  	 *         checkers.
  	 */
-	private static String getLanguage(
-			List<IHeuristicChecker> algorithmsForChecking) {
+	private static String getLanguageFromHeuristic(
+			List<IHeuristicChecker> algorithmsForChecking, PrintStream out) {
  		String toret = IHeuristicChecker.ALL_LANGUAGES;
  		Set<String> langs = new TreeSet<String>();
  		for (IHeuristicChecker heuristicChecker : algorithmsForChecking) {
@@ -302,8 +307,32 @@
  		}
  		if (langs.size() == 1) {
  			toret = langs.iterator().next();
-			System.out.println("Chosen language is: " +toret);
+			out.println("Chosen language is: " + toret);
  		}
  		return toret;
  	}
-}
+
+	private static String getLanguage(PdCommandLine commandLine,
+			List<IHeuristicChecker> algorithmsForChecking, PrintStream out) {
+		String toret = IHeuristicChecker.ALL_LANGUAGES;
+		if (commandLine.getLanguage() != null) {
+			toret = commandLine.getLanguage();
+		} else {
+			toret = getLanguageFromHeuristic(algorithmsForChecking, out);
+		}
+		return toret;
+	}
+
+	/**
+	 * If it is wanted to print current information in console, getVerbose  
will
+	 * return true. Otherwise, an dummy all information are printed in dummy
+	 * output stream.
+	 *
+	 * @param commandLine
+	 * @return
+	 */
+	private static PrintStream getProperPrintStream(PdCommandLine  
pdCommandLine) {
+		return pdCommandLine.isVerbose() ? System.out : new PrintStream(
+				new ByteArrayOutputStream());
+	}
+}
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/core/SourceCodeAnalyser.java	Wed  
Jul 22 14:50:50 2009
+++ /trunk/src/main/java/org/apache/rat/pd/core/SourceCodeAnalyser.java	Sat  
Aug  1 05:56:47 2009
@@ -22,6 +22,7 @@

  import java.io.BufferedReader;
  import java.io.IOException;
+import java.io.PrintStream;
  import java.io.Reader;
  import java.util.ArrayList;
  import java.util.List;
@@ -47,17 +48,19 @@
  	private final List<ISearchEngine> searchEngines;
  	private final List<IHeuristicChecker> algorithmsForChecking;
  	private final ReportDocument reportDocument;
-
+
+	private final PrintStream out;
  	private PauseListener pauseListener;
  	private volatile boolean paused = false;
  	private int progressMessageLength;

  	public SourceCodeAnalyser(List<ISearchEngine> searchEngines,
  			List<IHeuristicChecker> algorithmsForChecking,
-			ReportDocument reportDocument) {
+			ReportDocument reportDocument, PrintStream out) {
  		this.searchEngines = searchEngines;
  		this.algorithmsForChecking = algorithmsForChecking;
  		this.reportDocument = reportDocument;
+		this.out = out;

  		initializeKeyListener();
  	}
@@ -110,7 +113,7 @@
  			checkOneFile(searchEngines, code, algorithmsForChecking, document
  					.getName());
  		} catch (IOException e) {
-			System.out.println("Source file not found: " + document.getName());
+			System.err.println("Source file not found: " + document.getName());
  		}
  	}

@@ -185,11 +188,11 @@
  	 * @param reportEntry
  	 */
  	private void printReport(ReportEntry reportEntry) {
-		System.out.println("chunk of code copied:");
-		System.out.println(reportEntry.getUrl());
-		System.out.println("--------------------------------------------");
-		System.out.println(reportEntry.getCode().toString());
-		System.out.println("--------------------------------------------");
+		out.println("chunk of code copied:");
+		out.println(reportEntry.getUrl());
+		out.println("--------------------------------------------");
+		out.println(reportEntry.getCode().toString());
+		out.println("--------------------------------------------");
  	}

  	/**
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/engines/RetryManager.java	Sun  
Jul  5 17:15:14 2009
+++ /trunk/src/main/java/org/apache/rat/pd/engines/RetryManager.java	Sat  
Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.engines;

+import java.io.PrintStream;
+
  /**
   * This class is here to hide retry and timeout logic. This logic protects
   * application from exceptions caused by network problems or late response  
from
@@ -34,6 +36,7 @@
  	private final Managable searchengine;
  	private final int numberOfRetry;
  	private final int timeout;
+	private final PrintStream out;

  	/**
  	 * @param searchengine
@@ -43,10 +46,11 @@
  	 * @param timeout
  	 *            time between two requests
  	 */
-	public RetryManager(Managable searchengine, int numberOfRetry, int  
timeout) {
+	public RetryManager(Managable searchengine, int numberOfRetry, int  
timeout, PrintStream out) {
  		this.searchengine = searchengine;
  		this.timeout = timeout;
  		this.numberOfRetry = numberOfRetry;
+		this.out = out;
  	}

  	/**
@@ -73,7 +77,7 @@
  					Thread.currentThread().sleep(timeout);
  				} catch (InterruptedException e) {
  					// just print message
-					System.out.println("sleap interupted...");
+					System.err.println("sleap interupted...");
  				}
  			}
  		}
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/engines/google/GoogleCodeSearchParser.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/engines/google/GoogleCodeSearchParser.java	 
Sat Aug  1 05:56:47 2009
@@ -164,12 +164,15 @@
  	private List<URL> privateFeedUrl = new ArrayList<URL>();
  	private RegexGenerator regexGenerator = new MultilineRegexGenerator();

-	private RetryManager retryManager = new RetryManager(this,  
NUMBER_OF_RETRY,
-			WAIT_TIME);
+	private final RetryManager retryManager;
  	private final String language;
-
-	public GoogleCodeSearchParser(String language){
+	private final PrintStream out;
+
+	public GoogleCodeSearchParser(String language, PrintStream out){
  		this.language = language;
+		this.out = out;
+		this.retryManager = new RetryManager(this, NUMBER_OF_RETRY,
+				WAIT_TIME, out);
  	}

  	private String getLanguageQuery(){
@@ -193,8 +196,8 @@
  				+ URLEncoder.encode(regexGenerator
  						.stringToRegex(posibleCutAndPastedCode))
  				+ "&max-results=" + RESULT_NUMBER);
-		// System.out.println(regexGenerator
-		// .stringToRegex(posibleCutAndPastedCode));
+		 out.println(posibleCutAndPastedCode + " -> " +regexGenerator
+		 .stringToRegex(posibleCutAndPastedCode));
  		return toret;
  	}

=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ActionScriptCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ActionScriptCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   *There are two types of comments in ActionScript. First one starts with  
// and
   * ends with a end of a line. More info on:
@@ -41,9 +43,8 @@
  	 */
  	private static final String ACTION_SCRIPT_COMMENT_REGEX = "(/\\*(?:[^*]| 
(?:\\*+[^*/]))*\\*+/)|(//.*[\\n\\r])";

-	public ActionScriptCommentHeuristicChecker(int limit) {
-		super(ACTION_SCRIPT_COMMENT_REGEX, limit, "actionscript");
-
+	public ActionScriptCommentHeuristicChecker(int limit, PrintStream out) {
+		super(ACTION_SCRIPT_COMMENT_REGEX, limit, "actionscript", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   *
   * There is only one type of comments in C. C uses comments that starts  
with /*
@@ -38,8 +40,8 @@
  	 */
  	private static final String C_COMMENT_REGEX = "/\\*(?:[^*]| 
(?:\\*+[^*/]))*\\*+/";

-	public CCommentHeuristicChecker(int limit) {
-		super(C_COMMENT_REGEX, limit, "c");
+	public CCommentHeuristicChecker(int limit,PrintStream out) {
+		super(C_COMMENT_REGEX, limit, "c",out);

  	}

=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CPPCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CPPCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -21,6 +21,8 @@

  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There are two types of comments in C++ one starts with // and ends when  
line
   * ends; second starts with /* and ends with * /. This class recognize  
only pure
@@ -36,9 +38,8 @@
  	 */
  	private static final String CPP_COMMENT_REGEX = "(/\\*(?:[^*]| 
(?:\\*+[^*/]))*\\*+/)|(//.*[\\n\\r])";

-	public CPPCommentHeuristicChecker(int limit) {
-		super(CPP_COMMENT_REGEX, limit, "c++");
-
+	public CPPCommentHeuristicChecker(int limit, PrintStream out) {
+		super(CPP_COMMENT_REGEX, limit, "c++", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CSharpCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CSharpCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There are two types of comments in C#. First starts with // and ends  
when
   * line ends; second starts with /* and ends with * /. More info on:
@@ -35,9 +37,8 @@
  	 */
  	private static final String C_SHARP_COMMENT_REGEX = "(/\\*(?:[^*]| 
(?:\\*+[^*/]))*\\*+/)|(//.*[\\n\\r])";

-	public CSharpCommentHeuristicChecker(int limit) {
-		super(C_SHARP_COMMENT_REGEX, limit, "c#");
-
+	public CSharpCommentHeuristicChecker(int limit, PrintStream out) {
+		super(C_SHARP_COMMENT_REGEX, limit, "c#", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CobolCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CobolCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -21,6 +21,8 @@

  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  //TODO check if it really have digits for first 6 position
  /**
   * Comments in Cobol are defined with an asterisk at seventh character  
position
@@ -38,8 +40,8 @@
  	 */
  	private static final String COBOL_COMMENT_REGEX = "^\\d{6}\\*.*[\\n\\r]";

-	public CobolCommentHeuristicChecker(int limit) {
-		super(COBOL_COMMENT_REGEX, limit,"cobol");
+	public CobolCommentHeuristicChecker(int limit, PrintStream out) {
+		super(COBOL_COMMENT_REGEX, limit, "cobol", out);

  	}

=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ColdFusionCommentsheuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ColdFusionCommentsheuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There is only one type of comments in ColdFusion. Comments in ColdFusion
   * starts with <!--- and ends with --->. More info on:
@@ -37,8 +39,8 @@
  	 */
  	private static final String COLD_FUSION_COMMENT_REGEX = "<![  
\\r\\n\\t]*(---([^\\-]|[\\r\\n]|-[^\\-])*---[ \\r\\n\\t]*)>";

-	public ColdFusionCommentsheuristicChecker(int limit) {
-		super(COLD_FUSION_COMMENT_REGEX, limit, "coldfusion");
+	public ColdFusionCommentsheuristicChecker(int limit, PrintStream out) {
+		super(COLD_FUSION_COMMENT_REGEX, limit, "coldfusion", out);

  	}

=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,7 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
  import java.util.regex.Matcher;
  import java.util.regex.Pattern;

@@ -37,11 +38,13 @@
  	protected final String COMMENT_REGEX;
  	private final int limit;
  	private final String language;
-
-	public CommentHeuristicChecker(String regex, int limit, String language) {
+	private final PrintStream out;
+
+	public CommentHeuristicChecker(String regex, int limit, String language,  
PrintStream out) {
  		this.COMMENT_REGEX = regex;
  		this.limit = limit;
  		this.language = language;
+		this.out = out;
  	}

  	/**
@@ -65,7 +68,7 @@
  		if (m.find()) {
  			String found = m.group();
  			if (codeToBeChecked.endsWith(found)) {
-				System.out.println("Found comment: " + found);
+				out.println("Found comment: " + found);
  				boolean isSearchNeaded = found.length() > limit ? true : false;
  				toret = new HeuristicCheckerResult(isSearchNeaded,
  						false, found, this.getClass());
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/DelphiCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/DelphiCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * Comments in Delphi can be block comments and line comments. There are  
two
   * type of block comments. First start with { and ends with } and the  
second one
@@ -37,9 +39,8 @@
  	 */
  	private static final String DELPHI_COMMENT_REGEX = "(//.*[\\n\\r])| 
(\\(\\*(?:[^*]|(?:\\*+[^*\\(]))*\\*+\\))|(\\{(?:[^*]|(?:\\{+[^*]))*\\}+)";

-	public DelphiCommentHeuristicChecker(int limit) {
-		super(DELPHI_COMMENT_REGEX, limit,"pascal");
-
+	public DelphiCommentHeuristicChecker(int limit, PrintStream out) {
+		super(DELPHI_COMMENT_REGEX, limit, "pascal", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/FortranCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/FortranCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There are four types of comments in Fortran. They are all one-line  
comments
   * and they start with ! or C or c or * and ends when line ends. More info  
on:
@@ -37,9 +39,8 @@
  	// comment
  	private static final String FORTRAN_COMMENT_REGEX = "(!.*[\\n\\r])| 
(^C .*[\\n\\r])|(^c .*[\\n\\r])|(^\\* .*[\\n\\r])";

-	public FortranCommentHeuristicChecker(int limit) {
-		super(FORTRAN_COMMENT_REGEX, limit, "fortran");
-
+	public FortranCommentHeuristicChecker(int limit, PrintStream out) {
+		super(FORTRAN_COMMENT_REGEX, limit, "fortran", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/HTMLCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/HTMLCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -21,6 +21,8 @@

  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  import org.apache.rat.pd.heuristic.IHeuristicChecker;

  /**
@@ -40,9 +42,8 @@
  	 */
  	private static final String HTML_COMMENT_REGEX = "(<!((--([^\\-]|[\\r\\n]| 
-[^\\-])*--(\\s)*))*>)";

-	public HTMLCommentHeuristicChecker(int limit) {
-		super(HTML_COMMENT_REGEX, limit, IHeuristicChecker.ALL_LANGUAGES);
-
+	public HTMLCommentHeuristicChecker(int limit, PrintStream out) {
+		super(HTML_COMMENT_REGEX, limit, IHeuristicChecker.ALL_LANGUAGES, out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/JavaCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/JavaCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There are two types of comments in java one starts with // and ends  
when line
   * ends; second starts with /* and ends with * /. More info on:
@@ -35,8 +37,8 @@
  	 */
  	private static final String JAVA_COMMENT_REGEX = "(/\\*(?:[^*]| 
(?:\\*+[^*/]))*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";

-	public JavaCommentHeuristicChecker(int limit) {
-		super(JAVA_COMMENT_REGEX, limit, "java");
+	public JavaCommentHeuristicChecker(int limit, PrintStream out) {
+		super(JAVA_COMMENT_REGEX, limit, "java", out);

  	}

=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/JavaScriptCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/JavaScriptCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There are two types of comments in java one starts with // and ends  
when line
   * ends; second starts with /* and ends with * /. More info on:
@@ -34,9 +36,8 @@
  	 */
  	private static final String JAVA_SCRIPT_COMMENT_REGEX = "(/\\*(?:[^*]| 
(?:\\*+[^*/]))*\\*+/)|(//.*[\\n\\r])";

-	public JavaScriptCommentHeuristicChecker(int limit) {
-		super(JAVA_SCRIPT_COMMENT_REGEX, limit, "javascript");
-
+	public JavaScriptCommentHeuristicChecker(int limit, PrintStream out) {
+		super(JAVA_SCRIPT_COMMENT_REGEX, limit, "javascript", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/LispCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/LispCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There are two types of comments in Lisp. A line comments in Lisp starts  
with
   * ; and ends with a end of a line. Block comments in Lisp starts with #|  
and
@@ -36,8 +38,7 @@
  	 */
  	private static final String LISP_COMMENT_REGEX = "(#\\|(?:[^*]|(?:\\| 
+[^(\\|#)]))*\\|+#)|(;.*[\\n\\r])";

-	public LispCommentHeuristicChecker(int limit) {
-		super(LISP_COMMENT_REGEX, limit,"lisp");
-
+	public LispCommentHeuristicChecker(int limit, PrintStream out) {
+		super(LISP_COMMENT_REGEX, limit, "lisp", out);
  	}
  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PHPCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PHPCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There are two types of a line comments and one type of block comments  
in PHP.
   * Block comments in PHP starts with / * and ends with * / First type of a  
line
@@ -37,9 +39,8 @@
  	 */
  	private static final String PHP_COMMENT_REGEX = "(#.*[\\n\\r])| 
((/\\*(?:[^*]|(?:\\*+[^*/]))*\\*+/)|(//.*[\\n\\r]))";

-	public PHPCommentHeuristicChecker(int limit) {
-		super(PHP_COMMENT_REGEX, limit, "php");
-
+	public PHPCommentHeuristicChecker(int limit, PrintStream out) {
+		super(PHP_COMMENT_REGEX, limit, "php", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PascalCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PascalCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,11 +20,14 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There are 4 types of comments allowed in standard Pascal: <li>1.{this  
is a
   * valid comment} <li>2.(*this is a valid comment too} <li>3.(*this is a  
valid
- * comment*) <li>4.{this is a valid comment*) <p>This class recognize only  
pure
- * comments, without text before or after it.
+ * comment*) <li>4.{this is a valid comment*)
+ * <p>
+ * This class recognize only pure comments, without text before or after  
it.
   *
   * @author maka
   */
@@ -37,8 +40,7 @@
  	 */
  	private static final String PASCAL_COMMENT_REGEX = "(\\{.*\\})| 
(\\{.*\\*\\))|(\\(\\*.*\\*\\))|(\\(\\*.*\\})";

-	public PascalCommentHeuristicChecker(int limit) {
-		super(PASCAL_COMMENT_REGEX, limit, "pascal");
-
+	public PascalCommentHeuristicChecker(int limit, PrintStream out) {
+		super(PASCAL_COMMENT_REGEX, limit, "pascal", out);
  	}
  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PerlCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PerlCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There is only one type of comments in Perl. Perl uses comments that  
start
   * with a #, and continue till the end of the line. More info on:
@@ -37,9 +39,8 @@
  	 */
  	private static final String PERL_COMMENT_REGEX = "(#.*[\\n\\r])";

-	public PerlCommentHeuristicChecker(int limit) {
-		super(PERL_COMMENT_REGEX, limit, "perl");
-
+	public PerlCommentHeuristicChecker(int limit, PrintStream out) {
+		super(PERL_COMMENT_REGEX, limit, "perl", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PythonCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PythonCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There are two types of comments in Python. Python uses comments that  
start
   * with a #, and continue till the end of the line and uses triple-quotes  
for
@@ -35,8 +37,8 @@
  	 */
  	private static final String PYTHON_COMMENT_REGEX = "(#.*[\\n\\r])| 
(\"\"\"[ [\\n\\r](\\w)]*\"\"\")";

-	public PythonCommentHeuristicChecker(int limit) {
-		super(PYTHON_COMMENT_REGEX, limit,"python");
+	public PythonCommentHeuristicChecker(int limit, PrintStream out) {
+		super(PYTHON_COMMENT_REGEX, limit, "python", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/RubyCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/RubyCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There is only one type of comments in Ruby. Ruby uses comments that  
start
   * with a #, and continue till the end of the line.
@@ -35,8 +37,8 @@
  	 */
  	private static final String RUBY_COMMENT_REGEX = "(#.*[\\n\\r])";

-	public RubyCommentHeuristicChecker(int limit) {
-		super(RUBY_COMMENT_REGEX, limit, "ruby");
+	public RubyCommentHeuristicChecker(int limit, PrintStream out) {
+		super(RUBY_COMMENT_REGEX, limit, "ruby", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/SQLCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/SQLCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -19,6 +19,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There are two types of comments in SQL. First type of comments starts  
with a
   * two consecutive hyphens and last till the end of a line. Second one,  
startsF
@@ -34,9 +36,8 @@
  	 */
  	private static final String SQL_COMMENT_REGEX = "(/\\*(?:[^*]| 
(?:\\*+[^*/]))*\\*+/)|(--.*[\\n\\r])";

-	public SQLCommentHeuristicChecker(int limit) {
-		super(SQL_COMMENT_REGEX, limit, "sql");
-
+	public SQLCommentHeuristicChecker(int limit, PrintStream out) {
+		super(SQL_COMMENT_REGEX, limit, "sql", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ShellCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ShellCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  /**
   * There is only one type of comments in Shell. Shell uses comments that  
start
   * with a #, and continue till the end of the line.
@@ -35,7 +37,7 @@
  	 */
  	private static final String SHELL_COMMENT_REGEX = "(#.*[\\n\\r])";

-	public ShellCommentHeuristicChecker(int limit) {
-		super(SHELL_COMMENT_REGEX, limit, "shell");
+	public ShellCommentHeuristicChecker(int limit, PrintStream out) {
+		super(SHELL_COMMENT_REGEX, limit, "shell", out);
  	}
  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/VisualBasicCommentHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/VisualBasicCommentHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.comment;

+import java.io.PrintStream;
+
  import org.apache.rat.pd.heuristic.IHeuristicChecker;

  /**
@@ -36,9 +38,8 @@
  	 */
  	private static final String VISUAL_BASIC_COMMENT_REGEX  
= "(\\s*\\'.*[\\n\\r])+";

-	public VisualBasicCommentHeuristicChecker(int limit) {
-		super(VISUAL_BASIC_COMMENT_REGEX, limit,  
IHeuristicChecker.ALL_LANGUAGES);
-
-	}
-
-}
+	public VisualBasicCommentHeuristicChecker(int limit, PrintStream out) {
+		super(VISUAL_BASIC_COMMENT_REGEX, limit,
+				IHeuristicChecker.ALL_LANGUAGES, out);
+	}
+}
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/ActionScriptFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/ActionScriptFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
+
  /**
   * Functions in ActionScript can exist in two ways: <li>function
   * functionName(listOfParameters){function body} <li>function
@@ -47,9 +49,9 @@
  	 */
  	private static final String ACTION_SCRIPT_FUNCTION_REGEX = "function  
+\\w+ *\\([\\s\\S]*\\)(( *\\: *\\w+)){0,1}\\s*\\{[\\s\\S]*\\}[\n\r]*";

-	public ActionScriptFunctionHeuristicChecker(int limit) {
+	public ActionScriptFunctionHeuristicChecker(int limit, PrintStream out) {
  		super(limit, ACTION_SCRIPT_FUNCTION_REGEX,
-				ACTION_SCRIPT_OPENED_BRACKET,  
ACTION_SCRIPT_CLOSED_BRACKET, "actionscript");
+				ACTION_SCRIPT_OPENED_BRACKET,  
ACTION_SCRIPT_CLOSED_BRACKET, "actionscript", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
+
  /**
   * Function in C consists of function definition and function body. There  
are
   * special constructions called "inline functions" and "macro functions"  
too.
@@ -110,8 +112,8 @@
  	private static final String FUNCTION_REGEX = "(" + C_FUNCTION_REGEX + ")"
  			+ OR_REGEX + C_MACRO_REGEX + OR_REGEX + C_INLINE_FUNCTION;

-	public CFunctionHeuristicChecker(int limit) {
-		super(limit, FUNCTION_REGEX, C_OPENED_BRACKET, C_CLOSED_BRACKET, "c");
+	public CFunctionHeuristicChecker(int limit, PrintStream out) {
+		super(limit, FUNCTION_REGEX, C_OPENED_BRACKET, C_CLOSED_BRACKET, "c",  
out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CPPFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CPPFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
+
  /**
   * Function in C++ consists of function definition and function body.  
There are
   * special constructions called "inline functions" and "macro  
functions"too.
@@ -124,8 +126,8 @@
  	private static final String FUNCTION_REGEX = CPP_FUNCTION_REGEX + OR_REGEX
  			+ CPP_MACRO_REGEX + OR_REGEX + CPP_INLINE_FUNCTION;

-	public CPPFunctionHeuristicChecker(int limit) {
-		super(limit, FUNCTION_REGEX, CPP_OPENED_BRACKET,  
CPP_CLOSED_BRACKET, "c++");
+	public CPPFunctionHeuristicChecker(int limit, PrintStream out) {
+		super(limit, FUNCTION_REGEX, CPP_OPENED_BRACKET,  
CPP_CLOSED_BRACKET, "c++", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CSharpFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CSharpFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
+
  /**
   * This class can match C# functions.
   * More info on: {@link}  
http://en.wikipedia.org/wiki/C_Sharp_(programming_language)
@@ -38,9 +40,9 @@
  	private static final String C_SHARP_FUNCTION_REGEX = "^[\t  
]*[(public)(protected)(private)(static)(void)(abstract)\\w+]*  
+(.*)\\([\\s\\S]*\\)(\\s)*"
  			+ "\\{[\\s\\S]*\\}[\n\r]*";

-	public CSharpFunctionHeuristicChecker(int limit) {
+	public CSharpFunctionHeuristicChecker(int limit, PrintStream out) {
  		super(limit, C_SHARP_FUNCTION_REGEX, C_SHARP_OPENED_BRACKET,
-				C_SHARP_CLOSED_BRACKET, "c#");
+				C_SHARP_CLOSED_BRACKET, "c#", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/DelphiFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/DelphiFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
+
  /**
   * Delphi provides 2 types of subroutine - Procedures and Functions.  
Functions
   * are the same as procedures except that they return a value in addition  
to
@@ -51,9 +53,9 @@
  	private static final String DELPHI_SUBROUTINE_REGEX = "("
  			+ DELPHI_FUNCTION_REGEX + ")|(" + DELPHI_PROCEDURE_REGEX + ")";

-	public DelphiFunctionHeuristicChecker(int limit) {
+	public DelphiFunctionHeuristicChecker(int limit, PrintStream out) {
  		super(limit, DELPHI_SUBROUTINE_REGEX, DELPHI_OPENED_BRACKET,
-				DELPHI_CLOSED_BRACKET, "pascal");
+				DELPHI_CLOSED_BRACKET, "pascal", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/FortranFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/FortranFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,7 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
  import java.util.regex.Matcher;
  import java.util.regex.Pattern;

@@ -70,17 +71,16 @@

  	private int limit;
  	private final String language;
-
-	public FortranFunctionHeuristicChecker(int limit) {
+	private final PrintStream out;
+
+	public FortranFunctionHeuristicChecker(int limit, PrintStream out) {

  		this.limit = limit;
  		this.language = "fortran";
+		this.out = out;
  	}

  	@Override
-	/**
-	 *
-	 */
  	public HeuristicCheckerResult checkByHeuristic(String codeToBeChecked) {
  		HeuristicCheckerResult toret = new HeuristicCheckerResult(false,
  				true, codeToBeChecked, this.getClass());
@@ -128,7 +128,7 @@
  		boolean toret = false;
  		String functionRegex = functionHeader + "[\\s\\S]*"
  				+ functionEndRegex;
-		System.out.println(functionRegex);
+		out.println(functionRegex);
  		Pattern p = Pattern.compile(functionRegex, Pattern.MULTILINE);
  		// Run matches
  		Matcher m = p.matcher(codeToBeChecked);
@@ -136,7 +136,7 @@
  		if (m.find()) {
  			String found = m.group();
  			if (codeToBeChecked.equals(found)) {
-				System.out.println("Found function: " + found);
+				out.println("Found function: " + found);
  				toret = found.length() > limit ? true : false;
  			}
  		}
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/FunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/FunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,7 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
  import java.util.regex.Matcher;
  import java.util.regex.Pattern;

@@ -39,14 +40,16 @@
  	private final String FUNCTION_REGEX;
  	private final int limit;
  	private final String language;
+	private final PrintStream out;

  	public FunctionHeuristicChecker(int limit, String regex,
-			String openedBrackets, String closedBrackets, String language) {
+			String openedBrackets, String closedBrackets, String language,  
PrintStream out) {
  		this.limit = limit;
  		this.FUNCTION_REGEX = regex;
  		this.CLOSED_BRACKET = closedBrackets;
  		this.OPENED_BRACKET = openedBrackets;
  		this.language = language;
+		this.out = out;
  	}

  	public HeuristicCheckerResult checkByHeuristic(String codeToBeChecked) {
@@ -64,7 +67,7 @@
  						&& filterWrongMatches(found) ? true : false;
  				toret = new HeuristicCheckerResult(isSearchNeaded,
  						false, found, this.getClass());
-				System.out.println("Found function: " + found);
+				out.println("Found function: " + found);
  			}
  		}
  		return toret;
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/JavaFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/JavaFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
+
  /**
   * This class can match java functions from source code. Only condition is  
that
   * function definition must start from new line. More info about Java  
functions
@@ -43,9 +45,9 @@
  	private static final String JAVA_FUNCTION_REGEX = "^[\t  
]*([(\\w+)<>\\[\\]]|( +))+ +(\\w+) *\\([\\s\\S]*\\) *(throws +\\w+)*\\s*"
  			+ "\\{[\\s\\S]*\\}[\n\r]*";

-	public JavaFunctionHeuristicChecker(int limit) {
+	public JavaFunctionHeuristicChecker(int limit, PrintStream out) {
  		super(limit, JAVA_FUNCTION_REGEX, JAVA_OPENED_BRACKET,
-				JAVA_CLOSED_BRACKET, "java");
+				JAVA_CLOSED_BRACKET, "java", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/JavaScriptFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/JavaScriptFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -19,6 +19,8 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
+
  /**
   * This class can match functions from JavaScript. More info about  
functions in
   * JavaScript: {@link} http://www.w3schools.com/jS/js_functions.asp
@@ -40,9 +42,9 @@
  	 */
  	private static final String JAVA_SCRIPT_FUNCTION_REGEX = "function +\\w+  
*\\([\\s\\S]*\\)\\s*\\{[\\s\\S]*\\}[\n\r]*";

-	public JavaScriptFunctionHeuristicChecker(int limit) {
+	public JavaScriptFunctionHeuristicChecker(int limit, PrintStream out) {
  		super(limit, JAVA_SCRIPT_FUNCTION_REGEX, JAVA_SCRIPT_OPENED_BRACKET,
-				JAVA_SCRIPT_CLOSED_BRACKET, "javascript");
+				JAVA_SCRIPT_CLOSED_BRACKET, "javascript", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/PHPFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/PHPFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
+
  /**
   * This class can match PHP functions. More info about functions in PHP on:
   * {@link} http://www.w3schools.com/PHP/php_functions.asp
@@ -37,8 +39,8 @@
  	 */
  	private static final String PHP_FUNCTION_REGEX = "function +\\w+  
*\\([\\s\\S]*\\)\\s*\\{[\\s\\S]*\\}[\n\r]*";

-	public PHPFunctionHeuristicChecker(int limit) {
-		super(limit, PHP_FUNCTION_REGEX, PHP_OPENED_BRACKET,  
PHP_CLOSED_BRACKET, "php");
+	public PHPFunctionHeuristicChecker(int limit, PrintStream out) {
+		super(limit, PHP_FUNCTION_REGEX, PHP_OPENED_BRACKET,  
PHP_CLOSED_BRACKET, "php", out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/PascalFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/PascalFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
+
  /**
   * This class recognize procedures and functions in Pascal. More info on:
   * http://www.learn-programming.za.net/programming_pascal_learn09.html
@@ -52,8 +54,8 @@
  	private static final String PASCAL_SUBPROGRAM_REGEX = "("
  			+ PASCAL_FUNCTION_REGEX + ")|(" + PASCAL_PROCEDURE_REGEX + ")";

-	public PascalFunctionHeuristicChecker(int limit) {
+	public PascalFunctionHeuristicChecker(int limit, PrintStream out) {
  		super(limit, PASCAL_SUBPROGRAM_REGEX, PASCAL_OPENED_BRACKET,
-				PASCAL_CLOSED_BRACKET, "pascal");
+				PASCAL_CLOSED_BRACKET, "pascal", out);
  	}
  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/VisualBasicFunctionHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/VisualBasicFunctionHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -20,6 +20,8 @@
   */
  package org.apache.rat.pd.heuristic.functions;

+import java.io.PrintStream;
+
  import org.apache.rat.pd.heuristic.IHeuristicChecker;

  /**
@@ -105,9 +107,9 @@
  	private static final String VISUAL_BASIC_SUBPROGRAMS_REGEX =  
VISUAL_BASIC_FUNCTION_REGEX
  			+ "|" + VISUAL_BASIC_SUBROUTINES_REGEX;

-	public VisualBasicFunctionHeuristicChecker(int limit) {
+	public VisualBasicFunctionHeuristicChecker(int limit, PrintStream out) {
  		super(limit, VISUAL_BASIC_SUBPROGRAMS_REGEX,
-				VISUAL_BASIC_OPENED_BRACKET, VISUAL_BASIC_CLOSED_BRACKET,  
IHeuristicChecker.ALL_LANGUAGES);
+				VISUAL_BASIC_OPENED_BRACKET, VISUAL_BASIC_CLOSED_BRACKET,  
IHeuristicChecker.ALL_LANGUAGES, out);
  	}

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/misspellings/MisspellingsHeuristicChecker.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/misspellings/MisspellingsHeuristicChecker.java	 
Sat Aug  1 05:56:47 2009
@@ -21,6 +21,7 @@
  package org.apache.rat.pd.heuristic.misspellings;

  import java.io.IOException;
+import java.io.PrintStream;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
@@ -40,10 +41,12 @@

  	private IDictionary spellChecker;
  	private final String language;
-
-	public MisspellingsHeuristicChecker(IDictionary dictionary, String  
language) {
+	private final PrintStream out;
+
+	public MisspellingsHeuristicChecker(IDictionary dictionary, String  
language, PrintStream out) {
  		this.spellChecker = dictionary;
  		this.language = language;
+		this.out = out;
  	}

  	/**
@@ -66,7 +69,7 @@
  				isCheckingOnInternetNeaded = isCheckingOnInternetNeaded &&  
isWordCorrect(decomposeCombinedWord(word));
  			} catch (Exception e) {
  				isCheckingOnInternetNeaded = false;
-				System.out.println("Error in decomposing word:" + word
+				out.println("Error in decomposing word:" + word
  						+ " We consider that it is misspelled.");
  			}
  		}
@@ -98,7 +101,7 @@
  			// it is assumed that words with capital case are equal to word with
  			// all small case in dictionary
  			toret = toret && spellChecker.exist(word.toLowerCase());
-			System.out.println(word + " " + toret);
+			out.println(word + " " + toret);
  		}
  		return toret;
  	}
=======================================
--- /trunk/src/test/java/org/apache/rat/pd/core/PdCommandLineTest.java	Fri  
May 29 15:33:07 2009
+++ /trunk/src/test/java/org/apache/rat/pd/core/PdCommandLineTest.java	Sat  
Aug  1 05:56:47 2009
@@ -26,7 +26,7 @@

  	public void testNoArgs() {

-		PdCommandLine pdCommandLine = new PdCommandLine(new String[] {});
+		PdCommandLine pdCommandLine = new PdCommandLine(new String[] {},  
System.out);
  		assertNull("I assert that code base property is null", pdCommandLine
  				.getCodebase());
  		assertEquals("I assert that the size of engines list is 0", 0,
@@ -37,50 +37,61 @@
  				pdCommandLine.getReport());
  		assertFalse("I assert that the flag is set to false", pdCommandLine
  				.isAllArgumentsCorrect());
+		assertNull("I assert that the language is not set", pdCommandLine
+				.getLanguage());
  	}

  	public void testCodebaseArg() {
  		PdCommandLine pdCommandLine = new PdCommandLine(new String[] { "-cb",
-				"c:/src" });
+				"c:/src" }, System.out);
  		assertEquals("c:/src", pdCommandLine.getCodebase());
  		pdCommandLine = new PdCommandLine(
-				new String[] { "-codebase", "c:/src" });
+				new String[] { "-codebase", "c:/src" }, System.out);
  		assertEquals("c:/src", pdCommandLine.getCodebase());
  		pdCommandLine = new PdCommandLine(new String[] { "-cb", "c:/src",
-				"c:/src2" });
+				"c:/src2" }, System.out);
  		assertEquals("c:/src", pdCommandLine.getCodebase());

  	}

  	public void testAllArgs() {
  		String[] args = new String[] { "-cb", "c:/src", "-report", "rep.txt",
-				"-limit", "23", "-engines", "myEngine", "-heur", "myHeuristic" };
-		PdCommandLine pdCommandLine = new PdCommandLine(args);
+				"-limit", "23", "-engines", "myEngine", "-heur", "myHeuristic",
+				"-lang", "java" };
+		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that codebase is c:/src", "c:/src",
  				pdCommandLine.getCodebase());
  		assertEquals("rep.txt", pdCommandLine.getReport());
  		assertEquals(23, pdCommandLine.getLimit());
  		assertEquals("myEngine", pdCommandLine.getEngines().get(0));
  		assertEquals("myHeuristic", pdCommandLine.getHeuristics().get(0));
+		assertEquals("java", pdCommandLine.getLanguage());

  		args = new String[] { "-cb", "c:/src", "-report", "rep.txt", "-limit",
-				"23", "-e", "myEngine", "myEngine2", "-heur", "myHeuristic" };
-		pdCommandLine = new PdCommandLine(args);
+				"23", "-e", "myEngine", "myEngine2", "-heur", "myHeuristic",
+				"-language", "c++" };
+
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that there are two engines", 2, pdCommandLine
  				.getEngines().size());
  		assertEquals("I assert that first engine is myEngine", "myEngine",
  				pdCommandLine.getEngines().get(0));
  		assertEquals("I assert that second engine is myEngine2", "myEngine2",
  				pdCommandLine.getEngines().get(1));
+		assertEquals("c++", pdCommandLine.getLanguage());
+
  		args = new String[] { "-cb", "c:/src", "-report", "rep.txt", "-limit",
-				"23", "-engines", "myEngine,myEngine2", "-heur", "myHeuristic" };
-		pdCommandLine = new PdCommandLine(args);
+				"23", "-engines", "myEngine,myEngine2", "-heur", "myHeuristic",
+				"-language", "pascal" };
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("myEngine", pdCommandLine.getEngines().get(0));
  		assertEquals("myEngine2", pdCommandLine.getEngines().get(1));
+		assertEquals("pascal", pdCommandLine.getLanguage());
+
  		args = new String[] { "-cb", "c:/src", "-report", "rep.txt", "-limit",
  				"23", "-engines", "myEngine,myEngine2", "-heur", "myHeuristic",
  				"-engines", "myEngine3" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that there are 3 engines", 3, pdCommandLine
  				.getEngines().size());
  		assertEquals("I assert that first engine is myEngine", "myEngine",
@@ -92,7 +103,7 @@
  		args = new String[] { "-cb", "c:/src", "-report", "rep.txt", "-limit",
  				"23", "-engines", "myEngine,myEngine2", "-heur", "myHeuristic",
  				"-e", "myEngine3", "-heuristics", "myHeuristic2" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that there are 3 engines", 3, pdCommandLine
  				.getEngines().size());
  		assertEquals("I assert that first engine is myEngine", "myEngine",
@@ -113,14 +124,14 @@
  	public void testHeuristicArgs() {
  		String[] args = new String[] { "-heur", "myHeuristic", "-cb",
  				"codebase" };
-		PdCommandLine pdCommandLine = new PdCommandLine(args);
+		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that there is one heuristic", 1, pdCommandLine
  				.getHeuristics().size());
  		assertEquals("I assert that heuristic is myHeuristic", "myHeuristic",
  				pdCommandLine.getHeuristics().get(0));
  		args = new String[] { "-heuristics", "myHeuristic", "-cb", "codebase",
  				"-heuristics", "myHeuristic2" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that there are two heuristic", 2, pdCommandLine
  				.getHeuristics().size());
  		assertEquals("I assert that first heuristic is myHeuristic",
@@ -129,7 +140,7 @@
  				"myHeuristic2", pdCommandLine.getHeuristics().get(1));
  		args = new String[] { "-heuristics", "myHeuristic", "myHeuristic2",
  				"-cb", "codebase", "-heuristics", "myHeuristic3" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that there are three heuristic", 3,
  				pdCommandLine.getHeuristics().size());
  		assertEquals("I assert that first heuristic is myHeuristic",
@@ -138,9 +149,10 @@
  				"myHeuristic2", pdCommandLine.getHeuristics().get(1));
  		assertEquals("I assert that third heuristic is myHeuristic3",
  				"myHeuristic3", pdCommandLine.getHeuristics().get(2));
+
  		args = new String[] { "-heur", "myHeuristic,myHeuristic2", "-cb",
  				"codebase", "-heur", "myHeuristic3" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that there are three heuristic", 3,
  				pdCommandLine.getHeuristics().size());
  		assertEquals("I assert that first heuristic is myHeuristic",
@@ -154,14 +166,14 @@

  	public void testEnginesArgs() {
  		String[] args = new String[] { "-cb", "codebase", "-e", "myEngine" };
-		PdCommandLine pdCommandLine = new PdCommandLine(args);
+		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that there is one engine value", 1,
  				pdCommandLine.getEngines().size());
  		assertEquals("I assert that value of engine will be myEngine",
  				"myEngine", pdCommandLine.getEngines().get(0));
  		args = new String[] { "-cb", "codebase", "-engines", "myEngine", "-l",
  				"123" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that there is one engine value", 1,
  				pdCommandLine.getEngines().size());
  		assertEquals("I assert that value of engine will be myEngine",
@@ -171,11 +183,11 @@

  	public void testReportArg() {
  		String[] args = new String[] { "-cb", "codebase", "-report", "rep.txt" };
-		PdCommandLine pdCommandLine = new PdCommandLine(args);
+		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that report will be rep.txt", "rep.txt",
  				pdCommandLine.getReport());
  		args = new String[] { "-cb", "codebase", "-r", "rep.txt" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertEquals("I assert that report will be rep.txt", "rep.txt",
  				pdCommandLine.getReport());

@@ -183,19 +195,19 @@

  	public void testHelpArg() {
  		String[] args = new String[] { "-h" };
-		PdCommandLine pdCommandLine = new PdCommandLine(args);
+		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
  		assertFalse(
  				"I assert that only help will be printed - that means that  
isAllArgumentsCorrect returns false",
  				pdCommandLine.isAllArgumentsCorrect());

  		args = new String[] { "--help" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertFalse(
  				"I assert that only help will be printed - that means that  
isAllArgumentsCorrect returns false",
  				pdCommandLine.isAllArgumentsCorrect());

  		args = new String[] { "-h", "-cb", "c:/src" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertFalse(
  				"I assert that only help will be printed - that means that  
isAllArgumentsCorrect returns false",
  				pdCommandLine.isAllArgumentsCorrect());
@@ -204,7 +216,7 @@
  	public void testConfigurationFileParsingArg() {
  		String[] args = new String[] { "-config",
  				"src/test/resources/configuration/resources/config_test1.conf" };
-		PdCommandLine pdCommandLine = new PdCommandLine(args);
+		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
  		assertTrue(
  				"I assert that all arguments will be parsed from cconfig file - that  
means that isAllArgumentsCorrect returns true",
  				pdCommandLine.isAllArgumentsCorrect());
@@ -216,18 +228,20 @@
  		assertEquals("engine1", pdCommandLine.getEngines().get(0));
  		assertEquals("engine2", pdCommandLine.getEngines().get(1));
  		assertEquals("myheuristic", pdCommandLine.getHeuristics().get(0));
+		assertEquals("java", pdCommandLine.getLanguage());
+		assertTrue(pdCommandLine.isVerbose());
  		// it is not planed to use -h in config file but if we use it,it is
  		// supposed to give the same results as if it used from command line
  		args = new String[] { "-config",
  				"src/test/resources/configuration/resources/config_test2.conf" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertFalse(
  				"I assert that only help will be printed - that means that  
isAllArgumentsCorrect returns false",
  				pdCommandLine.isAllArgumentsCorrect());
  		// config file can be written in single line
  		args = new String[] { "-config",
  				"src/test/resources/configuration/resources/config_test3.conf" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertTrue(
  				"I assert that all arguments will be parsed from cconfig file - that  
means that isAllArgumentsCorrect returns true",
  				pdCommandLine.isAllArgumentsCorrect());
@@ -243,7 +257,7 @@
  		// it will ignore -config argument in config file
  		args = new String[] { "-config",
  				"src/test/resources/configuration/resources/config_test4.conf" };
-		pdCommandLine = new PdCommandLine(args);
+		pdCommandLine = new PdCommandLine(args, System.out);
  		assertTrue(
  				"I assert that all arguments will be parsed from cconfig file - that  
means that isAllArgumentsCorrect returns true",
  				pdCommandLine.isAllArgumentsCorrect());
@@ -254,12 +268,36 @@
  	}

  	public void testMallFormedConfigurationFileParsing() {
-		String[] args = new String[] {"-config",
+		String[] args = new String[] { "-config",
  			 
	"src/test/resources/configuration/resources/mallformed_config_test.conf" };
-		PdCommandLine pdCommandLine = new PdCommandLine(args);
+		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
  		assertFalse(
  				"I assert that only help will be printed - that means that  
isAllArgumentsCorrect returns false",
  				pdCommandLine.isAllArgumentsCorrect());

  	}
-}
+
+	public void testVerboseParsing() {
+		String[] args = new String[] { "-cb", "c:/src", "-report", "rep.txt",
+				"-limit", "23", "-e", "myEngine", "myEngine2", "-heur",
+				"myHeuristic", "-language", "c++", "-verbose" };
+		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
+		assertTrue(pdCommandLine.isVerbose());
+
+		args = new String[] { "-cb", "c:/src", "-report", "rep1.txt", "-v" };
+		pdCommandLine = new PdCommandLine(args, System.out);
+		assertTrue(pdCommandLine.isVerbose());
+	}
+
+	public void testLanguageParsing() {
+		String[] args = new String[] { "-cb", "c:/src", "-report", "rep.txt",
+				"-limit", "23", "-e", "myEngine", "myEngine2", "-heur",
+				"myHeuristic", "-language", "c++", "-verbose" };
+		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
+		assertEquals("c++", pdCommandLine.getLanguage());
+
+		args = new String[] { "-cb", "c:/src", "-language", "c++"  };
+		pdCommandLine = new PdCommandLine(args, System.out);
+		assertEquals("c++", pdCommandLine.getLanguage());
+	}
+}
=======================================
---  
/trunk/src/test/java/org/apache/rat/pd/core/SlidingWindowAlgorithmTest.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/test/java/org/apache/rat/pd/core/SlidingWindowAlgorithmTest.java	 
Sat Aug  1 05:56:47 2009
@@ -58,7 +58,7 @@
  		checkers = new ArrayList<IHeuristicChecker>();

  		analyser = new SourceCodeAnalyser(searchEngines, checkers,
-				reportDocument);
+				reportDocument, System.out);

  	}

=======================================
---  
/trunk/src/test/java/org/apache/rat/pd/engines/google/GoogleCodeSearchParserTest.java	 
Sat Jul 25 03:08:02 2009
+++  
/trunk/src/test/java/org/apache/rat/pd/engines/google/GoogleCodeSearchParserTest.java	 
Sat Aug  1 05:56:47 2009
@@ -28,7 +28,7 @@

  public class GoogleCodeSearchParserTest extends TestCase {

-	private GoogleCodeSearchParser parser = new GoogleCodeSearchParser("lag");
+	private GoogleCodeSearchParser parser = new GoogleCodeSearchParser("lag",  
System.out);

  	public void testSplitLongUrl() throws IOException{
  		//minimum length is 96
@@ -38,7 +38,7 @@
  		actual = parser.splitLongUrl("a\nb", 100);
  		assertEquals(2,actual.size());

-		actual = parser.splitLongUrl("a\nb", 125);
+		actual = parser.splitLongUrl("a\nb", 135);
  		assertEquals(1,actual.size());

  		actual = parser.splitLongUrl("a\nb\nc", 100);
=======================================
---  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/CCommentHeuristicCheckerTest.java	 
Sun Jul 12 17:28:44 2009
+++  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/CCommentHeuristicCheckerTest.java	 
Sat Aug  1 05:56:47 2009
@@ -39,7 +39,7 @@

  	protected void setUp() throws Exception {
  		super.setUp();
-		checker = new CCommentHeuristicChecker(5);
+		checker = new CCommentHeuristicChecker(5, System.out);

  	}

=======================================
---  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/CobolCommentHeuristicCheckerTest.java	 
Sun Jul 12 17:28:44 2009
+++  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/CobolCommentHeuristicCheckerTest.java	 
Sat Aug  1 05:56:47 2009
@@ -44,7 +44,7 @@
  	 */
  	protected void setUp() throws Exception {
  		super.setUp();
-		checker = new CobolCommentHeuristicChecker(5);
+		checker = new CobolCommentHeuristicChecker(5, System.out);

  	}

=======================================
---  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/ColdFusionCommentsheuristicCheckerTest.java	 
Sun Jul 12 17:28:44 2009
+++  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/ColdFusionCommentsheuristicCheckerTest.java	 
Sat Aug  1 05:56:47 2009
@@ -43,7 +43,7 @@
  	 */
  	protected void setUp() throws Exception {
  		super.setUp();
-		checker = new ColdFusionCommentsheuristicChecker(5);
+		checker = new ColdFusionCommentsheuristicChecker(5, System.out);

  	}

=======================================
---  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/DelphiCommentHeuristicCheckerTest.java	 
Sun Jul 12 17:28:44 2009
+++  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/DelphiCommentHeuristicCheckerTest.java	 
Sat Aug  1 05:56:47 2009
@@ -44,7 +44,7 @@
  	 */
  	protected void setUp() throws Exception {
  		super.setUp();
-		checker = new DelphiCommentHeuristicChecker(5);
+		checker = new DelphiCommentHeuristicChecker(5, System.out);

  	}

=======================================
---  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/FortranCommentHeuristicCheckerTest.java	 
Sun Jul 12 17:28:44 2009
+++  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/FortranCommentHeuristicCheckerTest.java	 
Sat Aug  1 05:56:47 2009
@@ -46,7 +46,7 @@
  	 */
  	protected void setUp() throws Exception {
  		super.setUp();
-		checker = new FortranCommentHeuristicChecker(5);
+		checker = new FortranCommentHeuristicChecker(5, System.out);

  	}

=======================================
---  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/HTMLCommentHeuristicCheckerTest.java	 
Sun Jul 12 17:28:44 2009
+++  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/HTMLCommentHeuristicCheckerTest.java	 
Sat Aug  1 05:56:47 2009
@@ -45,7 +45,7 @@
  	 */
  	protected void setUp() throws Exception {
  		super.setUp();
-		checker = new HTMLCommentHeuristicChecker(5);
+		checker = new HTMLCommentHeuristicChecker(5, System.out);

  	}

=======================================
---  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/JavaCommentHeuristicCheckerTest.java	 
Sun Jul 12 17:28:44 2009
+++  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/JavaCommentHeuristicCheckerTest.java	 
Sat Aug  1 05:56:47 2009
@@ -56,7 +56,7 @@
  	protected void setUp() throws Exception {
  		super.setUp();

-		checker = new JavaCommentHeuristicChecker(5);
+		checker = new JavaCommentHeuristicChecker(5, System.out);

  	}

=======================================
---  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/LispCommentHeuristicCheckerTest.java	 
Sun Jul 12 17:28:44 2009
+++  
/trunk/src/test/java/org/apache/rat/pd/heuristic/comment/LispCommentHeuristicCheckerTest.java	 
Sat Aug  1 05:56:47 2009
@@ -43,7 +43,7 @@
  	 */
  	protected void setUp() throws Exception {
  		super.setUp();
-		checker = new LispCommentHeuristicChecker(5);
+		checker = new LispCommentHeuristicChecker(5, System.out);

  	}

=======================================
***Additional files exist in this changeset.***

Mime
View raw message