You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@creadur.apache.org by co...@google.com on 2009/08/21 15:54:25 UTC

[apache-rat-pd] r52 committed - Whole code is being formated using different formatter....

Revision: 52
Author: maka82
Date: Fri Aug 21 06:53:09 2009
Log: Whole code is being formated using different formatter.
Formatter that has been used is with spaces only,  4 spaces indentination  
and max-line length of 120 characters.
No other changes have been made.
http://code.google.com/p/apache-rat-pd/source/detail?r=52

Modified:
  /trunk/src/main/java/org/apache/rat/pd/core/PauseListener.java
  /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/PlagiarismDetectorReport.java
  /trunk/src/main/java/org/apache/rat/pd/core/SourceCodeAnalyser.java
  /trunk/src/main/java/org/apache/rat/pd/engines/ISearchEngine.java
  /trunk/src/main/java/org/apache/rat/pd/engines/KodersCodeSearchParser.java
  /trunk/src/main/java/org/apache/rat/pd/engines/Managable.java
  /trunk/src/main/java/org/apache/rat/pd/engines/RetryManager.java
  /trunk/src/main/java/org/apache/rat/pd/engines/SearchResult.java
   
/trunk/src/main/java/org/apache/rat/pd/engines/google/GoogleCodeSearchParser.java
   
/trunk/src/main/java/org/apache/rat/pd/engines/google/MultilineRegexGenerator.java
  /trunk/src/main/java/org/apache/rat/pd/engines/google/RegexGenerator.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/BruteForceHeuristicChecker.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/HeuristicCheckerResult.java
  /trunk/src/main/java/org/apache/rat/pd/heuristic/IHeuristicChecker.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/Dictionary.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/misspellings/IDictionary.java
   
/trunk/src/main/java/org/apache/rat/pd/heuristic/misspellings/MisspellingsHeuristicChecker.java
  /trunk/src/main/java/org/apache/rat/pd/report/HtmlReportGenerator.java
  /trunk/src/main/java/org/apache/rat/pd/report/IReport.java
  /trunk/src/main/java/org/apache/rat/pd/report/Report.java
  /trunk/src/main/java/org/apache/rat/pd/report/ReportEntry.java
  /trunk/src/main/java/org/apache/rat/pd/report/TxtReportGenerator.java
  /trunk/src/main/java/org/apache/rat/pd/report/XmlReportGenerator.java
  /trunk/src/main/java/org/apache/rat/pd/util/FileManipulator.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/engines/google/MultilineRegexGeneratorTest.java
   
/trunk/src/test/java/org/apache/rat/pd/engines/google/RegexGeneratorTest.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/comments/JavaComments.java

=======================================
--- /trunk/src/main/java/org/apache/rat/pd/core/PauseListener.java	Mon Jul  
20 14:56:49 2009
+++ /trunk/src/main/java/org/apache/rat/pd/core/PauseListener.java	Fri Aug  
21 06:53:09 2009
@@ -23,61 +23,57 @@
  import java.io.IOException;

  /**
- *
   * This is the way to implement something like KeyListener in console
   * applications. This Thread will listen keystroke and if enter is pressed  
it
- * will call proper methods.
- *
- * To use this class it is needed to override and implement it's methods  
onPause
- * and onResume in derived class (hook design pattern).
- *
+ * will call proper methods. To use this class it is needed to override and
+ * implement it's methods onPause and onResume in derived class (hook  
design
+ * pattern).
   *
   * @author maka
- *
   */
  public class PauseListener extends Thread {
-
-	private boolean paused = false;
-
-	@Override
-	public void run() {
-		while (true) {
-			try {
-				sleep(500);
-				// read all input characters and expect enter
-				while (System.in.available() > 0) {
-					System.in.read();
-					// only for last one character we do something
-					if (System.in.available() == 0) {
-						paused = !paused;
-						if (paused)
-							onPause();
-						else
-							onResume();
-					}
-				}
-
-			} catch (IOException e) {
-				// swallow exception
-			} catch (InterruptedException e) {
-				// swallow exception
-			}
-		}
-	}
-
-	/**
-	 * override this function if want to do something when pause event is
-	 * happened
-	 */
-	public void onPause() {
-		// override and implement me
-	}
-
-	/**
-	 * override this function if want to do something when resume event is
-	 * happened
-	 */
-	public void onResume() {
-		// override and implement me
-	}
-}
+
+    private boolean paused = false;
+
+    @Override
+    public void run() {
+        while (true) {
+            try {
+                sleep(500);
+                // read all input characters and expect enter
+                while (System.in.available() > 0) {
+                    System.in.read();
+                    // only for last one character we do something
+                    if (System.in.available() == 0) {
+                        paused = !paused;
+                        if (paused)
+                            onPause();
+                        else
+                            onResume();
+                    }
+                }
+
+            } catch (IOException e) {
+                // swallow exception
+            } catch (InterruptedException e) {
+                // swallow exception
+            }
+        }
+    }
+
+    /**
+     * override this function if want to do something when pause event is
+     * happened
+     */
+    public void onPause() {
+        // override and implement me
+    }
+
+    /**
+     * override this function if want to do something when resume event is
+     * happened
+     */
+    public void onResume() {
+        // override and implement me
+    }
+}
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/core/PdCommandLine.java	Sun Aug  
16 16:43:54 2009
+++ /trunk/src/main/java/org/apache/rat/pd/core/PdCommandLine.java	Fri Aug  
21 06:53:09 2009
@@ -39,397 +39,364 @@
  /**
   * This class can parse command line arguments and retrieve arguments from  
file.
   * If some arguments are not provided, it set default values to them. Only
- * -codebase argument is required.
- *
- * Arguments passed to constructor are parsed and values are set to proper  
class
- * member. After that configuration file is parsed. If path to  
configuration
- * file is provided by command line argument, we try to parse that  
configuration
- * file. Otherwise, default configuration "config.conf" file is parsed.  
After
- * this two steps if any of members is not initialized, we initialize them  
with
- * default values.
- *
- * Finally, report,codebase,limit,engines, heuristics and  
allArgumentsCorrect
- * are initialized.
- *
- * If allArgumentsCorrect is true, we can use parsed values. Otherwise, we  
can
- * just print usage.
+ * -codebase argument is required. Arguments passed to constructor are  
parsed
+ * and values are set to proper class member. After that configuration  
file is
+ * parsed. If path to configuration file is provided by command line  
argument,
+ * we try to parse that configuration file. Otherwise, default  
configuration
+ * "config.conf" file is parsed. After this two steps if any of members is  
not
+ * initialized, we initialize them with default values. Finally,
+ * report,codebase,limit,engines, heuristics and allArgumentsCorrect are
+ * initialized. If allArgumentsCorrect is true, we can use parsed values.
+ * Otherwise, we can just print usage.
   *
   * @author maka
- *
   */
  public class PdCommandLine {
-	// possible report formats
-	public static final String HTML_MODE = "html";
-	public static final String TEXT_MODE = "txt";
-	public static final String XML_MODE = "xml";
-
-	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";
-	private static final String LIMIT_OPT_DESC = "integer from 1 to 100,1 is  
almost brute force and 100 is heuristic";
-	private static final String CODEBASE_OPT_DESC = "name of source code  
directory";
-	private static final String REPORT_OPT_DESC = "name of the report  
file;\nextension of file determines report format:"
-			+ "\n\t.xml  - report will be xml document"
-			+ "\n\t.html - report will be html document"
-			+ "\n\t.txt  - report will be txt document"
-			+ "\nDefault is report.html.";
-	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";
-	private static final String LIMIT_OPT_SHORT = "l";
-	private static final String CODEBASE_OPT_SHORT = "cb";
-	private static final String REPORT_OPT_SHORT = "r";
-	private static final String HELP_OPT_SHORT = "h";
-	public static final int DEFAULT_LIMIT = 10;
-	public static final String DEFAULT_HEURISTIC  
= "BruteForceHeuristicChecker";
-	public static final String DEFAULT_ENGINE = "GoogleCodeSearchParser";
-	public static final String DEFAULT_REPORT = "report.html";
-	private static final String DEFAULT_HEURISTIC_MSG = "Heuristic is not  
set.In use is default checker: ";
-	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";
-	private static final String LIMIT_OPT_LONG = "limit";
-	private static final String CODEBASE_OPT_LONG = "codebase";
-	private static final String REPORT_OPT_LONG = "report";
-	private static final String HELP_OPT_LONG = "help";
-
-	// this are properties which can be parsed from
-	// command line or from configuration file
-	private Options options = new Options();
-	private String report;
-	private String codebase;
-	/**
-	 * Limit is user-defined constants 1-100 and it is used to measure how
-	 * aggressively will be used search engines if we put there 10 =little  
usage
-	 * of Internet (search engines) if we put there 90 =almost bruteforce
-	 * checking will be run
-	 */
-	private int limit;
-	private List<String> engines = new ArrayList<String>();
-	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);
-
-	private Option reportOption = OptionBuilder.hasArg(true)
-			.withArgName("file").withDescription(REPORT_OPT_DESC).withLongOpt(
-					REPORT_OPT_LONG).create(REPORT_OPT_SHORT);
-
-	private Option codebaseOption = OptionBuilder.hasArg(true).withArgName(
-			"dir").withDescription(CODEBASE_OPT_DESC).withLongOpt(
-			CODEBASE_OPT_LONG).create(CODEBASE_OPT_SHORT);
-
-	private Option limitOption = OptionBuilder.hasArg(true).withArgName("int")
-			.withDescription(LIMIT_OPT_DESC).withLongOpt(LIMIT_OPT_LONG)
-			.create(LIMIT_OPT_SHORT);
-
-	private Option configOption = OptionBuilder.hasArg(true)
-			.withArgName("file").withDescription(CONFIG_OPT_DESC).withLongOpt(
-					CONFIG_OPT_LONG).create(CONFIG_OPT_SHORT);
-
-	private Option enginesOption = OptionBuilder.withValueSeparator(',')
-			.hasArgs(Option.UNLIMITED_VALUES).withArgName("names")
-			.withDescription(ENGINES_OPT_DESC).withLongOpt(ENGINES_OPT_LONG)
-			.create(ENGINES_OPT_SHORT);
-
-	private Option heuristicsOption = OptionBuilder.withValueSeparator(',')
-			.hasArgs(Option.UNLIMITED_VALUES).withArgName("names")
-			.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
-	 * configuration file is provided by command line argument, we try to  
parse
-	 * that configuration file. Otherwise, default configuration "config.conf"
-	 * file is parsed. After this two steps if any of members is not
-	 * initialized, we initialize them with default values.
-	 *
-	 * @param args
-	 *            command line arguments
-	 * @param out
-	 *            output stream for displaying current information
-	 */
-	public PdCommandLine(String[] args, PrintStream out) {
-		this.out = out;
-		initializeOptions();
-		// we parse command line
-		try {
-			parseArguments(args);
-			// from command line we get configuration file path
-			// or use default one, and then parse config file for more options
-			parseConfigFile(this.config);
-			// only if it is codebase set from command line or configuration
-			// file we continue
-			Validate.notNull(this.codebase, "Codebase must be provided.");
-			// if any option is not configured after this, we set it to
-			// default value
-			configureUninitializedValues();
-		} catch (Exception e) {
-			// oops, something went wrong
-			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
-		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("format   : " + this.getReportFormat());
-		this.out.println("language : " + this.language);
-		this.out.println("verbose  : " + this.verbose);
-	}
-
-	/**
-	 * Parse arguments and gets parameters from them.
-	 *
-	 * @param args
-	 *            command line arguments
-	 */
-	private void parseArguments(String[] args) throws ParseException,
-			NumberFormatException {
-		CommandLineParser parser = new GnuParser();
-		CommandLine line = parser.parse(options, args);
-		parseCommandLineArguments(line);
-	}
-
-	/**
-	 * Sets default values to uninitialized properties.
-	 */
-	private void configureUninitializedValues() {
-		if (this.report == null) {
-			this.out.println(DEFAULT_RAPORT_MSG + DEFAULT_REPORT);
-			this.report = DEFAULT_REPORT;
-		}
-		if (this.limit == 0) {
-			this.out.println(DEFAULT_LIMIT_MSG + DEFAULT_LIMIT);
-			this.limit = DEFAULT_LIMIT;
-		}
-		if (this.engines.isEmpty()) {
-			this.out.println(DEFAULT_ENGINE_MSG + DEFAULT_ENGINE);
-			this.engines.add(DEFAULT_ENGINE);
-		}
-		if (this.heuristics.isEmpty()) {
-			this.out.println(DEFAULT_HEURISTIC_MSG + DEFAULT_HEURISTIC);
-			this.heuristics.add(DEFAULT_HEURISTIC);
-		}
-	}
-
-	/**
-	 * Prints message how to use PdCommandLine.
-	 */
-	public void printUsage() {
-		StringBuffer footer = new StringBuffer("\n");
-
-		footer
-				.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");
-		footer.append("Remember - this is very basic tool!!!\n");
-
-		// automatically generate the help statement
-		HelpFormatter formatter = new HelpFormatter();
-		formatter.printHelp("java -jar apache-rat-pd.jar [options]",
-				"Options:", options, footer.toString(), false);
-	}
-
-	/**
-	 * Initializes available options.
-	 */
-	private void initializeOptions() {
-		options.addOption(helpOption);
-		options.addOption(reportOption);
-		options.addOption(codebaseOption);
-		options.addOption(limitOption);
-		options.addOption(configOption);
-		options.addOption(enginesOption);
-		options.addOption(heuristicsOption);
-		options.addOption(languageOption);
-		options.addOption(verboseOption);
-	}
-
-	/**
-	 * Parse command line and sets values to properties.
-	 * <p>
-	 * If some property is invalid an exception is thrown.
-	 *
-	 * @param line
-	 *            CommandLine
-	 * @throws NumberFormatException
-	 *             , IllegalArgumentException
-	 */
-	private void parseCommandLineArguments(CommandLine line)
-			throws NumberFormatException, IllegalArgumentException {
-
-		if (line.hasOption(CODEBASE_OPT_LONG)) {
-			this.codebase = line.getOptionValue(CODEBASE_OPT_LONG);
-		}
-		if (line.hasOption(REPORT_OPT_LONG)) {
-			this.report = line.getOptionValue(REPORT_OPT_LONG);
-		}
-		if (line.hasOption(CONFIG_OPT_LONG)) {
-			this.config = line.getOptionValue(CONFIG_OPT_LONG);
-		}
-		if (line.hasOption(ENGINES_OPT_LONG)) {
-			String[] temp = line.getOptionValues(ENGINES_OPT_LONG);
-			for (int i = 0; i < temp.length; i++) {
-				engines.add(temp[i]);
-			}
-		}
-		if (line.hasOption(HEURISTICS_OPT_LONG)) {
-			String[] temp = line.getOptionValues(HEURISTICS_OPT_LONG);
-			for (int i = 0; i < temp.length; i++) {
-				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;
-		}
-		if (line.hasOption(LIMIT_OPT_LONG)) {
-			int temp = Integer.valueOf(line.getOptionValue(LIMIT_OPT_LONG));
-			// this line will throw an exception if number is not in specified
-			// interval
-			Validate.isTrue(temp > 0 && temp <= 100,
-					"Number must be in interval [1,100] inclusive");
-			this.limit = temp;
-		}
-		if (line.hasOption(VERBOSE_OPT_LONG)) {
-			this.verbose = true;
-		}
-	}
-
-	/**
-	 * @return limit property
-	 */
-	public int getLimit() {
-		return this.limit;
-	}
-
-	/**
-	 * @return verbose flag
-	 */
-	public boolean isVerbose() {
-		return this.verbose;
-	}
-
-	/**
-	 * @return filename of the report
-	 */
-	public String getReport() {
-		return this.report;
-	}
-
-	/**
-	 * @return format of report, PdCommandLine.HTML_MODE,  
PdCommandLine.XML_MODE
-	 *         or PdCommandLine.TEXT_MODE
-	 */
-	public String getReportFormat() {
-		String toRet = getReport() != null ? getReport().replaceFirst(".*\\.",
-				"") : "";
-		// htm and html are valid extensions for html files
-		if (toRet.equalsIgnoreCase("html") || toRet.equalsIgnoreCase("htm")) {
-			toRet = PdCommandLine.HTML_MODE;
-		}
-		if (toRet.equalsIgnoreCase("xml")) {
-			toRet = PdCommandLine.XML_MODE;
-		}
-		return toRet;
-	}
-
-	/**
-	 * @return path to code base
-	 */
-	public String getCodebase() {
-		return this.codebase;
-	}
-
-	/**
-	 * @return list of engine names
-	 */
-	public List<String> getEngines() {
-		return this.engines;
-	}
-
-	/**
-	 * @return list of heuristic names
-	 */
-	public List<String> getHeuristics() {
-		return this.heuristics;
-	}
-
-	/**
-	 * @return programming language name
-	 */
-	public String getLanguage() {
-		return this.language;
-	}
-
-	/**
-	 * @return true if all arguments are parsed properly
-	 */
-	public boolean isAllArgumentsCorrect() {
-		return allArgumentsCorrect;
-	}
-
-	/**
-	 * Read configuration file and parse it. We assert that configuration file
-	 * structure is like command line - in each line is defined an argument  
and
-	 * value. Available arguments are same as command line options.
-	 *
-	 * @param config
-	 *            path to configuration file
-	 * @throws NumberFormatException
-	 * @throws ParseException
-	 */
-	private void parseConfigFile(String config) throws NumberFormatException,
-			ParseException {
-		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) {
-			this.out.println("Error parsing configuration options from: "
-					+ config);
-		}
-		parseArguments(args);
-	}
+    // possible report formats
+    public static final String HTML_MODE = "html";
+    public static final String TEXT_MODE = "txt";
+    public static final String XML_MODE = "xml";
+
+    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";
+    private static final String LIMIT_OPT_DESC = "integer from 1 to 100,1  
is almost brute force and 100 is heuristic";
+    private static final String CODEBASE_OPT_DESC = "name of source code  
directory";
+    private static final String REPORT_OPT_DESC = "name of the report  
file;\nextension of file determines report format:"
+            + "\n\t.xml  - report will be xml document"
+            + "\n\t.html - report will be html document"
+            + "\n\t.txt  - report will be txt document" + "\nDefault is  
report.html.";
+    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";
+    private static final String LIMIT_OPT_SHORT = "l";
+    private static final String CODEBASE_OPT_SHORT = "cb";
+    private static final String REPORT_OPT_SHORT = "r";
+    private static final String HELP_OPT_SHORT = "h";
+    public static final int DEFAULT_LIMIT = 10;
+    public static final String DEFAULT_HEURISTIC  
= "BruteForceHeuristicChecker";
+    public static final String DEFAULT_ENGINE = "GoogleCodeSearchParser";
+    public static final String DEFAULT_REPORT = "report.html";
+    private static final String DEFAULT_HEURISTIC_MSG = "Heuristic is not  
set.In use is default checker: ";
+    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";
+    private static final String LIMIT_OPT_LONG = "limit";
+    private static final String CODEBASE_OPT_LONG = "codebase";
+    private static final String REPORT_OPT_LONG = "report";
+    private static final String HELP_OPT_LONG = "help";
+
+    // this are properties which can be parsed from
+    // command line or from configuration file
+    private Options options = new Options();
+    private String report;
+    private String codebase;
+    /**
+     * Limit is user-defined constants 1-100 and it is used to measure how
+     * aggressively will be used search engines if we put there 10 =little  
usage
+     * of Internet (search engines) if we put there 90 =almost bruteforce
+     * checking will be run
+     */
+    private int limit;
+    private List<String> engines = new ArrayList<String>();
+    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);
+
+    private Option reportOption =  
OptionBuilder.hasArg(true).withArgName("file").withDescription(REPORT_OPT_DESC)
+            .withLongOpt(REPORT_OPT_LONG).create(REPORT_OPT_SHORT);
+
+    private Option codebaseOption =  
OptionBuilder.hasArg(true).withArgName("dir").withDescription(CODEBASE_OPT_DESC)
+            .withLongOpt(CODEBASE_OPT_LONG).create(CODEBASE_OPT_SHORT);
+
+    private Option limitOption =  
OptionBuilder.hasArg(true).withArgName("int").withDescription(LIMIT_OPT_DESC)
+            .withLongOpt(LIMIT_OPT_LONG).create(LIMIT_OPT_SHORT);
+
+    private Option configOption =  
OptionBuilder.hasArg(true).withArgName("file").withDescription(CONFIG_OPT_DESC)
+            .withLongOpt(CONFIG_OPT_LONG).create(CONFIG_OPT_SHORT);
+
+    private Option enginesOption =  
OptionBuilder.withValueSeparator(',').hasArgs(Option.UNLIMITED_VALUES).withArgName(
+            "names").withDescription(ENGINES_OPT_DESC).withLongOpt(ENGINES_OPT_LONG).create(ENGINES_OPT_SHORT);
+
+    private Option heuristicsOption =  
OptionBuilder.withValueSeparator(',').hasArgs(Option.UNLIMITED_VALUES)
+            .withArgName("names").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
+     * configuration file is provided by command line argument, we try to  
parse
+     * that configuration file. Otherwise, default  
configuration "config.conf"
+     * file is parsed. After this two steps if any of members is not
+     * initialized, we initialize them with default values.
+     *
+     * @param args command line arguments
+     * @param out output stream for displaying current information
+     */
+    public PdCommandLine(String[] args, PrintStream out) {
+        this.out = out;
+        initializeOptions();
+        // we parse command line
+        try {
+            parseArguments(args);
+            // from command line we get configuration file path
+            // or use default one, and then parse config file for more  
options
+            parseConfigFile(this.config);
+            // only if it is codebase set from command line or  
configuration
+            // file we continue
+            Validate.notNull(this.codebase, "Codebase must be provided.");
+            // if any option is not configured after this, we set it to
+            // default value
+            configureUninitializedValues();
+        } catch (Exception e) {
+            // oops, something went wrong
+            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
+        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("format   : " + this.getReportFormat());
+        this.out.println("language : " + this.language);
+        this.out.println("verbose  : " + this.verbose);
+    }
+
+    /**
+     * Parse arguments and gets parameters from them.
+     *
+     * @param args command line arguments
+     */
+    private void parseArguments(String[] args) throws ParseException,  
NumberFormatException {
+        CommandLineParser parser = new GnuParser();
+        CommandLine line = parser.parse(options, args);
+        parseCommandLineArguments(line);
+    }
+
+    /**
+     * Sets default values to uninitialized properties.
+     */
+    private void configureUninitializedValues() {
+        if (this.report == null) {
+            this.out.println(DEFAULT_RAPORT_MSG + DEFAULT_REPORT);
+            this.report = DEFAULT_REPORT;
+        }
+        if (this.limit == 0) {
+            this.out.println(DEFAULT_LIMIT_MSG + DEFAULT_LIMIT);
+            this.limit = DEFAULT_LIMIT;
+        }
+        if (this.engines.isEmpty()) {
+            this.out.println(DEFAULT_ENGINE_MSG + DEFAULT_ENGINE);
+            this.engines.add(DEFAULT_ENGINE);
+        }
+        if (this.heuristics.isEmpty()) {
+            this.out.println(DEFAULT_HEURISTIC_MSG + DEFAULT_HEURISTIC);
+            this.heuristics.add(DEFAULT_HEURISTIC);
+        }
+    }
+
+    /**
+     * Prints message how to use PdCommandLine.
+     */
+    public void printUsage() {
+        StringBuffer footer = new StringBuffer("\n");
+
+        footer.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");
+        footer.append("Remember - this is very basic tool!!!\n");
+
+        // automatically generate the help statement
+        HelpFormatter formatter = new HelpFormatter();
+        formatter.printHelp("java -jar apache-rat-pd.jar  
[options]", "Options:", options, footer.toString(), false);
+    }
+
+    /**
+     * Initializes available options.
+     */
+    private void initializeOptions() {
+        options.addOption(helpOption);
+        options.addOption(reportOption);
+        options.addOption(codebaseOption);
+        options.addOption(limitOption);
+        options.addOption(configOption);
+        options.addOption(enginesOption);
+        options.addOption(heuristicsOption);
+        options.addOption(languageOption);
+        options.addOption(verboseOption);
+    }
+
+    /**
+     * Parse command line and sets values to properties.
+     * <p>
+     * If some property is invalid an exception is thrown.
+     *
+     * @param line CommandLine
+     * @throws NumberFormatException , IllegalArgumentException
+     */
+    private void parseCommandLineArguments(CommandLine line) throws  
NumberFormatException, IllegalArgumentException {
+
+        if (line.hasOption(CODEBASE_OPT_LONG)) {
+            this.codebase = line.getOptionValue(CODEBASE_OPT_LONG);
+        }
+        if (line.hasOption(REPORT_OPT_LONG)) {
+            this.report = line.getOptionValue(REPORT_OPT_LONG);
+        }
+        if (line.hasOption(CONFIG_OPT_LONG)) {
+            this.config = line.getOptionValue(CONFIG_OPT_LONG);
+        }
+        if (line.hasOption(ENGINES_OPT_LONG)) {
+            String[] temp = line.getOptionValues(ENGINES_OPT_LONG);
+            for (int i = 0; i < temp.length; i++) {
+                engines.add(temp[i]);
+            }
+        }
+        if (line.hasOption(HEURISTICS_OPT_LONG)) {
+            String[] temp = line.getOptionValues(HEURISTICS_OPT_LONG);
+            for (int i = 0; i < temp.length; i++) {
+                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;
+        }
+        if (line.hasOption(LIMIT_OPT_LONG)) {
+            int temp =  
Integer.valueOf(line.getOptionValue(LIMIT_OPT_LONG));
+            // this line will throw an exception if number is not in  
specified
+            // interval
+            Validate.isTrue(temp > 0 && temp <= 100, "Number must be in  
interval [1,100] inclusive");
+            this.limit = temp;
+        }
+        if (line.hasOption(VERBOSE_OPT_LONG)) {
+            this.verbose = true;
+        }
+    }
+
+    /**
+     * @return limit property
+     */
+    public int getLimit() {
+        return this.limit;
+    }
+
+    /**
+     * @return verbose flag
+     */
+    public boolean isVerbose() {
+        return this.verbose;
+    }
+
+    /**
+     * @return filename of the report
+     */
+    public String getReport() {
+        return this.report;
+    }
+
+    /**
+     * @return format of report, PdCommandLine.HTML_MODE,  
PdCommandLine.XML_MODE
+     *         or PdCommandLine.TEXT_MODE
+     */
+    public String getReportFormat() {
+        String toRet = getReport() != null ?  
getReport().replaceFirst(".*\\.", "") : "";
+        // htm and html are valid extensions for html files
+        if (toRet.equalsIgnoreCase("html") ||  
toRet.equalsIgnoreCase("htm")) {
+            toRet = PdCommandLine.HTML_MODE;
+        }
+        if (toRet.equalsIgnoreCase("xml")) {
+            toRet = PdCommandLine.XML_MODE;
+        }
+        return toRet;
+    }
+
+    /**
+     * @return path to code base
+     */
+    public String getCodebase() {
+        return this.codebase;
+    }
+
+    /**
+     * @return list of engine names
+     */
+    public List<String> getEngines() {
+        return this.engines;
+    }
+
+    /**
+     * @return list of heuristic names
+     */
+    public List<String> getHeuristics() {
+        return this.heuristics;
+    }
+
+    /**
+     * @return programming language name
+     */
+    public String getLanguage() {
+        return this.language;
+    }
+
+    /**
+     * @return true if all arguments are parsed properly
+     */
+    public boolean isAllArgumentsCorrect() {
+        return allArgumentsCorrect;
+    }
+
+    /**
+     * Read configuration file and parse it. We assert that configuration  
file
+     * structure is like command line - in each line is defined an  
argument and
+     * value. Available arguments are same as command line options.
+     *
+     * @param config path to configuration file
+     * @throws NumberFormatException
+     * @throws ParseException
+     */
+    private void parseConfigFile(String config) throws  
NumberFormatException, ParseException {
+        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) {
+            this.out.println("Error parsing configuration options from: "  
+ config);
+        }
+        parseArguments(args);
+    }

  }
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/core/PlagiarismDetector.java	Sun  
Aug 16 16:43:54 2009
+++ /trunk/src/main/java/org/apache/rat/pd/core/PlagiarismDetector.java	Fri  
Aug 21 06:53:09 2009
@@ -82,297 +82,246 @@
   * http://wiki.apache.org/general/MarijaSljivovic/SoC2009ApacheRatProposal
   *
   * @author maka
- *
   */
  public class PlagiarismDetector {

-	// stream for printing current information
-	private static PrintStream out;
-	/**
-	 * @param args
-	 * @throws RatReportFailedException
-	 */
-	public static void main(String[] args) throws RatReportFailedException,
-			IOException {
-		//instance of PlagiarismDetector
-		PlagiarismDetector pd = new PlagiarismDetector();
-
-		PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
-		if (!pdCommandLine.isAllArgumentsCorrect()) {
-			pdCommandLine.printUsage();
-			System.exit(1);
-		}
-		// stream for printing current information
-		out = pd.getProperPrintStream(pdCommandLine);
-		// we add all rules we are interested in
-		final List<IHeuristicChecker> algorithmsForChecking =
-			pd.configureHeuristicCheckers( pdCommandLine);
-		// making one or more parsers
-		final List<ISearchEngine> searchEngines = pd.configureSearchEngines(
-				pdCommandLine, pd.getLanguage(pdCommandLine,
-						algorithmsForChecking));
-
-		// we check whole directory
-		final DirectoryWalker walker = new DirectoryWalker(new File(
-				pdCommandLine.getCodebase()));
-		// report document
-		Report reportDocument = pd.configureReport(pdCommandLine);
-
-		// analyzer is sliding-window checker
-		final SourceCodeAnalyser analyser = new SourceCodeAnalyser(
-				searchEngines, algorithmsForChecking, reportDocument, out);
-
-		final PlagiarismDetectorReport plagiarismDetectorReport = new  
PlagiarismDetectorReport(
-				analyser);
-
-		walker.run(plagiarismDetectorReport);
-		// Saving generated report
-		pd.saveReport(pdCommandLine.getReport(), reportDocument.getReport());
-	}
-
-	/**
-	 * Decide which format of report will be used.
-	 *
-	 * @param pdCommandLine command line object to read report format from
-	 * @return
-	 */
-	private  Report configureReport(PdCommandLine pdCommandLine) {
-		Report reportDocument;
-		if (pdCommandLine.getReportFormat().equals(PdCommandLine.TEXT_MODE)) {
-			reportDocument = new TxtReportGenerator();
-		} else if (pdCommandLine.getReportFormat().equals(
-				PdCommandLine.XML_MODE)) {
-			reportDocument = new XmlReportGenerator();
-		} else {
-			reportDocument = new HtmlReportGenerator();
-		}
-		return reportDocument;
-	}
-
-	/**
-	 * This method can create objects defined from command line search engine
-	 * arguments
-	 *
-	 * @param pdCommandLine command line object to read engines from
-	 * @param language name of programming language
-	 * @return list of chosen search engine parsers
-	 */
-	private  List<ISearchEngine> configureSearchEngines(
-			PdCommandLine pdCommandLine, String language) {
-		List<ISearchEngine> toRet = new ArrayList<ISearchEngine>();
-		for (String searchEngine : pdCommandLine.getEngines()) {
-			if (searchEngine.equals("GoogleCodeSearchParser")) {
-				toRet.add(new GoogleCodeSearchParser(language, out));
-			}
-			// add more parsers here(koders and krugle)
-		}
-		return toRet;
-	}
-
-	/**
-	 * This method can create objects defined from command line heuristic
-	 * checker arguments
-	 *
-	 * @param pdCommandLine command line object to read engines from
-	 * @return list of chosen heuristic checkers
-	 * @throws IOException
-	 */
-	private  List<IHeuristicChecker> configureHeuristicCheckers(
-			PdCommandLine pdCommandLine) throws IOException {
-		List<IHeuristicChecker> toRet = new ArrayList<IHeuristicChecker>();
-
-		for (String heuristicChecker : pdCommandLine.getHeuristics()) {
-			if (heuristicChecker.equals("BruteForceHeuristicChecker")) {
-				toRet.add(new BruteForceHeuristicChecker(
-						IHeuristicChecker.ALL_LANGUAGES));
-			}
-			// ///////////////////////////////////////////////////
-			// Comment heuristic checkers
-			// //////////////////////////////////////////////////
-			else if (heuristicChecker.equals("JavaCommentHeuristicChecker")) {
-				toRet.add(new JavaCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("PascalCommentHeuristicChecker")) {
-				toRet.add(new PascalCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("CCommentHeuristicChecker")) {
-				toRet.add(new CCommentHeuristicChecker(
-						pdCommandLine.getLimit(), out));
-			} else if (heuristicChecker.equals("CobolCommentHeuristicChecker")) {
-				toRet.add(new CobolCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker
-					.equals("ColdFusionCommentsheuristicChecker")) {
-				toRet.add(new ColdFusionCommentsheuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("DelphiCommentHeuristicChecker")) {
-				toRet.add(new DelphiCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker
-					.equals("FortranCommentHeuristicChecker")) {
-				toRet.add(new FortranCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("HTMLCommentHeuristicChecker")) {
-				toRet.add(new HTMLCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("LispCommentHeuristicChecker")) {
-				toRet.add(new LispCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("PHPCommentHeuristicChecker")) {
-				toRet.add(new PHPCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("PythonCommentHeuristicChecker")) {
-				toRet.add(new PythonCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("RubyCommentHeuristicChecker")) {
-				toRet.add(new RubyCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("SQLCommentHeuristicChecker")) {
-				toRet.add(new SQLCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker
-					.equals("VisualBasicCommentHeuristicChecker")) {
-				toRet.add(new VisualBasicCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker
-					.equals("ActionScriptCommentHeuristicChecker")) {
-				toRet.add(new ActionScriptCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("CPPCommentHeuristicChecker")) {
-				toRet.add(new CPPCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("CSharpCommentHeuristicChecker")) {
-				toRet.add(new CSharpCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker
-					.equals("JavaScriptCommentHeuristicChecker")) {
-				toRet.add(new JavaScriptCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("PerlCommentHeuristicChecker")) {
-				toRet.add(new PerlCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("ShellCommentHeuristicChecker")) {
-				toRet.add(new ShellCommentHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			}
-			// ///////////////////////////////////////////////////
-			// Functions heuristic checkers
-			// //////////////////////////////////////////////////
-			else if (heuristicChecker
-					.equals("ActionScriptFunctionHeuristicChecker")) {
-				toRet.add(new ActionScriptFunctionHeuristicChecker(
-						pdCommandLine.getLimit(), out));
-			} else if (heuristicChecker.equals("CFunctionHeuristicChecker")) {
-				toRet.add(new CFunctionHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("CPPFunctionHeuristicChecker")) {
-				toRet.add(new CPPFunctionHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker
-					.equals("CSharpFunctionHeuristicChecker")) {
-				toRet.add(new CSharpFunctionHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker
-					.equals("DelphiFunctionHeuristicChecker")) {
-				toRet.add(new DelphiFunctionHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("JavaFunctionHeuristicChecker")) {
-				toRet.add(new JavaFunctionHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker
-					.equals("JavaScriptFunctionHeuristicChecker")) {
-				toRet.add(new JavaScriptFunctionHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker
-					.equals("PascalFunctionHeuristicChecker")) {
-				toRet.add(new PascalFunctionHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			} else if (heuristicChecker.equals("PHPFunctionHeuristicChecker")) {
-				toRet.add(new PHPFunctionHeuristicChecker(pdCommandLine
-						.getLimit(), out));
-			}
-			// ///////////////////////////////////////////////////
-			// Misspellings heuristic checkers
-			// //////////////////////////////////////////////////
-			else if (heuristicChecker.equals("MisspellingsHeuristicChecker")) {
-				InputStream is = ClassLoader.getSystemClassLoader()
-						.getResourceAsStream("misspellings/english.dict");
-				IDictionary dictionary = new Dictionary(is);
-				toRet.add(new MisspellingsHeuristicChecker(dictionary,
-						IHeuristicChecker.ALL_LANGUAGES, out));
-			}
-
-			else {
-				System.err.println("Cannot find propper class for "
-						+ heuristicChecker);
-			}
-		}
-		return toRet;
-	}
-
-	/**
-	 * @param raportName file name
-	 * @param reportContent content of report file
-	 */
-	private  void saveReport(String raportName, String reportContent) {
-		try {
-			FileManipulator.saveFile(raportName, reportContent);
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * @param algorithmsForChecking list of heuristic checkers
-	 * @return Language of source code. It depends by selected heuristic
-	 *         checkers.
-	 */
-	private  String getLanguageFromHeuristic(
-			List<IHeuristicChecker> algorithmsForChecking) {
-		String toRet = IHeuristicChecker.ALL_LANGUAGES;
-		Set<String> langs = new TreeSet<String>();
-		for (IHeuristicChecker heuristicChecker : algorithmsForChecking) {
-			langs.add(heuristicChecker.getLanguage());
-		}
-		if (langs.size() == 1) {
-			toRet = langs.iterator().next();
-			out.println("Chosen language is: " + toRet);
-		}
-		return toRet;
-	}
-
-	/**
-	 * Decides which programming language will be used.
-	 *
-	 * @param commandLine commandLine object to read language information from
-	 * @param algorithmsForChecking list of heuristic checkers
-	 * @return programming language name
-	 */
-	private  String getLanguage(PdCommandLine commandLine,
-			List<IHeuristicChecker> algorithmsForChecking) {
-		String toRet = IHeuristicChecker.ALL_LANGUAGES;
-		if (commandLine.getLanguage() != null) {
-			toRet = commandLine.getLanguage();
-		} else {
-			toRet = getLanguageFromHeuristic(algorithmsForChecking);
-		}
-		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 commandLine object to read verbose information from
-	 * @return chosen output stream. If -v is not specified, all information  
will not be shown
-	 */
-	private  PrintStream getProperPrintStream(PdCommandLine pdCommandLine) {
-		return pdCommandLine.isVerbose() ? System.out : new PrintStream(new  
OutputStream() {
-			@Override
-		    public void write(int b) {} // Do nothing when printing is requested.
-		});
-	}
-}
+    // stream for printing current information
+    private static PrintStream out;
+
+    /**
+     * @param args
+     * @throws RatReportFailedException
+     */
+    public static void main(String[] args) throws  
RatReportFailedException, IOException {
+        // instance of PlagiarismDetector
+        PlagiarismDetector pd = new PlagiarismDetector();
+
+        PdCommandLine pdCommandLine = new PdCommandLine(args, System.out);
+        if (!pdCommandLine.isAllArgumentsCorrect()) {
+            pdCommandLine.printUsage();
+            System.exit(1);
+        }
+        // stream for printing current information
+        out = pd.getProperPrintStream(pdCommandLine);
+        // we add all rules we are interested in
+        final List<IHeuristicChecker> algorithmsForChecking =  
pd.configureHeuristicCheckers(pdCommandLine);
+        // making one or more parsers
+        final List<ISearchEngine> searchEngines =  
pd.configureSearchEngines(pdCommandLine, pd.getLanguage(
+                pdCommandLine, algorithmsForChecking));
+
+        // we check whole directory
+        final DirectoryWalker walker = new DirectoryWalker(new  
File(pdCommandLine.getCodebase()));
+        // report document
+        Report reportDocument = pd.configureReport(pdCommandLine);
+
+        // analyzer is sliding-window checker
+        final SourceCodeAnalyser analyser = new  
SourceCodeAnalyser(searchEngines, algorithmsForChecking,
+                reportDocument, out);
+
+        final PlagiarismDetectorReport plagiarismDetectorReport = new  
PlagiarismDetectorReport(analyser);
+
+        walker.run(plagiarismDetectorReport);
+        // Saving generated report
+        pd.saveReport(pdCommandLine.getReport(),  
reportDocument.getReport());
+    }
+
+    /**
+     * Decide which format of report will be used.
+     *
+     * @param pdCommandLine command line object to read report format from
+     * @return
+     */
+    private Report configureReport(PdCommandLine pdCommandLine) {
+        Report reportDocument;
+        if  
(pdCommandLine.getReportFormat().equals(PdCommandLine.TEXT_MODE)) {
+            reportDocument = new TxtReportGenerator();
+        } else if  
(pdCommandLine.getReportFormat().equals(PdCommandLine.XML_MODE)) {
+            reportDocument = new XmlReportGenerator();
+        } else {
+            reportDocument = new HtmlReportGenerator();
+        }
+        return reportDocument;
+    }
+
+    /**
+     * This method can create objects defined from command line search  
engine
+     * arguments
+     *
+     * @param pdCommandLine command line object to read engines from
+     * @param language name of programming language
+     * @return list of chosen search engine parsers
+     */
+    private List<ISearchEngine> configureSearchEngines(PdCommandLine  
pdCommandLine, String language) {
+        List<ISearchEngine> toRet = new ArrayList<ISearchEngine>();
+        for (String searchEngine : pdCommandLine.getEngines()) {
+            if (searchEngine.equals("GoogleCodeSearchParser")) {
+                toRet.add(new GoogleCodeSearchParser(language, out));
+            }
+            // add more parsers here(koders and krugle)
+        }
+        return toRet;
+    }
+
+    /**
+     * This method can create objects defined from command line heuristic
+     * checker arguments
+     *
+     * @param pdCommandLine command line object to read engines from
+     * @return list of chosen heuristic checkers
+     * @throws IOException
+     */
+    private List<IHeuristicChecker>  
configureHeuristicCheckers(PdCommandLine pdCommandLine) throws IOException {
+        List<IHeuristicChecker> toRet = new ArrayList<IHeuristicChecker>();
+
+        for (String heuristicChecker : pdCommandLine.getHeuristics()) {
+            if (heuristicChecker.equals("BruteForceHeuristicChecker")) {
+                toRet.add(new  
BruteForceHeuristicChecker(IHeuristicChecker.ALL_LANGUAGES));
+            }
+            // ///////////////////////////////////////////////////
+            // Comment heuristic checkers
+            // //////////////////////////////////////////////////
+            else if  
(heuristicChecker.equals("JavaCommentHeuristicChecker")) {
+                toRet.add(new  
JavaCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("PascalCommentHeuristicChecker")) {
+                toRet.add(new  
PascalCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("CCommentHeuristicChecker")) {
+                toRet.add(new  
CCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("CobolCommentHeuristicChecker")) {
+                toRet.add(new  
CobolCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("ColdFusionCommentsheuristicChecker")) {
+                toRet.add(new  
ColdFusionCommentsheuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("DelphiCommentHeuristicChecker")) {
+                toRet.add(new  
DelphiCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("FortranCommentHeuristicChecker")) {
+                toRet.add(new  
FortranCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("HTMLCommentHeuristicChecker")) {
+                toRet.add(new  
HTMLCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("LispCommentHeuristicChecker")) {
+                toRet.add(new  
LispCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("PHPCommentHeuristicChecker")) {
+                toRet.add(new  
PHPCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("PythonCommentHeuristicChecker")) {
+                toRet.add(new  
PythonCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("RubyCommentHeuristicChecker")) {
+                toRet.add(new  
RubyCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("SQLCommentHeuristicChecker")) {
+                toRet.add(new  
SQLCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("VisualBasicCommentHeuristicChecker")) {
+                toRet.add(new  
VisualBasicCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("ActionScriptCommentHeuristicChecker")) {
+                toRet.add(new  
ActionScriptCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("CPPCommentHeuristicChecker")) {
+                toRet.add(new  
CPPCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("CSharpCommentHeuristicChecker")) {
+                toRet.add(new  
CSharpCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("JavaScriptCommentHeuristicChecker")) {
+                toRet.add(new  
JavaScriptCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("PerlCommentHeuristicChecker")) {
+                toRet.add(new  
PerlCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("ShellCommentHeuristicChecker")) {
+                toRet.add(new  
ShellCommentHeuristicChecker(pdCommandLine.getLimit(), out));
+            }
+            // ///////////////////////////////////////////////////
+            // Functions heuristic checkers
+            // //////////////////////////////////////////////////
+            else if  
(heuristicChecker.equals("ActionScriptFunctionHeuristicChecker")) {
+                toRet.add(new  
ActionScriptFunctionHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("CFunctionHeuristicChecker")) {
+                toRet.add(new  
CFunctionHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("CPPFunctionHeuristicChecker")) {
+                toRet.add(new  
CPPFunctionHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("CSharpFunctionHeuristicChecker")) {
+                toRet.add(new  
CSharpFunctionHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("DelphiFunctionHeuristicChecker")) {
+                toRet.add(new  
DelphiFunctionHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("JavaFunctionHeuristicChecker")) {
+                toRet.add(new  
JavaFunctionHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("JavaScriptFunctionHeuristicChecker")) {
+                toRet.add(new  
JavaScriptFunctionHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("PascalFunctionHeuristicChecker")) {
+                toRet.add(new  
PascalFunctionHeuristicChecker(pdCommandLine.getLimit(), out));
+            } else if  
(heuristicChecker.equals("PHPFunctionHeuristicChecker")) {
+                toRet.add(new  
PHPFunctionHeuristicChecker(pdCommandLine.getLimit(), out));
+            }
+            // ///////////////////////////////////////////////////
+            // Misspellings heuristic checkers
+            // //////////////////////////////////////////////////
+            else if  
(heuristicChecker.equals("MisspellingsHeuristicChecker")) {
+                InputStream is =  
ClassLoader.getSystemClassLoader().getResourceAsStream("misspellings/english.dict");
+                IDictionary dictionary = new Dictionary(is);
+                toRet.add(new MisspellingsHeuristicChecker(dictionary,  
IHeuristicChecker.ALL_LANGUAGES, out));
+            }
+
+            else {
+                System.err.println("Cannot find propper class for " +  
heuristicChecker);
+            }
+        }
+        return toRet;
+    }
+
+    /**
+     * @param raportName file name
+     * @param reportContent content of report file
+     */
+    private void saveReport(String raportName, String reportContent) {
+        try {
+            FileManipulator.saveFile(raportName, reportContent);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * @param algorithmsForChecking list of heuristic checkers
+     * @return Language of source code. It depends by selected heuristic
+     *         checkers.
+     */
+    private String getLanguageFromHeuristic(List<IHeuristicChecker>  
algorithmsForChecking) {
+        String toRet = IHeuristicChecker.ALL_LANGUAGES;
+        Set<String> langs = new TreeSet<String>();
+        for (IHeuristicChecker heuristicChecker : algorithmsForChecking) {
+            langs.add(heuristicChecker.getLanguage());
+        }
+        if (langs.size() == 1) {
+            toRet = langs.iterator().next();
+            out.println("Chosen language is: " + toRet);
+        }
+        return toRet;
+    }
+
+    /**
+     * Decides which programming language will be used.
+     *
+     * @param commandLine commandLine object to read language information  
from
+     * @param algorithmsForChecking list of heuristic checkers
+     * @return programming language name
+     */
+    private String getLanguage(PdCommandLine commandLine,  
List<IHeuristicChecker> algorithmsForChecking) {
+        String toRet = IHeuristicChecker.ALL_LANGUAGES;
+        if (commandLine.getLanguage() != null) {
+            toRet = commandLine.getLanguage();
+        } else {
+            toRet = getLanguageFromHeuristic(algorithmsForChecking);
+        }
+        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 commandLine object to read verbose information  
from
+     * @return chosen output stream. If -v is not specified, all  
information
+     *         will not be shown
+     */
+    private PrintStream getProperPrintStream(PdCommandLine pdCommandLine) {
+        return pdCommandLine.isVerbose() ? System.out : new  
PrintStream(new OutputStream() {
+            @Override
+            public void write(int b) {
+            } // Do nothing when printing is requested.
+        });
+    }
+}
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/core/PlagiarismDetectorReport.java	 
Sat Jun  6 18:25:20 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/core/PlagiarismDetectorReport.java	 
Fri Aug 21 06:53:09 2009
@@ -29,26 +29,27 @@
  import org.apache.rat.report.RatReportFailedException;

  public class PlagiarismDetectorReport implements RatReport {
-
-	private final IDocumentAnalyser analyser;
-	public PlagiarismDetectorReport(IDocumentAnalyser analyser) {
-		this.analyser = analyser;
-	}
-
-	@Override
-	public void startReport() throws RatReportFailedException {
-	}
-
-	@Override
-	public void endReport() throws RatReportFailedException {
-	}
-
-	@Override
-	public void report(IDocument document) throws RatReportFailedException {
-		try {
-			analyser.analyse(document);
-		} catch (RatDocumentAnalysisException e) {
-			e.printStackTrace();
-		}
-	}
-}
+
+    private final IDocumentAnalyser analyser;
+
+    public PlagiarismDetectorReport(IDocumentAnalyser analyser) {
+        this.analyser = analyser;
+    }
+
+    @Override
+    public void startReport() throws RatReportFailedException {
+    }
+
+    @Override
+    public void endReport() throws RatReportFailedException {
+    }
+
+    @Override
+    public void report(IDocument document) throws RatReportFailedException  
{
+        try {
+            analyser.analyse(document);
+        } catch (RatDocumentAnalysisException e) {
+            e.printStackTrace();
+        }
+    }
+}
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/core/SourceCodeAnalyser.java	Sun  
Aug 16 16:43:54 2009
+++ /trunk/src/main/java/org/apache/rat/pd/core/SourceCodeAnalyser.java	Fri  
Aug 21 06:53:09 2009
@@ -41,293 +41,268 @@
   * This is implementation of the sliding window algorithm
   *
   * @author maka
- *
   */
  public class SourceCodeAnalyser implements IDocumentAnalyser {

-	private static String STRING_DELIMETER_REGEX = " +";
-	private final List<ISearchEngine> searchEngines;
-	private final List<IHeuristicChecker> algorithmsForChecking;
-	private final Report reportDocument;
-
-	private final PrintStream out;
-	private PauseListener pauseListener;
-	private volatile boolean paused = false;
-	private int progressMessageLength;
-
-	/**
-	 * @param searchEngines
-	 *            list of chosen search engine parsers
-	 * @param algorithmsForChecking
-	 *            list of chosen heuristic algorithms
-	 * @param reportDocument
-	 *            chosen report
-	 * @param out
-	 *            printStream wnere current information are be printed
-	 */
-	public SourceCodeAnalyser(List<ISearchEngine> searchEngines,
-			List<IHeuristicChecker> algorithmsForChecking,
-			Report reportDocument, PrintStream out) {
-		this.searchEngines = searchEngines;
-		this.algorithmsForChecking = algorithmsForChecking;
-		this.reportDocument = reportDocument;
-		this.out = out;
-
-		initializeKeyListener();
-	}
-
-	/**
-	 * initialize key listener for pause/resume
-	 */
-	private void initializeKeyListener() {
-		this.pauseListener = new PauseListener() {
-			@Override
-			public void onPause() {
-				System.out.println("apache-rat-pd is paused...");
-				System.out.println("to resume application, pres Enter");
-				SourceCodeAnalyser.this.paused = true;
-			}
-
-			@Override
-			public void onResume() {
-				System.out.println("apache-rat-pd resumed...");
-				SourceCodeAnalyser.this.paused = false;
-			}
-
-		};
-		// to ensure that this process will end together with the program
-		pauseListener.setDaemon(true);
-		pauseListener.start();
-
-	}
-
-	/**
-	 * this method will make algorithm to sleep until flag paused == true
-	 */
-	private void pauseIfNeeded() {
-		while (paused)
-			try {
-				Thread.sleep(1000);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see
-	 *  
org.apache.rat.document.IDocumentAnalyser#analyse(org.apache.rat.document
-	 * .IDocument)
-	 */
-	@Override
-	public void analyse(IDocument document) throws  
RatDocumentAnalysisException {
-		try {
-
-			System.out.println("\n");
-			String code = readFile(document.reader());
-
-			checkOneFile(searchEngines, code, algorithmsForChecking, document
-					.getName());
-		} catch (IOException e) {
-			System.err.println("Source file not found: " + document.getName());
-		}
-	}
-
-	/**
-	 * @param reader
-	 *            object which can read a file
-	 * @return content of file
-	 * @throws IOException
-	 */
-	private String readFile(Reader reader) throws IOException {
-		String toret = "";
-		// TODO encoding is system default now!!!!
-		BufferedReader input = new BufferedReader(reader);
-		try {
-			String line = null;
-			while ((line = input.readLine()) != null) {
-				toret += line + "\n";
-			}
-		} finally {
-			input.close();
-		}
-		return toret;
-	}
-
-	/**
-	 * Implementation of sliding-window algorithm.
-	 *
-	 * @param searchEngines
-	 *            list of chosen search engine parsers
-	 * @param code
-	 *            code part to be checked
-	 * @param heuristicCheckers
-	 *            list of chosen heuristic checkers
-	 * @param fileName
-	 *            name of file we are currently checking
-	 */
-	public void checkOneFile(List<ISearchEngine> searchEngines, String code,
-			List<IHeuristicChecker> heuristicCheckers, String fileName) {
-
-		String[] tokens = tokeniseString(code);
-		ReportEntry raportEntry = null;
-
-		int i = 0;
-		int j = 0;
-
-		while (i < tokens.length) {
-			while (j < tokens.length) {
-				// this method will make application to sleep if it is needed
-				pauseIfNeeded();
-
-				StringBuffer toCheck = combineTokens(tokens, i, j);
-				j++;
-				printProgress(tokens.length, j, fileName);
-
-				HeuristicCheckerResult heurResult = isCheckOnInternetNeaded(
-						heuristicCheckers, toCheck.toString());
-				if (heurResult.isCheckOnInternetNeaded()) {
-
-					ReportEntry lastEntry = searchOnInternet(searchEngines,
-							heurResult.getCodeSuggestedToBeChecked(), fileName);
-					if (lastEntry != null) {
-						raportEntry = lastEntry;
-					}
-					if (!heurResult.isShouldStretch() || lastEntry == null) {
-						break;
-					}
-				}
-			}
-			i = j;
-			if (raportEntry != null) {
-				printReport(raportEntry);
-				reportDocument.addReportEntry(raportEntry);
-				raportEntry = null;
-			}
-		}
-	}
-
-	// TODO move this to report package....
-	/**
-	 * print current state into console
-	 *
-	 * @param reportEntry
-	 */
-	private void printReport(ReportEntry reportEntry) {
-		out.println("chunk of code copied:");
-		out.println("--------------------------------------------");
-		out.println(reportEntry.getCode());
-		out.println("--------------------------------------------");
-	}
-
-	/**
-	 * Search for code in all engines. If code is found, an reportEntry will  
be
-	 * returned Otherwise, null will be returned.
-	 *
-	 * @param searchEngines
-	 *            list of chosen search engine parsers
-	 * @param code
-	 *            code to be checked
-	 * @param fileName
-	 *            source file name
-	 * @return an report entry
-	 */
-	private ReportEntry searchOnInternet(List<ISearchEngine> searchEngines,
-			String code, String fileName) {
-		ReportEntry toret = null;
-		List<SearchResult> found = new ArrayList<SearchResult>();
-		for (ISearchEngine searchEngine : searchEngines) {
-			if (searchEngine.isCodeFound(code.toString())) {
-				found.addAll(searchEngine.getSearchResults());
-			}
-		}
-		if (!found.isEmpty()) {
-			toret = new ReportEntry(found, code, fileName);
-		}
-		return toret;
-	}
-
-	/**
-	 * @param heuristicCheckers
-	 *            lit of chosen heuristic checkers
-	 * @param toCheck
-	 *            code to be checked
-	 *
-	 * @return heuristicCheckerResult with proper information for sliding  
window
-	 *         algorithm
-	 */
-	private HeuristicCheckerResult isCheckOnInternetNeaded(
-			List<IHeuristicChecker> heuristicCheckers, String toCheck) {
-
-		HeuristicCheckerResult toret = new HeuristicCheckerResult(false, true,
-				toCheck, null);
-		for (IHeuristicChecker checker : heuristicCheckers) {
-			toret = checker.checkByHeuristic(toCheck);
-			if (toret.isShouldStretch()) {
-				break;
-			}
-		}
-
-		return toret;
-	}
-
-	/**
-	 * Append tokens from start position until end.
-	 *
-	 * @param tokens list of tokens to combine
-	 * @param start position
-	 * @param end position
-	 * @return appended tokens
-	 */
-	private StringBuffer combineTokens(String[] tokens, int start, int end) {
-
-		StringBuffer sb = new StringBuffer();
-		for (int k = start; k < end; k++) {
-			sb.append(tokens[k]);
-			sb.append(" ");
-		}
-		sb.append(tokens[end]);
-		return sb;
-	}
-
-	/**
-	 * extract tokens
-	 *
-	 * @param code to be tokenised
-	 * @return list of words
-	 */
-	private String[] tokeniseString(String code) {
-		code = code.replaceAll("\\n", "\n ");
-		String[] tokens = code.split(STRING_DELIMETER_REGEX);
-		// this simple tokeniser returns array {""} when "" is tokenised
-		// I must avoid that behavior
-		if (tokens.length == 1 && tokens[0].equals(""))
-			tokens = new String[0];
-		return tokens;
-	}
-
-	/**
-	 * This method just prints in console information about current progress.
-	 *<p>
-	 * Example:Analyzing file : c:\HelloWorld.java Progress: 2/200 (1%)
-	 *
-	 * @param whole
-	 *            is number of all tokens we iterate
-	 * @param current
-	 *            is current position of iteration
-	 * @param fileName
-	 *            is file name of source file
-	 */
-	private void printProgress(int whole, int current, String fileName) {
-		// clear previous state
-		for (int i = 0; i < progressMessageLength; i++) {
-			System.out.print("\b");
-		}
-
-		String message = "Analyzing file: " + fileName + " Progress: "
-				+ current + "/" + whole + " (" + (current * 100 / whole) + "%)";
-		this.progressMessageLength = message.length();
-		System.out.print(message);
-	}
-}
+    private static String STRING_DELIMETER_REGEX = " +";
+    private final List<ISearchEngine> searchEngines;
+    private final List<IHeuristicChecker> algorithmsForChecking;
+    private final Report reportDocument;
+
+    private final PrintStream out;
+    private PauseListener pauseListener;
+    private volatile boolean paused = false;
+    private int progressMessageLength;
+
+    /**
+     * @param searchEngines list of chosen search engine parsers
+     * @param algorithmsForChecking list of chosen heuristic algorithms
+     * @param reportDocument chosen report
+     * @param out printStream wnere current information are be printed
+     */
+    public SourceCodeAnalyser(List<ISearchEngine> searchEngines,  
List<IHeuristicChecker> algorithmsForChecking,
+            Report reportDocument, PrintStream out) {
+        this.searchEngines = searchEngines;
+        this.algorithmsForChecking = algorithmsForChecking;
+        this.reportDocument = reportDocument;
+        this.out = out;
+
+        initializeKeyListener();
+    }
+
+    /**
+     * initialize key listener for pause/resume
+     */
+    private void initializeKeyListener() {
+        this.pauseListener = new PauseListener() {
+            @Override
+            public void onPause() {
+                System.out.println("apache-rat-pd is paused...");
+                System.out.println("to resume application, pres Enter");
+                SourceCodeAnalyser.this.paused = true;
+            }
+
+            @Override
+            public void onResume() {
+                System.out.println("apache-rat-pd resumed...");
+                SourceCodeAnalyser.this.paused = false;
+            }
+
+        };
+        // to ensure that this process will end together with the program
+        pauseListener.setDaemon(true);
+        pauseListener.start();
+
+    }
+
+    /**
+     * this method will make algorithm to sleep until flag paused == true
+     */
+    private void pauseIfNeeded() {
+        while (paused)
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     *  
org.apache.rat.document.IDocumentAnalyser#analyse(org.apache.rat.document
+     * .IDocument)
+     */
+    @Override
+    public void analyse(IDocument document) throws  
RatDocumentAnalysisException {
+        try {
+
+            System.out.println("\n");
+            String code = readFile(document.reader());
+
+            checkOneFile(searchEngines, code, algorithmsForChecking,  
document.getName());
+        } catch (IOException e) {
+            System.err.println("Source file not found: " +  
document.getName());
+        }
+    }
+
+    /**
+     * @param reader object which can read a file
+     * @return content of file
+     * @throws IOException
+     */
+    private String readFile(Reader reader) throws IOException {
+        String toret = "";
+        // TODO encoding is system default now!!!!
+        BufferedReader input = new BufferedReader(reader);
+        try {
+            String line = null;
+            while ((line = input.readLine()) != null) {
+                toret += line + "\n";
+            }
+        } finally {
+            input.close();
+        }
+        return toret;
+    }
+
+    /**
+     * Implementation of sliding-window algorithm.
+     *
+     * @param searchEngines list of chosen search engine parsers
+     * @param code code part to be checked
+     * @param heuristicCheckers list of chosen heuristic checkers
+     * @param fileName name of file we are currently checking
+     */
+    public void checkOneFile(List<ISearchEngine> searchEngines, String  
code, List<IHeuristicChecker> heuristicCheckers,
+            String fileName) {
+
+        String[] tokens = tokeniseString(code);
+        ReportEntry raportEntry = null;
+
+        int i = 0;
+        int j = 0;
+
+        while (i < tokens.length) {
+            while (j < tokens.length) {
+                // this method will make application to sleep if it is  
needed
+                pauseIfNeeded();
+
+                StringBuffer toCheck = combineTokens(tokens, i, j);
+                j++;
+                printProgress(tokens.length, j, fileName);
+
+                HeuristicCheckerResult heurResult =  
isCheckOnInternetNeaded(heuristicCheckers, toCheck.toString());
+                if (heurResult.isCheckOnInternetNeaded()) {
+
+                    ReportEntry lastEntry =  
searchOnInternet(searchEngines, heurResult.getCodeSuggestedToBeChecked(),
+                            fileName);
+                    if (lastEntry != null) {
+                        raportEntry = lastEntry;
+                    }
+                    if (!heurResult.isShouldStretch() || lastEntry ==  
null) {
+                        break;
+                    }
+                }
+            }
+            i = j;
+            if (raportEntry != null) {
+                printReport(raportEntry);
+                reportDocument.addReportEntry(raportEntry);
+                raportEntry = null;
+            }
+        }
+    }
+
+    // TODO move this to report package....
+    /**
+     * print current state into console
+     *
+     * @param reportEntry
+     */
+    private void printReport(ReportEntry reportEntry) {
+        out.println("chunk of code copied:");
+        out.println("--------------------------------------------");
+        out.println(reportEntry.getCode());
+        out.println("--------------------------------------------");
+    }
+
+    /**
+     * Search for code in all engines. If code is found, an reportEntry  
will be
+     * returned Otherwise, null will be returned.
+     *
+     * @param searchEngines list of chosen search engine parsers
+     * @param code code to be checked
+     * @param fileName source file name
+     * @return an report entry
+     */
+    private ReportEntry searchOnInternet(List<ISearchEngine>  
searchEngines, String code, String fileName) {
+        ReportEntry toret = null;
+        List<SearchResult> found = new ArrayList<SearchResult>();
+        for (ISearchEngine searchEngine : searchEngines) {
+            if (searchEngine.isCodeFound(code.toString())) {
+                found.addAll(searchEngine.getSearchResults());
+            }
+        }
+        if (!found.isEmpty()) {
+            toret = new ReportEntry(found, code, fileName);
+        }
+        return toret;
+    }
+
+    /**
+     * @param heuristicCheckers lit of chosen heuristic checkers
+     * @param toCheck code to be checked
+     * @return heuristicCheckerResult with proper information for sliding  
window
+     *         algorithm
+     */
+    private HeuristicCheckerResult  
isCheckOnInternetNeaded(List<IHeuristicChecker> heuristicCheckers, String  
toCheck) {
+
+        HeuristicCheckerResult toret = new HeuristicCheckerResult(false,  
true, toCheck, null);
+        for (IHeuristicChecker checker : heuristicCheckers) {
+            toret = checker.checkByHeuristic(toCheck);
+            if (toret.isShouldStretch()) {
+                break;
+            }
+        }
+
+        return toret;
+    }
+
+    /**
+     * Append tokens from start position until end.
+     *
+     * @param tokens list of tokens to combine
+     * @param start position
+     * @param end position
+     * @return appended tokens
+     */
+    private StringBuffer combineTokens(String[] tokens, int start, int  
end) {
+
+        StringBuffer sb = new StringBuffer();
+        for (int k = start; k < end; k++) {
+            sb.append(tokens[k]);
+            sb.append(" ");
+        }
+        sb.append(tokens[end]);
+        return sb;
+    }
+
+    /**
+     * extract tokens
+     *
+     * @param code to be tokenised
+     * @return list of words
+     */
+    private String[] tokeniseString(String code) {
+        code = code.replaceAll("\\n", "\n ");
+        String[] tokens = code.split(STRING_DELIMETER_REGEX);
+        // this simple tokeniser returns array {""} when "" is tokenised
+        // I must avoid that behavior
+        if (tokens.length == 1 && tokens[0].equals(""))
+            tokens = new String[0];
+        return tokens;
+    }
+
+    /**
+     * This method just prints in console information about current  
progress.
+     *<p>
+     * Example:Analyzing file : c:\HelloWorld.java Progress: 2/200 (1%)
+     *
+     * @param whole is number of all tokens we iterate
+     * @param current is current position of iteration
+     * @param fileName is file name of source file
+     */
+    private void printProgress(int whole, int current, String fileName) {
+        // clear previous state
+        for (int i = 0; i < progressMessageLength; i++) {
+            System.out.print("\b");
+        }
+
+        String message = "Analyzing file: " + fileName + " Progress: " +  
current + "/" + whole + " ("
+                + (current * 100 / whole) + "%)";
+        this.progressMessageLength = message.length();
+        System.out.print(message);
+    }
+}
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/engines/ISearchEngine.java	Sun  
Aug 16 16:43:54 2009
+++ /trunk/src/main/java/org/apache/rat/pd/engines/ISearchEngine.java	Fri  
Aug 21 06:53:09 2009
@@ -30,20 +30,20 @@
   */
  public interface ISearchEngine {

-	/**
-	 * Checks if code part exist on this code search engine
-	 *
-	 * @param posibleCutAndPastedCode
-	 * @return boolean - true if this code is found on search engine
-	 */
-	boolean isCodeFound(String posibleCutAndPastedCode);
-
-	/**
-	 * This method can return search results with link where we can see  
exactly
-	 * what is found
-	 *
-	 * @return list of SearchResults for report if code is found on search
-	 *         engine
-	 */
-	List<SearchResult> getSearchResults();
-}
+    /**
+     * Checks if code part exist on this code search engine
+     *
+     * @param posibleCutAndPastedCode
+     * @return boolean - true if this code is found on search engine
+     */
+    boolean isCodeFound(String posibleCutAndPastedCode);
+
+    /**
+     * This method can return search results with link where we can see  
exactly
+     * what is found
+     *
+     * @return list of SearchResults for report if code is found on search
+     *         engine
+     */
+    List<SearchResult> getSearchResults();
+}
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/engines/KodersCodeSearchParser.java	 
Sat Aug  8 08:59:03 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/engines/KodersCodeSearchParser.java	 
Fri Aug 21 06:53:09 2009
@@ -22,29 +22,24 @@

  import java.util.List;

-
  /**
- * @author maka
- * implememtation for koders search
- *
+ * @author maka implememtation for koders search
   */
  public class KodersCodeSearchParser implements ISearchEngine {

-	@SuppressWarnings("unused")
-	private static final String serch  
= "http://www.koders.com/default.aspx?s=MyQuery&btn=&la=%2A&li=%2A";
-
-
-	@Override
-	public boolean isCodeFound(String posibleCutAndPastedCode) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-
-	@Override
-	public List<SearchResult> getSearchResults() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @SuppressWarnings("unused")
+    private static final String serch  
= "http://www.koders.com/default.aspx?s=MyQuery&btn=&la=%2A&li=%2A";
+
+    @Override
+    public boolean isCodeFound(String posibleCutAndPastedCode) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public List<SearchResult> getSearchResults() {
+        // TODO Auto-generated method stub
+        return null;
+    }

  }
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/engines/Managable.java	Sun Aug  
16 16:43:54 2009
+++ /trunk/src/main/java/org/apache/rat/pd/engines/Managable.java	Fri Aug  
21 06:53:09 2009
@@ -29,20 +29,16 @@
   * information about potentially plagiarised code from search engine.
   *
   * @author maka
- *
   */
  public interface Managable {
-	/**
-	 * This function can retrieve information about potentially plagiarised  
code
-	 * from search engine.
-	 *
-	 * NOTE: for now there are only this types of exceptions
-	 *
-	 * @param posibleCutAndPastedCode
-	 * @return
-	 * @throws IOException
-	 * @throws ServiceException
-	 */
-	boolean gueryEngine(String posibleCutAndPastedCode) throws IOException,
-			ServiceException;
-}
+    /**
+     * This function can retrieve information about potentially  
plagiarised code
+     * from search engine. NOTE: for now there are only this types of  
exceptions
+     *
+     * @param posibleCutAndPastedCode
+     * @return
+     * @throws IOException
+     * @throws ServiceException
+     */
+    boolean gueryEngine(String posibleCutAndPastedCode) throws  
IOException, ServiceException;
+}
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/engines/RetryManager.java	Sun  
Aug 16 16:43:54 2009
+++ /trunk/src/main/java/org/apache/rat/pd/engines/RetryManager.java	Fri  
Aug 21 06:53:09 2009
@@ -25,61 +25,55 @@
  /**
   * This class is here to hide retry and timeout logic. This logic protects
   * application from exceptions caused by network problems or late response  
from
- * server.
- *
- * This is separate class because all ISearchEngine implementations will  
use it.
+ * server. This is separate class because all ISearchEngine  
implementations will
+ * use it.
   *
   * @author maka
- *
   */
  public class RetryManager {
-	private final Managable searchengine;
-	private final int numberOfRetry;
-	private final int timeout;
-
-	/**
-	 * @param searchengine
-	 *            engine to check code
-	 * @param numberOfRetry
-	 *            maximum number of retry before give up
-	 * @param timeout
-	 *            time between two requests
-	 */
-	public RetryManager(Managable searchengine, int numberOfRetry, int  
timeout) {
-		this.searchengine = searchengine;
-		this.timeout = timeout;
-		this.numberOfRetry = numberOfRetry;
-	}
-
-	/**
-	 * Retrieve information is code plagiarised. This method can several times
-	 * query SearchEngine for this information. If an exception happened, it
-	 * will wait before next retry.
-	 *
-	 * @param posibleCutAndPastedCode
-	 * @return information is code plagiarised
-	 */
-	public boolean isCodeFound(String posibleCutAndPastedCode) {
-		boolean toret = false;
-		for (int i = 0; i < numberOfRetry; i++) {
-			try {
-				toret = searchengine.gueryEngine(posibleCutAndPastedCode);
-				break;
-			} catch (Exception e) {
-				// just print number of retry
-				// Possible too long query is often catch here.
-				System.out.println("Search Engine error. - " + e.getMessage()
-						+ ". retry..." + i);
-			} finally {
-				try {
-					Thread.currentThread().sleep(timeout);
-				} catch (InterruptedException e) {
-					// just print message
-					System.err.println("sleap interupted...");
-				}
-			}
-		}
-		return toret;
-	}
+    private final Managable searchengine;
+    private final int numberOfRetry;
+    private final int timeout;
+
+    /**
+     * @param searchengine engine to check code
+     * @param numberOfRetry maximum number of retry before give up
+     * @param timeout time between two requests
+     */
+    public RetryManager(Managable searchengine, int numberOfRetry, int  
timeout) {
+        this.searchengine = searchengine;
+        this.timeout = timeout;
+        this.numberOfRetry = numberOfRetry;
+    }
+
+    /**
+     * Retrieve information is code plagiarised. This method can several  
times
+     * query SearchEngine for this information. If an exception happened,  
it
+     * will wait before next retry.
+     *
+     * @param posibleCutAndPastedCode
+     * @return information is code plagiarised
+     */
+    public boolean isCodeFound(String posibleCutAndPastedCode) {
+        boolean toret = false;
+        for (int i = 0; i < numberOfRetry; i++) {
+            try {
+                toret = searchengine.gueryEngine(posibleCutAndPastedCode);
+                break;
+            } catch (Exception e) {
+                // just print number of retry
+                // Possible too long query is often catch here.
+                System.out.println("Search Engine error. - " +  
e.getMessage() + ". retry..." + i);
+            } finally {
+                try {
+                    Thread.currentThread().sleep(timeout);
+                } catch (InterruptedException e) {
+                    // just print message
+                    System.err.println("sleap interupted...");
+                }
+            }
+        }
+        return toret;
+    }

  }
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/engines/SearchResult.java	Sun  
Aug 16 16:43:54 2009
+++ /trunk/src/main/java/org/apache/rat/pd/engines/SearchResult.java	Fri  
Aug 21 06:53:09 2009
@@ -28,212 +28,203 @@
   * about query and retrieved result.
   */
  public class SearchResult {
-	// project name/title
-	private String projectName;
-	// class name or filename
-	private String className;
-	// license read from site
-	private String licence = "";
-	// language in which this code part is written
-	private String language = "";
-	// name of owner of file if it is specified
-	private String owner;
-	// whole code which is passed for searching
-	private String codeForQuery;
-	// whole class where matching is found
-	private String codeInClass = "";
-	// code which is identical in result and query in proper format
-	// this is usually bold/colored text in search results
-	private List<String> matchedCode = new ArrayList<String>();
-	// link to result on site
-	private String link;
-	// engine where code is found
-	private String engine;
-	// package name
-	private String packageName;
-
-	/**
-	 * @return package name of source code file
-	 */
-	public String getPackageName() {
-		return packageName;
-	}
-
-	/**
-	 * Set package name of source code file
-	 *
-	 * @param packageName
-	 *            package name of source code file
-	 */
-	public void setPackageName(String packageName) {
-		this.packageName = packageName;
-	}
-
-	/**
-	 * Set license of source code
-	 *
-	 * @param licence
-	 *            license of source code
-	 */
-	public void setLicence(String licence) {
-		this.licence = licence;
-	}
-
-	/**
-	 * @return license of source code
-	 */
-	public String getLicence() {
-		return licence;
-	}
-
-	/**
-	 * Set programming language of source code
-	 *
-	 * @param language
-	 *            programming language of source code
-	 */
-	public void setLanguage(String language) {
-		this.language = language;
-	}
-
-	/**
-	 * @return programming language of source code
-	 */
-	public String getLanguage() {
-		return language;
-	}
-
-	/**
-	 * Set name of code owner
-	 *
-	 * @param owner
-	 *            name of code owner
-	 */
-	public void setOwner(String owner) {
-		this.owner = owner;
-	}
-
-	/**
-	 * @return name of code owner
-	 */
-	public String getOwner() {
-		return owner;
-	}
-
-	/**
-	 * Set project name
-	 *
-	 * @param projectName
-	 */
-	public void setProjectName(String projectName) {
-		this.projectName = projectName;
-	}
-
-	/**
-	 * @return project name
-	 */
-	public String getProjectName() {
-		return projectName;
-	}
-
-	/**
-	 * Set possible plagiarised code
-	 *
-	 * @param codeForQuery
-	 */
-	public void setCodeForQuery(String codeForQuery) {
-		this.codeForQuery = codeForQuery;
-	}
-
-	/**
-	 * @return possible plagiarised code
-	 */
-	public String getCodeForQuery() {
-		return codeForQuery;
-	}
-
-	/**
-	 * Set list of matched code parts
-	 *
-	 * @param matchedCode
-	 *            list of matched code parts
-	 */
-	public void setMatchedCode(List<String> matchedCode) {
-		this.matchedCode = matchedCode;
-	}
-
-	/**
-	 * @return list of matched code parts
-	 */
-	public List<String> getMatchedCode() {
-		return matchedCode;
-	}
-
-	/**
-	 * Set source file name
-	 *
-	 * @param className
-	 *            source file name
-	 */
-	public void setClassName(String className) {
-		this.className = className;
-	}
-
-	/**
-	 * @return source file name
-	 */
-	public String getClassName() {
-		return className;
-	}
-
-	/**
-	 * Set code in class
-	 *
-	 * @param codeInClass
-	 *            raw code in class
-	 */
-	public void setCodeInClass(String codeInClass) {
-		this.codeInClass = codeInClass;
-	}
-
-	/**
-	 * @return code in class
-	 */
-	public String getCodeInClass() {
-		return codeInClass;
-	}
-
-	/**
-	 * Set URL to site where code is found
-	 *
-	 * @param link
-	 *            URL to site where code is found
-	 */
-	public void setLink(String link) {
-		this.link = link;
-	}
-
-	/**
-	 * @return URL to site where code is found
-	 */
-	public String getLink() {
-		return link;
-	}
-
-	/**
-	 * Set name of CodeSearchEngine
-	 *
-	 * @param engine
-	 *            name of CodeSearchEngine
-	 */
-	public void setEngine(String engine) {
-		this.engine = engine;
-	}
-
-	/**
-	 * @return name of CodeSearchEngine
-	 */
-	public String getEngine() {
-		return engine;
-	}
-}
+    // project name/title
+    private String projectName;
+    // class name or filename
+    private String className;
+    // license read from site
+    private String licence = "";
+    // language in which this code part is written
+    private String language = "";
+    // name of owner of file if it is specified
+    private String owner;
+    // whole code which is passed for searching
+    private String codeForQuery;
+    // whole class where matching is found
+    private String codeInClass = "";
+    // code which is identical in result and query in proper format
+    // this is usually bold/colored text in search results
+    private List<String> matchedCode = new ArrayList<String>();
+    // link to result on site
+    private String link;
+    // engine where code is found
+    private String engine;
+    // package name
+    private String packageName;
+
+    /**
+     * @return package name of source code file
+     */
+    public String getPackageName() {
+        return packageName;
+    }
+
+    /**
+     * Set package name of source code file
+     *
+     * @param packageName package name of source code file
+     */
+    public void setPackageName(String packageName) {
+        this.packageName = packageName;
+    }
+
+    /**
+     * Set license of source code
+     *
+     * @param licence license of source code
+     */
+    public void setLicence(String licence) {
+        this.licence = licence;
+    }
+
+    /**
+     * @return license of source code
+     */
+    public String getLicence() {
+        return licence;
+    }
+
+    /**
+     * Set programming language of source code
+     *
+     * @param language programming language of source code
+     */
+    public void setLanguage(String language) {
+        this.language = language;
+    }
+
+    /**
+     * @return programming language of source code
+     */
+    public String getLanguage() {
+        return language;
+    }
+
+    /**
+     * Set name of code owner
+     *
+     * @param owner name of code owner
+     */
+    public void setOwner(String owner) {
+        this.owner = owner;
+    }
+
+    /**
+     * @return name of code owner
+     */
+    public String getOwner() {
+        return owner;
+    }
+
+    /**
+     * Set project name
+     *
+     * @param projectName
+     */
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+    }
+
+    /**
+     * @return project name
+     */
+    public String getProjectName() {
+        return projectName;
+    }
+
+    /**
+     * Set possible plagiarised code
+     *
+     * @param codeForQuery
+     */
+    public void setCodeForQuery(String codeForQuery) {
+        this.codeForQuery = codeForQuery;
+    }
+
+    /**
+     * @return possible plagiarised code
+     */
+    public String getCodeForQuery() {
+        return codeForQuery;
+    }
+
+    /**
+     * Set list of matched code parts
+     *
+     * @param matchedCode list of matched code parts
+     */
+    public void setMatchedCode(List<String> matchedCode) {
+        this.matchedCode = matchedCode;
+    }
+
+    /**
+     * @return list of matched code parts
+     */
+    public List<String> getMatchedCode() {
+        return matchedCode;
+    }
+
+    /**
+     * Set source file name
+     *
+     * @param className source file name
+     */
+    public void setClassName(String className) {
+        this.className = className;
+    }
+
+    /**
+     * @return source file name
+     */
+    public String getClassName() {
+        return className;
+    }
+
+    /**
+     * Set code in class
+     *
+     * @param codeInClass raw code in class
+     */
+    public void setCodeInClass(String codeInClass) {
+        this.codeInClass = codeInClass;
+    }
+
+    /**
+     * @return code in class
+     */
+    public String getCodeInClass() {
+        return codeInClass;
+    }
+
+    /**
+     * Set URL to site where code is found
+     *
+     * @param link URL to site where code is found
+     */
+    public void setLink(String link) {
+        this.link = link;
+    }
+
+    /**
+     * @return URL to site where code is found
+     */
+    public String getLink() {
+        return link;
+    }
+
+    /**
+     * Set name of CodeSearchEngine
+     *
+     * @param engine name of CodeSearchEngine
+     */
+    public void setEngine(String engine) {
+        this.engine = engine;
+    }
+
+    /**
+     * @return name of CodeSearchEngine
+     */
+    public String getEngine() {
+        return engine;
+    }
+}
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/engines/google/GoogleCodeSearchParser.java	 
Mon Aug 17 13:56:27 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/engines/google/GoogleCodeSearchParser.java	 
Fri Aug 21 06:53:09 2009
@@ -47,369 +47,325 @@
   * This class is for communication between search engine and this program.
   *
   * @author maka:
- *
   */
  public class GoogleCodeSearchParser implements ISearchEngine, Managable {

-	/**
-	 * This constant describe minimum of distance between two strings to  
decide
-	 * that they are similar It is from interval (0-100). Larger number means
-	 * more restrictive matching
-	 */
-	public static final int SIMILARITY = 50;
-	// numberOfRetry maximum number of retry before give up
-	public static final int NUMBER_OF_RETRY = 5;
-	// timeout time between two requests
-	public static final int WAIT_TIME = 2000;
-	// 2324 is too long
-	public static final int CODESEARCH_QUERY_MAX_LENGTH = 1024;
-
-	private static final String CODESEARCH_FEEDS_URL  
= "http://www.google.com/codesearch/feeds/search?";
-
-	public static final String RESULT_NUMBER = "20";
-
-	/**
-	 * This class is there to estimate matching of results returned by
-	 * GoogleCodeSearch with real code. It will read CodeSearchFeed and  
analyze
-	 * matching between Google results and actual code part. Maybe it will be
-	 * better if GoogleCodeSearch can return file in which matched query, but  
it
-	 * is not possible from gdata-codesearch api.
-	 *
-	 * //TODO Think about using third party api for getting code from
-	 * GoogleCodeSearch site. HTMLUnit can do that.
-	 *
-	 * @author maka
-	 *
-	 */
-	private class Postprocessor {
-
-		private final int similarityFactor;
-
-		public Postprocessor(int similarityFactor) {
-			this.similarityFactor = similarityFactor;
-		}
-
-		/**
-		 * Decide are strings similar using various algorithms for string
-		 * similarity. If similarity is found based on any type of checking,
-		 * results will be true.
-		 *
-		 * @param searchResults
-		 *            list of results for our query
-		 * @param posibleCutAndPastedCode
-		 *            code currently being checked
-		 * @return information is there any match is found
-		 */
-		public boolean isMatchFound(List<SearchResult> searchResults,
-				String posibleCutAndPastedCode) {
-			boolean toret = false;
-			String[] lines = posibleCutAndPastedCode.split("\n *");
-
-			// iterate ower results
-			for (SearchResult searchResult : searchResults) {
-				// TODO if matches are duplicated, there is unnecessary checking
-				for (String match : searchResult.getMatchedCode()) {
-
-					for (String line : lines) {
-						if (isMatchingByDistance(match, line)
-								|| this.isMatchingByRegex(match, line)) {
-							toret = true;
-							break;
-						}
-					}
-				}
-			}
-			return toret;
-		}
-
-		/**
-		 * Make decision are strings similar by calculation of string distance
-		 *
-		 * @param source
-		 *            source code
-		 * @param toMatch
-		 *            code for comparation
-		 * @return information are code parts similar based on
-		 *         LevenshteinDistance algorithm
-		 */
-		boolean isMatchingByDistance(String source, String toMatch) {
-
-			int maxLength = toMatch.length() > source.length() ? toMatch
-					.length() : source.length();
-			int distance = StringUtils.getLevenshteinDistance(toMatch, source);
-			boolean toret = (maxLength > 0)
-					&& (similarityFactor < 100 - (distance * 100) / maxLength);
-			// TODO think about lines with only one character. }
-			// for example!!!
-			return toret;
-		}
-
-		/**
-		 * Make decision are strings similar by matching by regular expression
-		 *
-		 * @param source
-		 *            source code
-		 * @param toMatch
-		 *            code for comparation
-		 * @return information are code parts similar based on similarity by
-		 *         regular expression
-		 */
-		boolean isMatchingByRegex(String source, String toMatch) {
-
-			Pattern p = Pattern.compile(regexGenerator.stringToRegex(toMatch));
-
-			Matcher m = p.matcher(source);
-			return m.find();
-		}
-	}
-
-	private Postprocessor postprocessor = new Postprocessor(SIMILARITY);
-	private CodeSearchService codesearchService = new CodeSearchService(
-			"apache-rat-pd");
-	private List<SearchResult> searchResults = new ArrayList<SearchResult>();
-	private RegexGenerator regexGenerator = new MultilineRegexGenerator();
-
-	private final RetryManager retryManager;
-	private final 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);
-	}
-
-	private String getLanguageQuery() {
-		String toret = "";
-		if (!language.equals(IHeuristicChecker.ALL_LANGUAGES)) {
-			toret = "as_lang=" + this.language + "&";
-		}
-		return toret;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see org.apache.rat.pd.engines.ISearchEngine#getSearchResults()
-	 */
-	@Override
-	public List<SearchResult> getSearchResults() {
-		return searchResults;
-	}
-
-	/**
-	 * @param posibleCutAndPastedCode
-	 *            code for checking
-	 * @return proper URL for gdata-codesearch API
-	 * @throws MalformedURLException
-	 */
-	@SuppressWarnings("deprecation")
-	// FIXME URLEncoding is system dependent now
-	private URL createUrl(String posibleCutAndPastedCode)
-			throws MalformedURLException {
-		URL toret = new URL(CODESEARCH_FEEDS_URL
-				+ getLanguageQuery()
-				+ "q="
-				+ URLEncoder.encode(regexGenerator
-						.stringToRegex(posibleCutAndPastedCode))
-				+ "&max-results=" + RESULT_NUMBER);
-
-		out.println(posibleCutAndPastedCode + " -> "
-				+ regexGenerator.stringToRegex(posibleCutAndPastedCode));
-		return toret;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see
-	 * org.apache.rat.pd.engines.ISearchEngine#isCodeFound(java.lang.String)
-	 */
-	@Override
-	public boolean isCodeFound(String posibleCutAndPastedCode) {
-		searchResults.clear();
-		return retryManager.isCodeFound(posibleCutAndPastedCode);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see org.apache.rat.pd.engines.Managable#gueryEngine(java.lang.String)
-	 */
-	@Override
-	public boolean gueryEngine(String posibleCutAndPastedCode)
-			throws IOException, ServiceException {
-		boolean toreturn = false;
-
-		List<URL> listOfFeedUrl = splitLongUrl(posibleCutAndPastedCode,
-				CODESEARCH_QUERY_MAX_LENGTH);
-		// pozovi svaki url i parsiraj rezultate u zajednicku mapu
-		for (URL url : listOfFeedUrl) {
-			CodeSearchFeed myFeed = codesearchService.getFeed(url,
-					CodeSearchFeed.class);
-			List<SearchResult> srList = createSearchResutl(myFeed,
-					posibleCutAndPastedCode);
-			boolean found = (srList.size() > 0)
-					&& (postprocessor.isMatchFound(srList,
-							posibleCutAndPastedCode));
-
-			toreturn = toreturn || found;
-
-			if (found) {
-				searchResults.addAll(srList);
-			}
-			// for test porposes
-			// try {
-			// printAdditionalInformation(myFeed, System.out);
-			// } catch (Exception e) {
-			// // TODO Auto-generated catch block
-			// e.printStackTrace();
-			// }
-		}
-
-		return toreturn;
-	}
-
-	/**
-	 * This method can split code to produce URLs that will not be greater  
then
-	 * length. For GoogleCodeSearch length is 1024.
-	 *
-	 * @param posibleCutAndPastedCode
-	 *            code to be checked
-	 * @param length
-	 *            maximum length of query which code search engine can manage
-	 * @return list of url-s not longer then @length
-	 * @throws IOException
-	 */
-	List<URL> splitLongUrl(String posibleCutAndPastedCode, int length)
-			throws IOException {
-		List<URL> toret = new ArrayList<URL>();
-		// lines must be less then 1024 characters
-		String[] lines = posibleCutAndPastedCode.split("\n *");
-		URL url = null;
-
-		int i = 0;
-		int j = 0;
-
-		while (i < lines.length) {
-			while (j < lines.length) {
-				StringBuffer currenCodePart = combineLines(lines, i, j);
-				URL currentUrl = createUrl(currenCodePart.toString());
-				if (currentUrl.toString().length() <= length) {
-					url = currentUrl;
-					j++;
-				} else {
-					i = j;
-					break;
-				}
-			}
-			if (url != null) {
-				toret.add(url);
-				url = null;
-			}
-			if (j == lines.length) {
-				break;
-			}
-		}
-		return toret;
-	}
-
-	/**
-	 * Append tokens from start position until end, inclusive.
-	 *
-	 * @param tokens
-	 * @param start
-	 * @param end
-	 * @return
-	 */
-	private StringBuffer combineLines(String[] tokens, int start, int end) {
-
-		StringBuffer sb = new StringBuffer();
-		for (int k = start; k < end; k++) {
-			sb.append(tokens[k]);
-			sb.append("\n");
-		}
-		sb.append(tokens[end]);
-		return sb;
-	}
-
-	/**
-	 * for debugging
-	 *
-	 * @param myFeed
-	 *            GoogleCodeSearch feed
-	 * @param entry
-	 *            Google CodeSearchEntry
-	 * @param out
-	 *            print stream for printing current information
-	 * @throws Exception
-	 */
-	private void printAdditionalInformation(CodeSearchFeed myFeed,
-			CodeSearchEntry entry) {
-		out.println("\tgetEtag: " + entry.getEtag());
-		out
-				.println("\tgetExtensionLocalName: "
-						+ entry.getExtensionLocalName());
-		out.println("\tgetId: " + entry.getId());
-		out.println("\tgetVersionId: " + entry.getVersionId());
-		out.println("\tgetCategories: " + entry.getCategories().size());
-		out.println("\tgetXmlBlob: " + entry.getXmlBlob());
-		out.println("\tgetVersionId: " + entry.getVersionId());
-
-		out.println("\tgetExtensionLocalName: "
-				+ entry.getFile().getExtensionLocalName());
-		out.println("\tgetPackage: ");
-		out.println("\t\t Name:" + entry.getPackage().getName());
-		out.println("\tAuthor: " + entry.getAuthors().get(0).getName());
-		out.println("\tTitle: " + entry.getTitle());
-		out.println("Id: " + entry.getId());
-		out.println("Link: " + entry.getHtmlLink().getHref());
-		if (entry.getRights() != null)
-			out.println("\tLicense:" + entry.getRights().getPlainText());
-		for (Match m : entry.getMatches()) {
-			out.println("\t\tMatch " + m.getLineNumber() + ": "
-					+ m.getLineText().getPlainText());
-		}
-	}
-
-	/**
-	 * Parse GoogleCodeSearch feed and pack retrieved information in proper to
-	 * us form.
-	 *
-	 * @param myFeed
-	 *            GoogleCodeSearch feed
-	 * @param posibleCutAndPastedCode
-	 *            code to be checked
-	 * @return list of search result retrieved from GoogleCodeSearch feed
-	 */
-	private List<SearchResult> createSearchResutl(CodeSearchFeed myFeed,
-			String posibleCutAndPastedCode) {
-		List<SearchResult> toRet = new ArrayList<SearchResult>();
-		for (CodeSearchEntry entry : myFeed.getEntries()) {
-			SearchResult searchResult = new SearchResult();
-			searchResult.setEngine("GoogleCodeSearch");
-			searchResult.setCodeForQuery(posibleCutAndPastedCode);
-			searchResult.setLink(entry.getHtmlLink().getHref());
-			searchResult.setProjectName(entry.getPackage().getName());
-			searchResult.setOwner(entry.getAuthors().get(0).getName());
-			searchResult.setClassName(entry.getTitle().getPlainText()
-					.replaceFirst(".*/", ""));
-			searchResult.setPackageName(entry.getTitle().getPlainText()
-					.replace(searchResult.getClassName(), ""));
-			searchResult.setCodeInClass(entry.getTextContent().getContent()
-					.getPlainText());
-			if (entry.getRights() != null)
-				searchResult.setLicence(entry.getRights().getPlainText());
-			for (Match m : entry.getMatches()) {
-				searchResult.getMatchedCode().add(
-						m.getLineText().getPlainText());
-			}
-			toRet.add(searchResult);
-
-			printAdditionalInformation(myFeed, entry);
-		}
-
-		return toRet;
-	}
+    /**
+     * This constant describe minimum of distance between two strings to  
decide
+     * that they are similar It is from interval (0-100). Larger number  
means
+     * more restrictive matching
+     */
+    public static final int SIMILARITY = 50;
+    // numberOfRetry maximum number of retry before give up
+    public static final int NUMBER_OF_RETRY = 5;
+    // timeout time between two requests
+    public static final int WAIT_TIME = 2000;
+    // 2324 is too long
+    public static final int CODESEARCH_QUERY_MAX_LENGTH = 1024;
+
+    private static final String CODESEARCH_FEEDS_URL  
= "http://www.google.com/codesearch/feeds/search?";
+
+    public static final String RESULT_NUMBER = "20";
+
+    /**
+     * This class is there to estimate matching of results returned by
+     * GoogleCodeSearch with real code. It will read CodeSearchFeed and  
analyze
+     * matching between Google results and actual code part. Maybe it will  
be
+     * better if GoogleCodeSearch can return file in which matched query,  
but it
+     * is not possible from gdata-codesearch api. //TODO Think about using  
third
+     * party api for getting code from GoogleCodeSearch site. HTMLUnit can  
do
+     * that.
+     *
+     * @author maka
+     */
+    private class Postprocessor {
+
+        private final int similarityFactor;
+
+        public Postprocessor(int similarityFactor) {
+            this.similarityFactor = similarityFactor;
+        }
+
+        /**
+         * Decide are strings similar using various algorithms for string
+         * similarity. If similarity is found based on any type of  
checking,
+         * results will be true.
+         *
+         * @param searchResults list of results for our query
+         * @param posibleCutAndPastedCode code currently being checked
+         * @return information is there any match is found
+         */
+        public boolean isMatchFound(List<SearchResult> searchResults,  
String posibleCutAndPastedCode) {
+            boolean toret = false;
+            String[] lines = posibleCutAndPastedCode.split("\n *");
+
+            // iterate ower results
+            for (SearchResult searchResult : searchResults) {
+                // TODO if matches are duplicated, there is unnecessary  
checking
+                for (String match : searchResult.getMatchedCode()) {
+
+                    for (String line : lines) {
+                        if (isMatchingByDistance(match, line) ||  
this.isMatchingByRegex(match, line)) {
+                            toret = true;
+                            break;
+                        }
+                    }
+                }
+            }
+            return toret;
+        }
+
+        /**
+         * Make decision are strings similar by calculation of string  
distance
+         *
+         * @param source source code
+         * @param toMatch code for comparation
+         * @return information are code parts similar based on
+         *         LevenshteinDistance algorithm
+         */
+        boolean isMatchingByDistance(String source, String toMatch) {
+
+            int maxLength = toMatch.length() > source.length() ?  
toMatch.length() : source.length();
+            int distance = StringUtils.getLevenshteinDistance(toMatch,  
source);
+            boolean toret = (maxLength > 0) && (similarityFactor < 100 -  
(distance * 100) / maxLength);
+            // TODO think about lines with only one character. }
+            // for example!!!
+            return toret;
+        }
+
+        /**
+         * Make decision are strings similar by matching by regular  
expression
+         *
+         * @param source source code
+         * @param toMatch code for comparation
+         * @return information are code parts similar based on similarity  
by
+         *         regular expression
+         */
+        boolean isMatchingByRegex(String source, String toMatch) {
+
+            Pattern p =  
Pattern.compile(regexGenerator.stringToRegex(toMatch));
+
+            Matcher m = p.matcher(source);
+            return m.find();
+        }
+    }
+
+    private Postprocessor postprocessor = new Postprocessor(SIMILARITY);
+    private CodeSearchService codesearchService = new  
CodeSearchService("apache-rat-pd");
+    private List<SearchResult> searchResults = new  
ArrayList<SearchResult>();
+    private RegexGenerator regexGenerator = new MultilineRegexGenerator();
+
+    private final RetryManager retryManager;
+    private final 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);
+    }
+
+    private String getLanguageQuery() {
+        String toret = "";
+        if (!language.equals(IHeuristicChecker.ALL_LANGUAGES)) {
+            toret = "as_lang=" + this.language + "&";
+        }
+        return toret;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.rat.pd.engines.ISearchEngine#getSearchResults()
+     */
+    @Override
+    public List<SearchResult> getSearchResults() {
+        return searchResults;
+    }
+
+    /**
+     * @param posibleCutAndPastedCode code for checking
+     * @return proper URL for gdata-codesearch API
+     * @throws MalformedURLException
+     */
+    @SuppressWarnings("deprecation")
+    // FIXME URLEncoding is system dependent now
+    private URL createUrl(String posibleCutAndPastedCode) throws  
MalformedURLException {
+        URL toret = new URL(CODESEARCH_FEEDS_URL + getLanguageQuery()  
+ "q="
+                +  
URLEncoder.encode(regexGenerator.stringToRegex(posibleCutAndPastedCode))  
+ "&max-results="
+                + RESULT_NUMBER);
+
+        out.println(posibleCutAndPastedCode + " -> " +  
regexGenerator.stringToRegex(posibleCutAndPastedCode));
+        return toret;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     *  
org.apache.rat.pd.engines.ISearchEngine#isCodeFound(java.lang.String)
+     */
+    @Override
+    public boolean isCodeFound(String posibleCutAndPastedCode) {
+        searchResults.clear();
+        return retryManager.isCodeFound(posibleCutAndPastedCode);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see  
org.apache.rat.pd.engines.Managable#gueryEngine(java.lang.String)
+     */
+    @Override
+    public boolean gueryEngine(String posibleCutAndPastedCode) throws  
IOException, ServiceException {
+        boolean toreturn = false;
+
+        List<URL> listOfFeedUrl = splitLongUrl(posibleCutAndPastedCode,  
CODESEARCH_QUERY_MAX_LENGTH);
+        // pozovi svaki url i parsiraj rezultate u zajednicku mapu
+        for (URL url : listOfFeedUrl) {
+            CodeSearchFeed myFeed = codesearchService.getFeed(url,  
CodeSearchFeed.class);
+            List<SearchResult> srList = createSearchResutl(myFeed,  
posibleCutAndPastedCode);
+            boolean found = (srList.size() > 0) &&  
(postprocessor.isMatchFound(srList, posibleCutAndPastedCode));
+
+            toreturn = toreturn || found;
+
+            if (found) {
+                searchResults.addAll(srList);
+            }
+            // for test porposes
+            // try {
+            // printAdditionalInformation(myFeed, System.out);
+            // } catch (Exception e) {
+            // // TODO Auto-generated catch block
+            // e.printStackTrace();
+            // }
+        }
+
+        return toreturn;
+    }
+
+    /**
+     * This method can split code to produce URLs that will not be greater  
then
+     * length. For GoogleCodeSearch length is 1024.
+     *
+     * @param posibleCutAndPastedCode code to be checked
+     * @param length maximum length of query which code search engine can  
manage
+     * @return list of url-s not longer then @length
+     * @throws IOException
+     */
+    List<URL> splitLongUrl(String posibleCutAndPastedCode, int length)  
throws IOException {
+        List<URL> toret = new ArrayList<URL>();
+        // lines must be less then 1024 characters
+        String[] lines = posibleCutAndPastedCode.split("\n *");
+        URL url = null;
+
+        int i = 0;
+        int j = 0;
+
+        while (i < lines.length) {
+            while (j < lines.length) {
+                StringBuffer currenCodePart = combineLines(lines, i, j);
+                URL currentUrl = createUrl(currenCodePart.toString());
+                if (currentUrl.toString().length() <= length) {
+                    url = currentUrl;
+                    j++;
+                } else {
+                    i = j;
+                    break;
+                }
+            }
+            if (url != null) {
+                toret.add(url);
+                url = null;
+            }
+            if (j == lines.length) {
+                break;
+            }
+        }
+        return toret;
+    }
+
+    /**
+     * Append tokens from start position until end, inclusive.
+     *
+     * @param tokens
+     * @param start
+     * @param end
+     * @return
+     */
+    private StringBuffer combineLines(String[] tokens, int start, int end)  
{
+
+        StringBuffer sb = new StringBuffer();
+        for (int k = start; k < end; k++) {
+            sb.append(tokens[k]);
+            sb.append("\n");
+        }
+        sb.append(tokens[end]);
+        return sb;
+    }
+
+    /**
+     * for debugging
+     *
+     * @param myFeed GoogleCodeSearch feed
+     * @param entry Google CodeSearchEntry
+     * @param out print stream for printing current information
+     * @throws Exception
+     */
+    private void printAdditionalInformation(CodeSearchFeed myFeed,  
CodeSearchEntry entry) {
+        out.println("\tgetEtag: " + entry.getEtag());
+        out.println("\tgetExtensionLocalName: " +  
entry.getExtensionLocalName());
+        out.println("\tgetId: " + entry.getId());
+        out.println("\tgetVersionId: " + entry.getVersionId());
+        out.println("\tgetCategories: " + entry.getCategories().size());
+        out.println("\tgetXmlBlob: " + entry.getXmlBlob());
+        out.println("\tgetVersionId: " + entry.getVersionId());
+
+        out.println("\tgetExtensionLocalName: " +  
entry.getFile().getExtensionLocalName());
+        out.println("\tgetPackage: ");
+        out.println("\t\t Name:" + entry.getPackage().getName());
+        out.println("\tAuthor: " + entry.getAuthors().get(0).getName());
+        out.println("\tTitle: " + entry.getTitle());
+        out.println("Id: " + entry.getId());
+        out.println("Link: " + entry.getHtmlLink().getHref());
+        if (entry.getRights() != null)
+            out.println("\tLicense:" + entry.getRights().getPlainText());
+        for (Match m : entry.getMatches()) {
+            out.println("\t\tMatch " + m.getLineNumber() + ": " +  
m.getLineText().getPlainText());
+        }
+    }
+
+    /**
+     * Parse GoogleCodeSearch feed and pack retrieved information in  
proper to
+     * us form.
+     *
+     * @param myFeed GoogleCodeSearch feed
+     * @param posibleCutAndPastedCode code to be checked
+     * @return list of search result retrieved from GoogleCodeSearch feed
+     */
+    private List<SearchResult> createSearchResutl(CodeSearchFeed myFeed,  
String posibleCutAndPastedCode) {
+        List<SearchResult> toRet = new ArrayList<SearchResult>();
+        for (CodeSearchEntry entry : myFeed.getEntries()) {
+            SearchResult searchResult = new SearchResult();
+            searchResult.setEngine("GoogleCodeSearch");
+            searchResult.setCodeForQuery(posibleCutAndPastedCode);
+            searchResult.setLink(entry.getHtmlLink().getHref());
+            searchResult.setProjectName(entry.getPackage().getName());
+            searchResult.setOwner(entry.getAuthors().get(0).getName());
+             
searchResult.setClassName(entry.getTitle().getPlainText().replaceFirst(".*/", ""));
+             
searchResult.setPackageName(entry.getTitle().getPlainText().replace(searchResult.getClassName(), ""));
+             
searchResult.setCodeInClass(entry.getTextContent().getContent().getPlainText());
+            if (entry.getRights() != null)
+                searchResult.setLicence(entry.getRights().getPlainText());
+            for (Match m : entry.getMatches()) {
+                 
searchResult.getMatchedCode().add(m.getLineText().getPlainText());
+            }
+            toRet.add(searchResult);
+
+            printAdditionalInformation(myFeed, entry);
+        }
+
+        return toRet;
+    }

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/engines/google/MultilineRegexGenerator.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/engines/google/MultilineRegexGenerator.java	 
Fri Aug 21 06:53:09 2009
@@ -27,58 +27,59 @@
   * this class cannot match it.
   *
   * @author maka
- *
   */
  public class MultilineRegexGenerator extends RegexGenerator {

-	private static final String LINE_BEGINNING_REGEX = "^";
-	private static final String LINE_END_REGEX = "$";
-	private static final String BLANK_MARK_FOR_URL = " ";
-
-	/* (non-Javadoc)
-	 * @see  
org.apache.rat.pd.engines.google.RegexGenerator#stringToRegex(java.lang.String)
-	 */
-	@Override
-	public String stringToRegex(String sourceCode) {
-		String toret = "";
-		String[] lines = sourceCode.split("\n *");
-		lines = excludeBlankLines(lines);
-		for (int i = 0; i < lines.length; i++) {
-			toret += LINE_BEGINNING_REGEX + ZERO_OR_MORE_BLANK_SPACE
-					+ super.stringToRegex(lines[i]);
-			// for current line, it is better not to add LINE_END_REGEX.
-			// we don't know is end of real line in code is reached
-			if (i != lines.length - 1) {
-				toret += ZERO_OR_MORE_BLANK_SPACE + LINE_END_REGEX
-						+ BLANK_MARK_FOR_URL;
-			}
-		}
-		return toret;
-	}
-
-	/**
-	 * Exclude blank lines from array.
-	 *
-	 * @param lines list of lines of code
-	 * @return array of code lines without empty ones
-	 */
-	private String[] excludeBlankLines(String[] lines) {
-		int lentgh = lines.length;
-		// determining new array length
-		for (String string : lines) {
-			if (string.trim().isEmpty()) {
-				lentgh--;
-			}
-		}
-		// copy non-blank lines
-		String[] toret = new String[lentgh];
-		int index = 0;
-		for (String line : lines) {
-			if (!line.trim().isEmpty()) {
-				toret[index] = line;
-				index++;
-			}
-		}
-		return toret;
-	}
-}
+    private static final String LINE_BEGINNING_REGEX = "^";
+    private static final String LINE_END_REGEX = "$";
+    private static final String BLANK_MARK_FOR_URL = " ";
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     *  
org.apache.rat.pd.engines.google.RegexGenerator#stringToRegex(java.lang
+     * .String)
+     */
+    @Override
+    public String stringToRegex(String sourceCode) {
+        String toret = "";
+        String[] lines = sourceCode.split("\n *");
+        lines = excludeBlankLines(lines);
+        for (int i = 0; i < lines.length; i++) {
+            toret += LINE_BEGINNING_REGEX + ZERO_OR_MORE_BLANK_SPACE +  
super.stringToRegex(lines[i]);
+            // for current line, it is better not to add LINE_END_REGEX.
+            // we don't know is end of real line in code is reached
+            if (i != lines.length - 1) {
+                toret += ZERO_OR_MORE_BLANK_SPACE + LINE_END_REGEX +  
BLANK_MARK_FOR_URL;
+            }
+        }
+        return toret;
+    }
+
+    /**
+     * Exclude blank lines from array.
+     *
+     * @param lines list of lines of code
+     * @return array of code lines without empty ones
+     */
+    private String[] excludeBlankLines(String[] lines) {
+        int lentgh = lines.length;
+        // determining new array length
+        for (String string : lines) {
+            if (string.trim().isEmpty()) {
+                lentgh--;
+            }
+        }
+        // copy non-blank lines
+        String[] toret = new String[lentgh];
+        int index = 0;
+        for (String line : lines) {
+            if (!line.trim().isEmpty()) {
+                toret[index] = line;
+                index++;
+            }
+        }
+        return toret;
+    }
+}
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/engines/google/RegexGenerator.java	 
Mon Aug 17 10:54:36 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/engines/google/RegexGenerator.java	 
Fri Aug 21 06:53:09 2009
@@ -28,128 +28,119 @@
   * then replace regex matching whitespace to ensure that our search is non
   * sensitive to whitespace and new line characters.
   *
- * @author Maka
- *
+ * @author maka
   */
  public class RegexGenerator {
-	// special signs in regex
-	protected final static String L_PARENTHESIS = "\\(";
-	protected final static String R_PARENTHESIS = "\\)";
-	protected final static String L_SQUARE_BRACKET = "\\[";
-	protected final static String R_SQUARE_BRACKET = "\\]";
-	protected final static String L_CURLY_BRACKET = "\\{";
-	protected final static String R_CURLY_BRACKET = "\\}";
-	protected final static String DOT = "\\.";
-	protected final static String QUESTION_MARK = "\\?";
-	protected final static String ASTERIX = "\\*";
-	protected final static String POWER = "\\^";
-	protected final static String DOLLAR_SIGN = "\\$";
-	protected final static String PLUS_SIGN = "\\+";
-	protected final static String MINUS_SIGN = "\\-";
-	protected final static String VERTICAL_LINE = "\\|";
-	protected final static String BACK_SLASH = "\\";
-	// non literals
-	protected final static String LES_THEN = "<";
-	protected final static String GREAT_THEN = ">";
-	protected final static String SEMICOLOMN = ";";
-	protected final static String COLON = ":";
-	protected final static String EQUALS = "=";
-	protected final static String SLASH = "/";
-	protected final static String DOUBLE_QUOTES = "\"";
-
-	// regex for matching
-	protected final static String ZERO_OR_MORE_BLANK_SPACE = "(\\s?)+";
-	protected final static String ONE_OR_MORE_BLANK_SPACE = "\\s+";
-	// protected final static String NOT_A_CHARACTER = "";
-
-	// other
-	protected final static String BLANK_SPACE = " ";
-
-	/**
-	 * this regex is better then '\s* when it is used on GoogleCodeSearch
-	 */
-	protected final static String ZERO_OR_MORE_BLANK_SPACE_REGEX  
= "(\\\\s?)+";
-
-	protected final static String[] regExpresions = { BACK_SLASH,
-			L_PARENTHESIS, DOLLAR_SIGN, R_PARENTHESIS, L_SQUARE_BRACKET,
-			R_SQUARE_BRACKET, L_CURLY_BRACKET, R_CURLY_BRACKET, DOT,
-			QUESTION_MARK, ASTERIX, POWER, PLUS_SIGN, MINUS_SIGN,
-			VERTICAL_LINE, LES_THEN, GREAT_THEN, SEMICOLOMN, COLON, EQUALS,
-			SLASH, DOUBLE_QUOTES };
-
-	/**
-	 * Returns regular expression of source code
-	 *
-	 * @param sourceCode
-	 *            code from which regex are generated
-	 * @return regex generated from source code
-	 */
-	public String stringToRegex(String sourceCode) {
-		// add whitespace before and after any non-character
-		sourceCode = addWhitespaceAroundNonLiteral(sourceCode);
-		// replace non literal with proper regex
-		sourceCode = replaceNonLiteralWithProperRegex(sourceCode);
-		// replace blank spaces with proper regex
-		sourceCode = replaceWhitespaceWithRegex(sourceCode);
-		return sourceCode;
-	}
-
-	/**
-	 * Replace strings matching whitespace with proper regex
-	 *
-	 * @param code
-	 *            string with multiple blank spaces
-	 * @return string without multiple blank spaces
-	 */
-	protected String replaceWhitespaceWithRegex(String code) {
-		code = code.replaceAll(" ", ZERO_OR_MORE_BLANK_SPACE_REGEX);
-		return code;
-	}
-
-	/**
-	 * Replace reserved symbols in POSIX extended regular expression syntax  
with
-	 * proper regular expressions
-	 *
-	 * @param code
-	 *            string with symbols listed in RegexGenerator.regExpresions
-	 *            array
-	 * @return string with regular expressions
-	 */
-	protected String replaceNonLiteralWithProperRegex(String code) {
-		for (String regex : regExpresions) {
-			if (regex.equals(DOLLAR_SIGN)) {
-				// for some reason, String.replaceAll("\$", "anything") always
-				// breaks
-				code = code.replace("$", "\\$");
-			} else if (regex.equals(BACK_SLASH)) {
-				// bug-fix for code consist backslash
-				code = code.replace(BACK_SLASH, "\\\\");
-			} else {
-				code = code.replaceAll(regex, BACK_SLASH + regex);
-			}
-		}
-		return code;
-	}
-
-	/**
-	 * Add whitespace around non-literal
-	 * <p>
-	 * for example: "main(String[] args)" will be "main ( String [ ] args )"
-	 *
-	 * @param code
-	 *            string
-	 * @return string with whitespace added around non-literal
-	 */
-	protected String addWhitespaceAroundNonLiteral(String code) {
-		for (String regex : regExpresions) {
-			// in words beginning with
-			// "\" it should not be whitespace inserted after "\".
-			if (!regex.equals(BACK_SLASH)) {
-				code = code
-						.replaceAll(regex, BLANK_SPACE + regex + BLANK_SPACE);
-			}
-		}
-		code = code.replaceAll(ONE_OR_MORE_BLANK_SPACE, BLANK_SPACE);
-		return code.trim();
-	}
-}
+    // special signs in regex
+    protected final static String L_PARENTHESIS = "\\(";
+    protected final static String R_PARENTHESIS = "\\)";
+    protected final static String L_SQUARE_BRACKET = "\\[";
+    protected final static String R_SQUARE_BRACKET = "\\]";
+    protected final static String L_CURLY_BRACKET = "\\{";
+    protected final static String R_CURLY_BRACKET = "\\}";
+    protected final static String DOT = "\\.";
+    protected final static String QUESTION_MARK = "\\?";
+    protected final static String ASTERIX = "\\*";
+    protected final static String POWER = "\\^";
+    protected final static String DOLLAR_SIGN = "\\$";
+    protected final static String PLUS_SIGN = "\\+";
+    protected final static String MINUS_SIGN = "\\-";
+    protected final static String VERTICAL_LINE = "\\|";
+    protected final static String BACK_SLASH = "\\";
+    // non literals
+    protected final static String LES_THEN = "<";
+    protected final static String GREAT_THEN = ">";
+    protected final static String SEMICOLOMN = ";";
+    protected final static String COLON = ":";
+    protected final static String EQUALS = "=";
+    protected final static String SLASH = "/";
+    protected final static String DOUBLE_QUOTES = "\"";
+
+    // regex for matching
+    protected final static String ZERO_OR_MORE_BLANK_SPACE = "(\\s?)+";
+    protected final static String ONE_OR_MORE_BLANK_SPACE = "\\s+";
+    // protected final static String NOT_A_CHARACTER = "";
+
+    // other
+    protected final static String BLANK_SPACE = " ";
+
+    /**
+     * this regex is better then '\s* when it is used on GoogleCodeSearch
+     */
+    protected final static String ZERO_OR_MORE_BLANK_SPACE_REGEX  
= "(\\\\s?)+";
+
+    protected final static String[] regExpresions = { BACK_SLASH,  
L_PARENTHESIS, DOLLAR_SIGN, R_PARENTHESIS,
+            L_SQUARE_BRACKET, R_SQUARE_BRACKET, L_CURLY_BRACKET,  
R_CURLY_BRACKET, DOT, QUESTION_MARK, ASTERIX, POWER,
+            PLUS_SIGN, MINUS_SIGN, VERTICAL_LINE, LES_THEN, GREAT_THEN,  
SEMICOLOMN, COLON, EQUALS, SLASH, DOUBLE_QUOTES };
+
+    /**
+     * Returns regular expression of source code
+     *
+     * @param sourceCode code from which regex are generated
+     * @return regex generated from source code
+     */
+    public String stringToRegex(String sourceCode) {
+        // add whitespace before and after any non-character
+        sourceCode = addWhitespaceAroundNonLiteral(sourceCode);
+        // replace non literal with proper regex
+        sourceCode = replaceNonLiteralWithProperRegex(sourceCode);
+        // replace blank spaces with proper regex
+        sourceCode = replaceWhitespaceWithRegex(sourceCode);
+        return sourceCode;
+    }
+
+    /**
+     * Replace strings matching whitespace with proper regex
+     *
+     * @param code string with multiple blank spaces
+     * @return string without multiple blank spaces
+     */
+    protected String replaceWhitespaceWithRegex(String code) {
+        code = code.replaceAll(" ", ZERO_OR_MORE_BLANK_SPACE_REGEX);
+        return code;
+    }
+
+    /**
+     * Replace reserved symbols in POSIX extended regular expression  
syntax with
+     * proper regular expressions
+     *
+     * @param code string with symbols listed in  
RegexGenerator.regExpresions
+     *        array
+     * @return string with regular expressions
+     */
+    protected String replaceNonLiteralWithProperRegex(String code) {
+        for (String regex : regExpresions) {
+            if (regex.equals(DOLLAR_SIGN)) {
+                // for some reason, String.replaceAll("\$", "anything")  
always
+                // breaks
+                code = code.replace("$", "\\$");
+            } else if (regex.equals(BACK_SLASH)) {
+                // bug-fix for code consist backslash
+                code = code.replace(BACK_SLASH, "\\\\");
+            } else {
+                code = code.replaceAll(regex, BACK_SLASH + regex);
+            }
+        }
+        return code;
+    }
+
+    /**
+     * Add whitespace around non-literal
+     * <p>
+     * for example: "main(String[] args)" will be "main ( String [ ] args  
)"
+     *
+     * @param code string
+     * @return string with whitespace added around non-literal
+     */
+    protected String addWhitespaceAroundNonLiteral(String code) {
+        for (String regex : regExpresions) {
+            // in words beginning with
+            // "\" it should not be whitespace inserted after "\".
+            if (!regex.equals(BACK_SLASH)) {
+                code = code.replaceAll(regex, BLANK_SPACE + regex +  
BLANK_SPACE);
+            }
+        }
+        code = code.replaceAll(ONE_OR_MORE_BLANK_SPACE, BLANK_SPACE);
+        return code.trim();
+    }
+}
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/BruteForceHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/BruteForceHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -20,41 +20,41 @@
   */
  package org.apache.rat.pd.heuristic;

-
  /**
   * This is brute force heuristic checker. It always returns  
true-everything must
   * be checked.
   *
   * @author maka
- *
   */
  public class BruteForceHeuristicChecker implements IHeuristicChecker {

-	private final String language;
-	public BruteForceHeuristicChecker(String language){
-		this.language = language;
-	}
-
-	/*
-	 * If this Checker is used, it override all other heuristic checkers  
because
-	 * it always returns true.
-	 *
-	 * @see
-	 *  
org.apache.rat.pd.heuristic.IHeuristicChecker#checkByHeuristic(java.lang
-	 * .String)
-	 */
-	@Override
-	public HeuristicCheckerResult checkByHeuristic(String codeToBeChecked) {
-		return new HeuristicCheckerResult(true,
-				true, codeToBeChecked, this.getClass());
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.rat.pd.heuristic.IHeuristicChecker#getLanguage()
-	 */
-	@Override
-	public String getLanguage() {
-		return this.language;
-	}
+    private final String language;
+
+    public BruteForceHeuristicChecker(String language) {
+        this.language = language;
+    }
+
+    /*
+     * If this Checker is used, it override all other heuristic checkers  
because
+     * it always returns true.
+     *
+     * @see
+     *  
org.apache.rat.pd.heuristic.IHeuristicChecker#checkByHeuristic(java.lang
+     * .String)
+     */
+    @Override
+    public HeuristicCheckerResult checkByHeuristic(String codeToBeChecked)  
{
+        return new HeuristicCheckerResult(true, true, codeToBeChecked,  
this.getClass());
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.rat.pd.heuristic.IHeuristicChecker#getLanguage()
+     */
+    @Override
+    public String getLanguage() {
+        return this.language;
+    }

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/HeuristicCheckerResult.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/HeuristicCheckerResult.java	 
Fri Aug 21 06:53:09 2009
@@ -25,77 +25,73 @@
   * certain heuristic checker.
   *
   * @author maka
- *
   */
  public class HeuristicCheckerResult {

-	/**
-	 * This parameter will be set as true if check on Internet is needed.
-	 */
-	private final boolean checkOnInternetNeaded;
-
-	/**
-	 * This parameter give us the name of heuristic checker which recognize  
this
-	 * code.
-	 */
-	private final Class<? extends IHeuristicChecker> foundBy;
-
-	/**
-	 * This parameter gives informations to the algorithm if he can increase  
to
-	 * the right.
-	 */
-	private final boolean shouldStretch;
-
-	/**
-	 * This parameter marks recognized part of a code which should be checked  
on
-	 * search engines.
-	 */
-	private final String codeSugsestedTobeChecked;
-
-	/**
-	 * @param checkOnInternetNeaded
-	 *            information is search on on Internet needed
-	 * @param shouldStretch
-	 *            information for sliding algorithm to continue to stretch
-	 * @param codeSugestedToCheck
-	 *            code suggested for check by particular heuristic checker
-	 * @param foundBy
-	 *            name of heuristic checker found this code part
-	 */
-	public HeuristicCheckerResult(final boolean checkOnInternetNeaded,
-			final boolean shouldStretch, final String codeSugsestedToCheck,
-			final Class<? extends IHeuristicChecker> foundBy) {
-		this.checkOnInternetNeaded = checkOnInternetNeaded;
-		this.shouldStretch = shouldStretch;
-		this.codeSugsestedTobeChecked = codeSugsestedToCheck;
-		this.foundBy = foundBy;
-	}
-
-	/**
-	 * @return code suggested for check by particular heuristic checker
-	 */
-	public String getCodeSuggestedToBeChecked() {
-		return codeSugsestedTobeChecked;
-	}
-
-	/**
-	 * @return information for sliding algorithm to continue to stretch
-	 */
-	public boolean isShouldStretch() {
-		return shouldStretch;
-	}
-
-	/**
-	 * @return  name of heuristic checker found this code part
-	 */
-	public Class<? extends IHeuristicChecker> getFoundBy() {
-		return foundBy;
-	}
-
-	/**
-	 * @return  information is search on on Internet needed
-	 */
-	public boolean isCheckOnInternetNeaded() {
-		return checkOnInternetNeaded;
-	}
-}
+    /**
+     * This parameter will be set as true if check on Internet is needed.
+     */
+    private final boolean checkOnInternetNeaded;
+
+    /**
+     * This parameter give us the name of heuristic checker which  
recognize this
+     * code.
+     */
+    private final Class<? extends IHeuristicChecker> foundBy;
+
+    /**
+     * This parameter gives informations to the algorithm if he can  
increase to
+     * the right.
+     */
+    private final boolean shouldStretch;
+
+    /**
+     * This parameter marks recognized part of a code which should be  
checked on
+     * search engines.
+     */
+    private final String codeSugsestedTobeChecked;
+
+    /**
+     * @param checkOnInternetNeaded information is search on on Internet  
needed
+     * @param shouldStretch information for sliding algorithm to continue  
to
+     *        stretch
+     * @param codeSugestedToCheck code suggested for check by particular
+     *        heuristic checker
+     * @param foundBy name of heuristic checker found this code part
+     */
+    public HeuristicCheckerResult(final boolean checkOnInternetNeaded,  
final boolean shouldStretch,
+            final String codeSugsestedToCheck, final Class<? extends  
IHeuristicChecker> foundBy) {
+        this.checkOnInternetNeaded = checkOnInternetNeaded;
+        this.shouldStretch = shouldStretch;
+        this.codeSugsestedTobeChecked = codeSugsestedToCheck;
+        this.foundBy = foundBy;
+    }
+
+    /**
+     * @return code suggested for check by particular heuristic checker
+     */
+    public String getCodeSuggestedToBeChecked() {
+        return codeSugsestedTobeChecked;
+    }
+
+    /**
+     * @return information for sliding algorithm to continue to stretch
+     */
+    public boolean isShouldStretch() {
+        return shouldStretch;
+    }
+
+    /**
+     * @return name of heuristic checker found this code part
+     */
+    public Class<? extends IHeuristicChecker> getFoundBy() {
+        return foundBy;
+    }
+
+    /**
+     * @return information is search on on Internet needed
+     */
+    public boolean isCheckOnInternetNeaded() {
+        return checkOnInternetNeaded;
+    }
+}
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/heuristic/IHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++ /trunk/src/main/java/org/apache/rat/pd/heuristic/IHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -20,30 +20,32 @@
   */
  package org.apache.rat.pd.heuristic;

-
  /**
   * All heuristic for good-to-be-copied code will implements this
   *
   * @author: maka
   */
  public interface IHeuristicChecker {
-
-	/**
-	 * if language is not important we use this constant
-	 */
-	static final String ALL_LANGUAGES = "ALL_LANGUAGES";
-	/**
-	 * This method knows is codeToBeChecked part of good-to-be-copied code. If
-	 * it is, method will return true in checkOnInternetNeaded property of  
HeuristicCheckerResult.
-	 *
-	 * @param codeToBeChecked possible good-to-be-copied code
-	 * @return HeuristicCheckerResult information generated for sliding  
window algorithm
-	 */
-	HeuristicCheckerResult checkByHeuristic(String codeToBeChecked);
-
-	/**
-	 * @return name of programming language
-	 */
-	String getLanguage();
+
+    /**
+     * if language is not important we use this constant
+     */
+    static final String ALL_LANGUAGES = "ALL_LANGUAGES";
+
+    /**
+     * This method knows is codeToBeChecked part of good-to-be-copied  
code. If
+     * it is, method will return true in checkOnInternetNeaded property of
+     * HeuristicCheckerResult.
+     *
+     * @param codeToBeChecked possible good-to-be-copied code
+     * @return HeuristicCheckerResult information generated for sliding  
window
+     *         algorithm
+     */
+    HeuristicCheckerResult checkByHeuristic(String codeToBeChecked);
+
+    /**
+     * @return name of programming language
+     */
+    String getLanguage();

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ActionScriptCommentHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ActionScriptCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -26,29 +26,26 @@
   *There are two types of comments in ActionScript. First one starts with  
// and
   * ends with a end of a line. More info on:
   *  
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/
- * actionscript_dictionary023.html
- *
- * Second one starts with / * and ends with * / . more info on:
+ * actionscript_dictionary023.html Second one starts with / * and ends  
with * /
+ * . more info on:
   *  
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/
   * actionscript_dictionary023.html
   *
   * @author maka
- *
   */
-public class ActionScriptCommentHeuristicChecker extends
-		CommentHeuristicChecker {
-
-	/**
-	 * This regular expression match comments in ActionScript.
-	 */
-	private static final String ACTION_SCRIPT_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public ActionScriptCommentHeuristicChecker(int limit, PrintStream out) {
-		super(ACTION_SCRIPT_COMMENT_REGEX, limit, "actionscript", out);
-	}
+public class ActionScriptCommentHeuristicChecker extends  
CommentHeuristicChecker {
+
+    /**
+     * This regular expression match comments in ActionScript.
+     */
+    private static final String ACTION_SCRIPT_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -23,29 +23,27 @@
  import java.io.PrintStream;

  /**
- *
   * There is only one type of comments in C. C uses comments that starts  
with /*
   * and ends with * /. More info on:
   * http://www.psgd.org/paul/docs/cstyle/cstyle03.htm
   *
   * @author maka
- *
   */
  public class CCommentHeuristicChecker extends CommentHeuristicChecker {

-	/**
-	 * This regular expression match comments in C. More info on: {@link}
-	 * http://ostermiller.org/findcomment.html
-	 *
-	 */
-	private static final String C_COMMENT_REGEX  
= "/\\*[\\s\\S]*\\*+/[\\n\\r]*";
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public CCommentHeuristicChecker(int limit, PrintStream out) {
-		super(C_COMMENT_REGEX, limit, "c", out);
-
-	}
+    /**
+     * This regular expression match comments in C. More info on: {@link}
+     * http://ostermiller.org/findcomment.html
+     */
+    private static final String C_COMMENT_REGEX  
= "/\\*[\\s\\S]*\\*+/[\\n\\r]*";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CPPCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -32,18 +32,18 @@
   * @author maka
   */
  public class CPPCommentHeuristicChecker extends CommentHeuristicChecker {
-	/**
-	 * This regular expression match comments in C++. More info on:{@link}
-	 * http://ostermiller.org/findcomment.html
-	 */
-	private static final String CPP_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public CPPCommentHeuristicChecker(int limit, PrintStream out) {
-		super(CPP_COMMENT_REGEX, limit, "c++", out);
-	}
+    /**
+     * This regular expression match comments in C++. More info on:{@link}
+     * http://ostermiller.org/findcomment.html
+     */
+    private static final String CPP_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CSharpCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -31,18 +31,18 @@
   */
  public class CSharpCommentHeuristicChecker extends CommentHeuristicChecker  
{

-	/**
-	 * This regular expression match comments in C#. More info on: {@link}
-	 * http://ostermiller.org/findcomment.html
-	 */
-	private static final String C_SHARP_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public CSharpCommentHeuristicChecker(int limit, PrintStream out) {
-		super(C_SHARP_COMMENT_REGEX, limit, "c#", out);
-	}
+    /**
+     * This regular expression match comments in C#. More info on: {@link}
+     * http://ostermiller.org/findcomment.html
+     */
+    private static final String C_SHARP_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CobolCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -30,22 +30,21 @@
   * http://www.csis.ul.ie/cobol/Course/COBOLIntro.htm
   *
   * @author maka
- *
   */
  public class CobolCommentHeuristicChecker extends CommentHeuristicChecker {

-	/**
-	 * This regular expression match comments in Cobol.
-	 */
-	private static final String COBOL_COMMENT_REGEX = "^\\d{6}\\*.*[\\n\\r]";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public CobolCommentHeuristicChecker(int limit, PrintStream out) {
-		super(COBOL_COMMENT_REGEX, limit, "cobol", out);
-
-	}
+    /**
+     * This regular expression match comments in Cobol.
+     */
+    private static final String COBOL_COMMENT_REGEX  
= "^\\d{6}\\*.*[\\n\\r]";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ColdFusionCommentsheuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -30,22 +30,21 @@
   * .htm?context=ColdFusion_Documentation&file=00000868.htm
   *
   * @author maka
- *
   */
  public class ColdFusionCommentsheuristicChecker extends  
CommentHeuristicChecker {
-
-	/**
-	 * This regular expression match comments in ColdFusion.
-	 */
-	private static final String COLD_FUSION_COMMENT_REGEX = "<![  
\\r\\n\\t]*(---([^\\-]|[\\r\\n]|-[^\\-])*---[ \\r\\n\\t]*)>";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public ColdFusionCommentsheuristicChecker(int limit, PrintStream out) {
-		super(COLD_FUSION_COMMENT_REGEX, limit, "coldfusion", out);
-
-	}
+
+    /**
+     * This regular expression match comments in ColdFusion.
+     */
+    private static final String COLD_FUSION_COMMENT_REGEX = "<![  
\\r\\n\\t]*(---([^\\-]|[\\r\\n]|-[^\\-])*---[ \\r\\n\\t]*)>";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/CommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -31,63 +31,62 @@
   * This is base class for all comment heuristic checkers.
   *
   * @author maka
- *
   */
  public class CommentHeuristicChecker implements IHeuristicChecker {

-	protected final String COMMENT_REGEX;
-	private final int limit;
-	private final String language;
-	private final PrintStream out;
-
-	/**
-	 * @param regex regular expression to match comment in current language
-	 * @param limit minimal length of comment which will be considered
-	 * @param language programming language
-	 * @param out print stream for logging purposes
-	 */
-	public CommentHeuristicChecker(String regex, int limit, String language,  
PrintStream out) {
-		this.COMMENT_REGEX = regex;
-		this.limit = limit;
-		this.language = language;
-		this.out = out;
-	}
-
-	/**
-	 * Method will return false if there are some characters before comment or
-	 * after comment. Depends on limit property, function can return false if
-	 * matched comment length is smaller then limit value.
-	 *
-	 * @param codeToBeChecked
-	 * @return true if this is comment.
-	 */
-	@Override
-	public HeuristicCheckerResult checkByHeuristic(String codeToBeChecked) {
-		HeuristicCheckerResult toret = new HeuristicCheckerResult(false,
-				true, codeToBeChecked, this.getClass());
-
-		// Create a pattern to match comments
-		Pattern p = Pattern.compile(COMMENT_REGEX, Pattern.MULTILINE);
-		// Run matches
-		Matcher m = p.matcher(codeToBeChecked);
-		// there must be no characters after comment
-		if (m.find()) {
-			String found = m.group();
-			if (codeToBeChecked.endsWith(found)) {
-				out.println("Found comment: " + found);
-				boolean isSearchNeaded = found.length() > limit ? true : false;
-				toret = new HeuristicCheckerResult(isSearchNeaded,
-						false, found, this.getClass());
-			}
-		}
-		return toret;
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.rat.pd.heuristic.IHeuristicChecker#getLanguage()
-	 */
-	@Override
-	public String getLanguage() {
-		return this.language;
-	}
-}
+    protected final String COMMENT_REGEX;
+    private final int limit;
+    private final String language;
+    private final PrintStream out;
+
+    /**
+     * @param regex regular expression to match comment in current language
+     * @param limit minimal length of comment which will be considered
+     * @param language programming language
+     * @param out print stream for logging purposes
+     */
+    public CommentHeuristicChecker(String regex, int limit, String  
language, PrintStream out) {
+        this.COMMENT_REGEX = regex;
+        this.limit = limit;
+        this.language = language;
+        this.out = out;
+    }
+
+    /**
+     * Method will return false if there are some characters before  
comment or
+     * after comment. Depends on limit property, function can return false  
if
+     * matched comment length is smaller then limit value.
+     *
+     * @param codeToBeChecked
+     * @return true if this is comment.
+     */
+    @Override
+    public HeuristicCheckerResult checkByHeuristic(String codeToBeChecked)  
{
+        HeuristicCheckerResult toret = new HeuristicCheckerResult(false,  
true, codeToBeChecked, this.getClass());
+
+        // Create a pattern to match comments
+        Pattern p = Pattern.compile(COMMENT_REGEX, Pattern.MULTILINE);
+        // Run matches
+        Matcher m = p.matcher(codeToBeChecked);
+        // there must be no characters after comment
+        if (m.find()) {
+            String found = m.group();
+            if (codeToBeChecked.endsWith(found)) {
+                out.println("Found comment: " + found);
+                boolean isSearchNeaded = found.length() > limit ? true :  
false;
+                toret = new HeuristicCheckerResult(isSearchNeaded, false,  
found, this.getClass());
+            }
+        }
+        return toret;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.rat.pd.heuristic.IHeuristicChecker#getLanguage()
+     */
+    @Override
+    public String getLanguage() {
+        return this.language;
+    }
+}
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/DelphiCommentHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/DelphiCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -30,21 +30,20 @@
   * http://delphi.about.com/od/beginners/l/aa101502a.htm
   *
   * @author maka
- *
   */
  public class DelphiCommentHeuristicChecker extends CommentHeuristicChecker  
{

-	/**
-	 * This regular expression match comments in Delphi.
-	 */
-	private static final String DELPHI_COMMENT_REGEX  
= "(\\{[\\s\\S]*\\}[\\n\\r]*)|(\\(\\*[\\s\\S]*\\*\\))|(//.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public DelphiCommentHeuristicChecker(int limit, PrintStream out) {
-		super(DELPHI_COMMENT_REGEX, limit, "pascal", out);
-	}
+    /**
+     * This regular expression match comments in Delphi.
+     */
+    private static final String DELPHI_COMMENT_REGEX  
= "(\\{[\\s\\S]*\\}[\\n\\r]*)|(\\(\\*[\\s\\S]*\\*\\))|(//.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/FortranCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -28,21 +28,20 @@
   * http://folk.uio.no/steikr/doc/f77/tutorial/basics.html
   *
   * @author maka
- *
   */
  public class FortranCommentHeuristicChecker extends  
CommentHeuristicChecker {

-	/**
-	 * This regular expression match comments in Fortran.
-	 */
-	private static final String FORTRAN_COMMENT_REGEX = "(!.*[\\n\\r])| 
(^C .*[\\n\\r])|(^c .*[\\n\\r])|(^\\* .*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public FortranCommentHeuristicChecker(int limit, PrintStream out) {
-		super(FORTRAN_COMMENT_REGEX, limit, "fortran", out);
-	}
+    /**
+     * This regular expression match comments in Fortran.
+     */
+    private static final String FORTRAN_COMMENT_REGEX = "(!.*[\\n\\r])| 
(^C .*[\\n\\r])|(^c .*[\\n\\r])|(^\\* .*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/HTMLCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -35,19 +35,19 @@
   */
  public class HTMLCommentHeuristicChecker extends CommentHeuristicChecker {

-	/**
-	 * This regular expression match comments in HTML allowing zero or more
-	 * comments in comment declaration. More info about regular expression to
-	 * match comments on: http://ostermiller.org/findhtmlcomment.html
-	 */
-	private static final String HTML_COMMENT_REGEX = "(<!((--([^\\-]|[\\r\\n]| 
-[^\\-])*--(\\s)*))*>)";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public HTMLCommentHeuristicChecker(int limit, PrintStream out) {
-		super(HTML_COMMENT_REGEX, limit, IHeuristicChecker.ALL_LANGUAGES, out);
-	}
+    /**
+     * This regular expression match comments in HTML allowing zero or more
+     * comments in comment declaration. More info about regular expression  
to
+     * match comments on: http://ostermiller.org/findhtmlcomment.html
+     */
+    private static final String HTML_COMMENT_REGEX = "(<!((--([^\\-]| 
[\\r\\n]|-[^\\-])*--(\\s)*))*>)";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/JavaCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -31,18 +31,18 @@
   */
  public class JavaCommentHeuristicChecker extends CommentHeuristicChecker {

-	/**
-	 * This regular expression match comments in Java.
-	 */
-	private static final String JAVA_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public JavaCommentHeuristicChecker(int limit, PrintStream out) {
-		super(JAVA_COMMENT_REGEX, limit, "java", out);
-
-	}
+    /**
+     * This regular expression match comments in Java.
+     */
+    private static final String JAVA_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/JavaScriptCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -31,17 +31,17 @@
   */
  public class JavaScriptCommentHeuristicChecker extends  
CommentHeuristicChecker {

-	/**
-	 * This regular expression match comments in JavaScript.
-	 */
-	private static final String JAVA_SCRIPT_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public JavaScriptCommentHeuristicChecker(int limit, PrintStream out) {
-		super(JAVA_SCRIPT_COMMENT_REGEX, limit, "javascript", out);
-	}
+    /**
+     * This regular expression match comments in JavaScript.
+     */
+    private static final String JAVA_SCRIPT_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/LispCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -30,19 +30,18 @@
   * /style/com_mechanics.html
   *
   * @author maka
- *
   */
  public class LispCommentHeuristicChecker extends CommentHeuristicChecker {
-	/**
-	 * This regular expression matches comments in Lisp.
-	 */
-	private static final String LISP_COMMENT_REGEX = "(#\\|[\\s\\S]*\\|#)| 
(;.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public LispCommentHeuristicChecker(int limit, PrintStream out) {
-		super(LISP_COMMENT_REGEX, limit, "lisp", out);
-	}
-}
+    /**
+     * This regular expression matches comments in Lisp.
+     */
+    private static final String LISP_COMMENT_REGEX = "(#\\|[\\s\\S]*\\|#)| 
(;.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PHPCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -30,21 +30,20 @@
   * about that can be found here: http://www.tizag.com/phpT/comment.php
   *
   * @author maka
- *
   */
  public class PHPCommentHeuristicChecker extends CommentHeuristicChecker {

-	/**
-	 * This regular expression match comments in PHP.
-	 */
-	private static final String PHP_COMMENT_REGEX = "(#.*[\\n\\r])| 
(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public PHPCommentHeuristicChecker(int limit, PrintStream out) {
-		super(PHP_COMMENT_REGEX, limit, "php", out);
-	}
+    /**
+     * This regular expression match comments in PHP.
+     */
+    private static final String PHP_COMMENT_REGEX = "(#.*[\\n\\r])| 
(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(//.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PascalCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -33,18 +33,18 @@
   */
  public class PascalCommentHeuristicChecker extends CommentHeuristicChecker  
{

-	/**
-	 * This regular expression match comments in Pascal. More info on:{@link}
-	 * http://search.cpan.org/~abigail/Regexp-Common-2.122/lib/Regexp/Common/
-	 * comment.pm
-	 */
-	private static final String PASCAL_COMMENT_REGEX = "(\\{.*\\})| 
(\\{.*\\*\\))|(\\(\\*.*\\*\\))|(\\(\\*.*\\})";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public PascalCommentHeuristicChecker(int limit, PrintStream out) {
-		super(PASCAL_COMMENT_REGEX, limit, "pascal", out);
-	}
-}
+    /**
+     * This regular expression match comments in Pascal. More info  
on:{@link}
+     *  
http://search.cpan.org/~abigail/Regexp-Common-2.122/lib/Regexp/Common/
+     * comment.pm
+     */
+    private static final String PASCAL_COMMENT_REGEX = "(\\{.*\\})| 
(\\{.*\\*\\))|(\\(\\*.*\\*\\))|(\\(\\*.*\\})";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PerlCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -32,19 +32,19 @@

  public class PerlCommentHeuristicChecker extends CommentHeuristicChecker {

-	/**
-	 * This regular expression match comments in Perl. More info on:{@link}
-	 * http://search.cpan.org/~abigail/Regexp-Common-2.122/lib/Regexp/Common/
-	 * comment.pm
-	 */
-	private static final String PERL_COMMENT_REGEX = "(#.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public PerlCommentHeuristicChecker(int limit, PrintStream out) {
-		super(PERL_COMMENT_REGEX, limit, "perl", out);
-	}
+    /**
+     * This regular expression match comments in Perl. More info on:{@link}
+     *  
http://search.cpan.org/~abigail/Regexp-Common-2.122/lib/Regexp/Common/
+     * comment.pm
+     */
+    private static final String PERL_COMMENT_REGEX = "(#.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/PythonCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -32,17 +32,17 @@
   */
  public class PythonCommentHeuristicChecker extends CommentHeuristicChecker  
{

-	/**
-	 * This regular expression match comments in Python.
-	 */
-	private static final String PYTHON_COMMENT_REGEX = "(#.*[\\n\\r])| 
(\"\"\"[\\s\\S]*\"\"\")";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public PythonCommentHeuristicChecker(int limit, PrintStream out) {
-		super(PYTHON_COMMENT_REGEX, limit, "python", out);
-	}
+    /**
+     * This regular expression match comments in Python.
+     */
+    private static final String PYTHON_COMMENT_REGEX = "(#.*[\\n\\r])| 
(\"\"\"[\\s\\S]*\"\"\")";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/RubyCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -30,19 +30,19 @@
   */
  public class RubyCommentHeuristicChecker extends CommentHeuristicChecker {

-	/**
-	 * This regular expression match comments in Ruby. More info on:{@link}
-	 * http://search.cpan.org/~abigail/Regexp-Common-2.122/lib/Regexp/Common/
-	 * comment.pm
-	 */
-	private static final String RUBY_COMMENT_REGEX = "(#.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public RubyCommentHeuristicChecker(int limit, PrintStream out) {
-		super(RUBY_COMMENT_REGEX, limit, "ruby", out);
-	}
+    /**
+     * This regular expression match comments in Ruby. More info on:{@link}
+     *  
http://search.cpan.org/~abigail/Regexp-Common-2.122/lib/Regexp/Common/
+     * comment.pm
+     */
+    private static final String RUBY_COMMENT_REGEX = "(#.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/SQLCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -28,20 +28,19 @@
   * com/pubs/html/as400/v4r5/ic2924/index.htm?info/db2/rbafzmst67.htm
   *
   * @author maka
- *
   */
  public class SQLCommentHeuristicChecker extends CommentHeuristicChecker {
-	/**
-	 * This regular expression match comments in SQL.
-	 */
-	private static final String SQL_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(--.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public SQLCommentHeuristicChecker(int limit, PrintStream out) {
-		super(SQL_COMMENT_REGEX, limit, "sql", out);
-	}
+    /**
+     * This regular expression match comments in SQL.
+     */
+    private static final String SQL_COMMENT_REGEX  
= "(/\\*[\\s\\S]*\\*+/[\\n\\r]*)|(--.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/ShellCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -30,18 +30,18 @@
   */
  public class ShellCommentHeuristicChecker extends CommentHeuristicChecker {

-	/**
-	 * This regular expression match comments in Shell. More info on:{@link}
-	 * http://search.cpan.org/~abigail/Regexp-Common-2.122/lib/Regexp/Common/
-	 * comment.pm
-	 */
-	private static final String SHELL_COMMENT_REGEX = "(#.*[\\n\\r])";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public ShellCommentHeuristicChecker(int limit, PrintStream out) {
-		super(SHELL_COMMENT_REGEX, limit, "shell", out);
-	}
-}
+    /**
+     * This regular expression match comments in Shell. More info  
on:{@link}
+     *  
http://search.cpan.org/~abigail/Regexp-Common-2.122/lib/Regexp/Common/
+     * comment.pm
+     */
+    private static final String SHELL_COMMENT_REGEX = "(#.*[\\n\\r])";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/comment/VisualBasicCommentHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -30,20 +30,18 @@
   * http://www.aivosto.com/vbtips/codedoc.html
   *
   * @author maka
- *
   */
  public class VisualBasicCommentHeuristicChecker extends  
CommentHeuristicChecker {
-	/**
-	 * This regular expression match comments in VisualBasic.
-	 */
-	private static final String VISUAL_BASIC_COMMENT_REGEX  
= "(\\s*\\'.*[\\n\\r])+";
-
-	/**
-	 * @param limit minimal length of comment which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public VisualBasicCommentHeuristicChecker(int limit, PrintStream out) {
-		super(VISUAL_BASIC_COMMENT_REGEX, limit,
-				IHeuristicChecker.ALL_LANGUAGES, out);
-	}
-}
+    /**
+     * This regular expression match comments in VisualBasic.
+     */
+    private static final String VISUAL_BASIC_COMMENT_REGEX  
= "(\\s*\\'.*[\\n\\r])+";
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/ActionScriptFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -26,36 +26,32 @@
   * Functions in ActionScript can exist in two ways: <li>function
   * functionName(listOfParameters){function body} <li>function
   * functionName(listOfParameters):returnType {function body}
- *
   * <p>
   * More info on {@link} http://en.wikipedia.org/wiki/ActionScript
   *
   * @author maka
- *
   */
-public class ActionScriptFunctionHeuristicChecker extends
-		FunctionHeuristicChecker {
-
-	private static final String ACTION_SCRIPT_OPENED_BRACKET = "\\{";
-	private static final String ACTION_SCRIPT_CLOSED_BRACKET = "\\}";
-
-	/**
-	 * Functions in ActionScript can exist in two ways: <li>function
-	 * functionName(listOfParameters){function body} <li>function
-	 * functionName(listOfParameters):returnType {function body}
-	 *
-	 * <p>
-	 * More info on {@link} http://en.wikipedia.org/wiki/ActionScript
-	 */
-	private static final String ACTION_SCRIPT_FUNCTION_REGEX = "function  
+\\w+ *\\([^()]*?\\)(( *\\: *\\w+)){0,1}\\s*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * @param limit minimal length of function which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public ActionScriptFunctionHeuristicChecker(int limit, PrintStream out) {
-		super(limit, ACTION_SCRIPT_FUNCTION_REGEX,
-				ACTION_SCRIPT_OPENED_BRACKET,  
ACTION_SCRIPT_CLOSED_BRACKET, "actionscript", out);
-	}
+public class ActionScriptFunctionHeuristicChecker extends  
FunctionHeuristicChecker {
+
+    private static final String ACTION_SCRIPT_OPENED_BRACKET = "\\{";
+    private static final String ACTION_SCRIPT_CLOSED_BRACKET = "\\}";
+
+    /**
+     * Functions in ActionScript can exist in two ways: <li>function
+     * functionName(listOfParameters){function body} <li>function
+     * functionName(listOfParameters):returnType {function body}
+     * <p>
+     * More info on {@link} http://en.wikipedia.org/wiki/ActionScript
+     */
+    private static final String ACTION_SCRIPT_FUNCTION_REGEX = "function  
+\\w+ *\\([^()]*?\\)(( *\\: *\\w+)){0,1}\\s*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * @param limit minimal length of function which will be considered
+     * @param out print stream for logging purposes
+     */
+    public ActionScriptFunctionHeuristicChecker(int limit, PrintStream  
out) {
+        super(limit, ACTION_SCRIPT_FUNCTION_REGEX,  
ACTION_SCRIPT_OPENED_BRACKET, ACTION_SCRIPT_CLOSED_BRACKET,
+                "actionscript", out);
+    }

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CFunctionHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -25,99 +25,95 @@
  /**
   * Function in C consists of function definition and function body. There  
are
   * special constructions called "inline functions" and "macro functions"  
too.
- *
   * More info on:
   * <p>
   * <li>{@link} http://www2.its.strath.ac.uk/courses/c/
   * <li>{@link}http://www.greenend.org.uk/rjk/2003/03/inline.html
   *
   * @author maka
- *
   */
  public class CFunctionHeuristicChecker extends FunctionHeuristicChecker {

-	private static final String OR_REGEX = "|";
-	private static final String C_OPENED_BRACKET = "\\{";
-	private static final String C_CLOSED_BRACKET = "\\}";
-
-	/**
-	 * Function in C consists of function definition and function body.
-	 *
-	 * More info on:
-	 * <p>
-	 * <li>{@link} http://www2.its.strath.ac.uk/courses/c/ <li>{@link}
-	 * http://www.greenend.org.uk/rjk/2003/03/inline.html
-	 */
-	private static final String C_FUNCTION_REGEX = "\\w+\\s+[*&]?\\s*\\w+  
*\\([^()]*?\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * This regular expression match macro in C which are multilines. For
-	 * example: #define SWAP(a, b) {
-	 * <p>
-	 * a ^= b;
-	 * <p>
-	 * b ^= a;
-	 * <p>
-	 * a ^= b; }
-	 */
-	private static final String C_MACRO_REGEX_1 = "#define +\\w+  
*\\([\\s\\S]*\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * This regular expression match macro in C which are one-line. For  
example:
-	 * <p>
-	 * #define INCREMENT(x) x++
-	 */
-	private static final String C_MACRO_REGEX_2 = "#define +\\w+  
*\\([\\s\\S]*\\).*[\\n\\r]";
-
-	/**
-	 * This regular expression match macro in C which are multiline but have  
no
-	 * parameters. For example:
-	 * <p>
-	 * #define UPDBITS {s->bitb=b;s->bitk=k;}
-	 */
-	private static final String C_MACRO_REGEX_3 = "#define  
+\\w+(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * This regular expression match macros in C. More info on: {@link }
-	 * http://www.cprogramming.com/tutorial/cpreprocessor.html
-	 */
-	private static final String C_MACRO_REGEX = "(" + C_MACRO_REGEX_1 + ")"
-			+ OR_REGEX + "(" + C_MACRO_REGEX_2 + ")" + OR_REGEX + "("
-			+ C_MACRO_REGEX_3 + ")";
-
-	/**
-	 * This regular expression match inline functions in C which are multiline
-	 * and have parametrs. For example:
-	 * <p>
-	 * inline void Recycle( char* aBuffer) { nsMemory::Free(aBuffer); }
-	 */
-
-	private static final String C_INLINE_FUNCTION_1  
= "inline(\\s)*\\w+(\\s*)(.*)\\([^()]*?\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-	/**
-	 * This regular expression match inline functions in C which have no
-	 * parametrs.
-	 */
-	private static final String C_INLINE_FUNCTION_2  
= "inline(\\s)*\\w+(\\s*)(.*)\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * This regular expression match inline functions in C. More info on :
-	 * {@link} http://www.cprogramming.com/tutorial/lesson13.html
-	 */
-	private static final String C_INLINE_FUNCTION = "(" + C_INLINE_FUNCTION_1
-			+ ")" + OR_REGEX + "(" + C_INLINE_FUNCTION_2 + ")";
-
-	/**
-	 * This regular expression match functions,inline functions and macros in  
C,
-	 */
-	private static final String FUNCTION_REGEX = "(" + C_FUNCTION_REGEX + ")"
-			+ OR_REGEX + C_MACRO_REGEX + OR_REGEX + C_INLINE_FUNCTION;
-
-	/**
-	 * @param limit minimal length of function which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public CFunctionHeuristicChecker(int limit, PrintStream out) {
-		super(limit, FUNCTION_REGEX, C_OPENED_BRACKET, C_CLOSED_BRACKET, "c",  
out);
-	}
+    private static final String OR_REGEX = "|";
+    private static final String C_OPENED_BRACKET = "\\{";
+    private static final String C_CLOSED_BRACKET = "\\}";
+
+    /**
+     * Function in C consists of function definition and function body.  
More
+     * info on:
+     * <p>
+     * <li>{@link} http://www2.its.strath.ac.uk/courses/c/ <li>{@link}
+     * http://www.greenend.org.uk/rjk/2003/03/inline.html
+     */
+    private static final String C_FUNCTION_REGEX = "\\w+\\s+[*&]?\\s*\\w+  
*\\([^()]*?\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * This regular expression match macro in C which are multilines. For
+     * example: #define SWAP(a, b) {
+     * <p>
+     * a ^= b;
+     * <p>
+     * b ^= a;
+     * <p>
+     * a ^= b; }
+     */
+    private static final String C_MACRO_REGEX_1 = "#define +\\w+  
*\\([\\s\\S]*\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * This regular expression match macro in C which are one-line. For  
example:
+     * <p>
+     * #define INCREMENT(x) x++
+     */
+    private static final String C_MACRO_REGEX_2 = "#define +\\w+  
*\\([\\s\\S]*\\).*[\\n\\r]";
+
+    /**
+     * This regular expression match macro in C which are multiline but  
have no
+     * parameters. For example:
+     * <p>
+     * #define UPDBITS {s->bitb=b;s->bitk=k;}
+     */
+    private static final String C_MACRO_REGEX_3 = "#define  
+\\w+(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * This regular expression match macros in C. More info on: {@link }
+     * http://www.cprogramming.com/tutorial/cpreprocessor.html
+     */
+    private static final String C_MACRO_REGEX = "(" + C_MACRO_REGEX_1  
+ ")" + OR_REGEX + "(" + C_MACRO_REGEX_2 + ")"
+            + OR_REGEX + "(" + C_MACRO_REGEX_3 + ")";
+
+    /**
+     * This regular expression match inline functions in C which are  
multiline
+     * and have parametrs. For example:
+     * <p>
+     * inline void Recycle( char* aBuffer) { nsMemory::Free(aBuffer); }
+     */
+
+    private static final String C_INLINE_FUNCTION_1  
= "inline(\\s)*\\w+(\\s*)(.*)\\([^()]*?\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
+    /**
+     * This regular expression match inline functions in C which have no
+     * parametrs.
+     */
+    private static final String C_INLINE_FUNCTION_2  
= "inline(\\s)*\\w+(\\s*)(.*)\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * This regular expression match inline functions in C. More info on :
+     * {@link} http://www.cprogramming.com/tutorial/lesson13.html
+     */
+    private static final String C_INLINE_FUNCTION = "(" +  
C_INLINE_FUNCTION_1 + ")" + OR_REGEX + "("
+            + C_INLINE_FUNCTION_2 + ")";
+
+    /**
+     * This regular expression match functions,inline functions and macros  
in C,
+     */
+    private static final String FUNCTION_REGEX = "(" + C_FUNCTION_REGEX  
+ ")" + OR_REGEX + C_MACRO_REGEX + OR_REGEX
+            + C_INLINE_FUNCTION;
+
+    /**
+     * @param limit minimal length of function which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Mon Aug 17 10:13:50 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CPPFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -27,109 +27,103 @@
   * special constructions called "inline functions" and "macro  
functions"too.
   *
   *@author maka
- *
   */
  public class CPPFunctionHeuristicChecker extends FunctionHeuristicChecker {

-	private static final String OR_REGEX = "|";
-	private static final String CPP_CLOSED_BRACKET = "\\}";
-	private static final String CPP_OPENED_BRACKET = "\\{";
-
-	/**
-	 * This regular expression match functions in C++.
-	 */
-	private static final String CPP_FUNCTION_REGEX_1 = "\\w+\\s+[*&]?\\s*\\w+  
*\\([^()]*?\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * This regular expression match functions in C++ which have mark "::".  
For
-	 * example:
-	 * <p>
-	 * MyType MyType::Add(const MyType & rhs) { return MyType(itsVal+
-	 * rhs.GetItsVal()); }
-	 */
-	private static final String CPP_FUNCTION_REGEX_2 = "^[\t ]*[\\w+  
\\*&]+\\s*\\:\\:\\s*[*&~]?\\s*\\w+ *\\([^()]*?\\)( *const  
*)?(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-	// TODO add regular expression which will match functions with a reference
-	// to a string as a returning type for example.
-	private static final String CPP_FUNCTION_REGEX = "(" +  
CPP_FUNCTION_REGEX_1
-			+ ")|(" + CPP_FUNCTION_REGEX_2 + ")";
-
-	/**
-	 * This regular expression match macros in C++ which are multilines. For
-	 * example: #define SWAP(a, b) {
-	 * <p>
-	 * a ^= b;
-	 * <p>
-	 * b ^= a;
-	 * <p>
-	 * a ^= b; }
-	 */
-	private static final String CPP_MACRO_REGEX_1 = "#define +\\w+  
*\\([\\s\\S]*\\)\\s*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * This regular expression match macro in C++ which are one-line. For
-	 * example:
-	 * <p>
-	 * #define INCREMENT(x) x++
-	 */
-	private static final String CPP_MACRO_REGEX_2 = "#define +\\w+  
*\\([\\s\\S]*\\)*.*[\\n\\r]";
-
-	/**
-	 * This regular expression match macros in C++.
-	 */
-	private static final String CPP_MACRO_REGEX = "(" + CPP_MACRO_REGEX_1  
+ ")"
-			+ OR_REGEX + "(" + CPP_MACRO_REGEX_2 + ")";
-
-	/**
-	 * This regular expression match inline functions in C++ which are  
multiline
-	 * and have parametrs. For example: inline void Recycle( char* aBuffer) {
-	 * nsMemory::Free(aBuffer); }
-	 */
-	private static final String CPP_INLINE_FUNCTION_1  
= "inline\\s+\\w+\\s+(.*)\\([^()]*\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * This regular expression match inline functions in C++ which have no
-	 * parametrs.
-	 */
-	private static final String CPP_INLINE_FUNCTION_2 = "inline  
+\\w+(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * This regular expression matches inline functions in C++ which contains
-	 * mark "::". For example:inline size_t SearchResultMessageArg::nTried() {
-	 * return filename_.size(); }
-	 *
-	 */
-	private static final String CPP_INLINE_FUNCTION_3  
= "inline\\s+\\w+\\s+\\w+\\:\\:\\w+\\s*\\([^()]*\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * This regular expression matches inline functions in C++ which contains
-	 * mark "::" and,after parameters, key word const. For example: inline
-	 * size_t SearchResultMessageArg::nTried() const{ return  
filename_.size();}
-	 */
-	private static final String CPP_INLINE_FUNCTION_4  
= "inline\\s+\\w+\\s+\\w+\\:\\:\\w+\\s*\\([^()]*\\)  
*const(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * This regular expression match inline functions in C++.
-	 */
-	private static final String CPP_INLINE_FUNCTION = "("
-			+ CPP_INLINE_FUNCTION_1 + ")" + OR_REGEX + "("
-			+ CPP_INLINE_FUNCTION_2 + ")" + OR_REGEX + "("
-			+ CPP_INLINE_FUNCTION_3 + ")" + OR_REGEX + "("
-			+ CPP_INLINE_FUNCTION_4 + ")";
-
-	/**
-	 * This regular expression match functions,inline functions and macros in
-	 * C++,
-	 */
-	private static final String FUNCTION_REGEX = CPP_FUNCTION_REGEX + OR_REGEX
-			+ CPP_MACRO_REGEX + OR_REGEX + CPP_INLINE_FUNCTION;
-
-	/**
-	 * @param limit minimal length of function which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public CPPFunctionHeuristicChecker(int limit, PrintStream out) {
-		super(limit, FUNCTION_REGEX, CPP_OPENED_BRACKET, CPP_CLOSED_BRACKET,
-				"c++", out);
-	}
+    private static final String OR_REGEX = "|";
+    private static final String CPP_CLOSED_BRACKET = "\\}";
+    private static final String CPP_OPENED_BRACKET = "\\{";
+
+    /**
+     * This regular expression match functions in C++.
+     */
+    private static final String CPP_FUNCTION_REGEX_1  
= "\\w+\\s+[*&]?\\s*\\w+ *\\([^()]*?\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * This regular expression match functions in C++ which have  
mark "::". For
+     * example:
+     * <p>
+     * MyType MyType::Add(const MyType & rhs) { return MyType(itsVal+
+     * rhs.GetItsVal()); }
+     */
+    private static final String CPP_FUNCTION_REGEX_2 = "^[\t ]*[\\w+  
\\*&]+\\s*\\:\\:\\s*[*&~]?\\s*\\w+ *\\([^()]*?\\)( *const  
*)?(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
+    // TODO add regular expression which will match functions with a  
reference
+    // to a string as a returning type for example.
+    private static final String CPP_FUNCTION_REGEX = "(" +  
CPP_FUNCTION_REGEX_1 + ")|(" + CPP_FUNCTION_REGEX_2 + ")";
+
+    /**
+     * This regular expression match macros in C++ which are multilines.  
For
+     * example: #define SWAP(a, b) {
+     * <p>
+     * a ^= b;
+     * <p>
+     * b ^= a;
+     * <p>
+     * a ^= b; }
+     */
+    private static final String CPP_MACRO_REGEX_1 = "#define +\\w+  
*\\([\\s\\S]*\\)\\s*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * This regular expression match macro in C++ which are one-line. For
+     * example:
+     * <p>
+     * #define INCREMENT(x) x++
+     */
+    private static final String CPP_MACRO_REGEX_2 = "#define +\\w+  
*\\([\\s\\S]*\\)*.*[\\n\\r]";
+
+    /**
+     * This regular expression match macros in C++.
+     */
+    private static final String CPP_MACRO_REGEX = "(" + CPP_MACRO_REGEX_1  
+ ")" + OR_REGEX + "(" + CPP_MACRO_REGEX_2
+            + ")";
+
+    /**
+     * This regular expression match inline functions in C++ which are  
multiline
+     * and have parametrs. For example: inline void Recycle( char*  
aBuffer) {
+     * nsMemory::Free(aBuffer); }
+     */
+    private static final String CPP_INLINE_FUNCTION_1  
= "inline\\s+\\w+\\s+(.*)\\([^()]*\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * This regular expression match inline functions in C++ which have no
+     * parametrs.
+     */
+    private static final String CPP_INLINE_FUNCTION_2 = "inline  
+\\w+(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * This regular expression matches inline functions in C++ which  
contains
+     * mark "::". For example:inline size_t  
SearchResultMessageArg::nTried() {
+     * return filename_.size(); }
+     */
+    private static final String CPP_INLINE_FUNCTION_3  
= "inline\\s+\\w+\\s+\\w+\\:\\:\\w+\\s*\\([^()]*\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * This regular expression matches inline functions in C++ which  
contains
+     * mark "::" and,after parameters, key word const. For example: inline
+     * size_t SearchResultMessageArg::nTried() const{ return  
filename_.size();}
+     */
+    private static final String CPP_INLINE_FUNCTION_4  
= "inline\\s+\\w+\\s+\\w+\\:\\:\\w+\\s*\\([^()]*\\)  
*const(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * This regular expression match inline functions in C++.
+     */
+    private static final String CPP_INLINE_FUNCTION = "(" +  
CPP_INLINE_FUNCTION_1 + ")" + OR_REGEX + "("
+            + CPP_INLINE_FUNCTION_2 + ")" + OR_REGEX + "(" +  
CPP_INLINE_FUNCTION_3 + ")" + OR_REGEX + "("
+            + CPP_INLINE_FUNCTION_4 + ")";
+
+    /**
+     * This regular expression match functions,inline functions and macros  
in
+     * C++,
+     */
+    private static final String FUNCTION_REGEX = CPP_FUNCTION_REGEX +  
OR_REGEX + CPP_MACRO_REGEX + OR_REGEX
+            + CPP_INLINE_FUNCTION;
+
+    /**
+     * @param limit minimal length of function which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CSharpFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -27,26 +27,24 @@
   * http://en.wikipedia.org/wiki/C_Sharp_(programming_language)
   *
   * @author maka
- *
   */
  public class CSharpFunctionHeuristicChecker extends  
FunctionHeuristicChecker {
-	private static final String C_SHARP_CLOSED_BRACKET = "\\}";
-	private static final String C_SHARP_OPENED_BRACKET = "\\{";
-
-	/**
-	 * This is regular expression for C# function matching . More info on:
-	 * {@link} http://en.wikipedia.org/wiki/C_Sharp_(programming_language)
-	 */
-	private static final String C_SHARP_FUNCTION_REGEX = "^[\t  
]*[(public)(protected)(private)(static)(void)(abstract)\\w+]*  
+(.*)\\([^()]*?\\)(\\s)*"
-			+ "\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * @param limit minimal length of function which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public CSharpFunctionHeuristicChecker(int limit, PrintStream out) {
-		super(limit, C_SHARP_FUNCTION_REGEX, C_SHARP_OPENED_BRACKET,
-				C_SHARP_CLOSED_BRACKET, "c#", out);
-	}
+    private static final String C_SHARP_CLOSED_BRACKET = "\\}";
+    private static final String C_SHARP_OPENED_BRACKET = "\\{";
+
+    /**
+     * This is regular expression for C# function matching . More info on:
+     * {@link} http://en.wikipedia.org/wiki/C_Sharp_(programming_language)
+     */
+    private static final String C_SHARP_FUNCTION_REGEX = "^[\t  
]*[(public)(protected)(private)(static)(void)(abstract)\\w+]*  
+(.*)\\([^()]*?\\)(\\s)*"
+            + "\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * @param limit minimal length of function which will be considered
+     * @param out print stream for logging purposes
+     */
+    public CSharpFunctionHeuristicChecker(int limit, PrintStream out) {
+        super(limit, C_SHARP_FUNCTION_REGEX, C_SHARP_OPENED_BRACKET,  
C_SHARP_CLOSED_BRACKET, "c#", out);
+    }

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/DelphiFunctionHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/DelphiFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -29,37 +29,35 @@
   * http://www.delphibasics.co.uk/Article.asp?Name=Routines
   *
   * @author maka
- *
   */
  public class DelphiFunctionHeuristicChecker extends  
FunctionHeuristicChecker {

-	private static final String DELPHI_CLOSED_BRACKET = "(?i:END)";
-	private static final String DELPHI_OPENED_BRACKET = "(?i:BEGIN)";
-
-	/**
-	 * This regular expression matches functions in Delphi.
-	 */
-	private static final String DELPHI_FUNCTION_REGEX = "(?i:function)  
+(.*)(\\([^()]*?\\))*(\\s)*\\: *\\w+  
*;(\\s)*(?i:BEGIN)[\\s\\S]*(?i:END;)[\n\r]*";
-
-	/**
-	 * This regular expression matches procedures in Delphi.
-	 */
-	private static final String DELPHI_PROCEDURE_REGEX = "(?i:procedure)  
+(.*)(\\([^()]*?\\))*(\\s)*;(\\s)*(?i:BEGIN)[\\s\\S]*(?i:END;)[\n\r]*";
-
-	/**
-	 * This regular expression matches subroutines in Delphi-both functions  
and
-	 * procedures.
-	 */
-	private static final String DELPHI_SUBROUTINE_REGEX = "("
-			+ DELPHI_FUNCTION_REGEX + ")|(" + DELPHI_PROCEDURE_REGEX + ")";
-
-	/**
-	 * @param limit minimal length of function which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public DelphiFunctionHeuristicChecker(int limit, PrintStream out) {
-		super(limit, DELPHI_SUBROUTINE_REGEX, DELPHI_OPENED_BRACKET,
-				DELPHI_CLOSED_BRACKET, "pascal", out);
-	}
+    private static final String DELPHI_CLOSED_BRACKET = "(?i:END)";
+    private static final String DELPHI_OPENED_BRACKET = "(?i:BEGIN)";
+
+    /**
+     * This regular expression matches functions in Delphi.
+     */
+    private static final String DELPHI_FUNCTION_REGEX = "(?i:function)  
+(.*)(\\([^()]*?\\))*(\\s)*\\: *\\w+  
*;(\\s)*(?i:BEGIN)[\\s\\S]*(?i:END;)[\n\r]*";
+
+    /**
+     * This regular expression matches procedures in Delphi.
+     */
+    private static final String DELPHI_PROCEDURE_REGEX = "(?i:procedure)  
+(.*)(\\([^()]*?\\))*(\\s)*;(\\s)*(?i:BEGIN)[\\s\\S]*(?i:END;)[\n\r]*";
+
+    /**
+     * This regular expression matches subroutines in Delphi-both  
functions and
+     * procedures.
+     */
+    private static final String DELPHI_SUBROUTINE_REGEX = "(" +  
DELPHI_FUNCTION_REGEX + ")|(" + DELPHI_PROCEDURE_REGEX
+            + ")";
+
+    /**
+     * @param limit minimal length of function which will be considered
+     * @param out print stream for logging purposes
+     */
+    public DelphiFunctionHeuristicChecker(int limit, PrintStream out) {
+        super(limit, DELPHI_SUBROUTINE_REGEX, DELPHI_OPENED_BRACKET,  
DELPHI_CLOSED_BRACKET, "pascal", out);
+    }

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/FortranFunctionHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/FortranFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -37,168 +37,155 @@
   * http://www.chem.ox.ac.uk/fortran/subprograms.html
   *
   * @author maka
- *
   */
  public class FortranFunctionHeuristicChecker implements IHeuristicChecker {
-	/**
-	 * This regular expression matches key word FUNCTION which is case
-	 * insensitive followed by one or more blanks.
-	 */
-	public static final String FUNCTION_KEYWORD = "(?i:FUNCTION) +";
-
-	/**
-	 * This regular expression matches key word SUBROUTINE which is case
-	 * insensitive followed by one or more blanks.
-	 */
-	public static final String SUBROUTINE_KEYWORD = "(?i:SUBROUTINE) +";
-
-	/**
-	 * This regular expression matches name of a functions starting with a key
-	 * word FUNCTION
-	 */
-	public static final String FUNCTION_NAME_REGEX = "(?i:FUNCTION) +\\w+";
-
-	/**
-	 * This regular expression matches name of a subroutine starting with a  
key
-	 * word SUBROUTINE.
-	 */
-	public static final String SUBROUTINE_NAME_REGEX = "(?i:SUBROUTINE)  
+\\w+";
-
-	/**
-	 * This regular expression matches functions header in Fortran.
-	 */
-	public static final String FUNCTION_HEADER_REGEX = "\\w+ +(?i:FUNCTION)  
+\\w+ *\\(.*\\).*\\n";
-
-	/**
-	 * This regular expression matches subroutines header in Fortran.
-	 */
-	public static final String SUBROUTINE_HEADER_REGEX = " *(?i:SUBROUTINE)  
+\\w+ *\\(.*\\).*\\n";
-
-	private int limit;
-	private final String language;
-	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());
-		boolean isSearchNeaded = false;
-		String functionHeader = getFunctionHeader(codeToBeChecked,
-				FUNCTION_HEADER_REGEX);
-		String functionName;
-		if (functionHeader != null) {
-			functionName = getFunctionName(functionHeader, FUNCTION_KEYWORD,
-					FUNCTION_NAME_REGEX);
-			// TODO This regular expression can hung up an application.
-			String functionEndRegex = // "(?i:END) +(?i:FUNCTION) +" +
-			"" + functionName;
-			isSearchNeaded = isFortranFunction(codeToBeChecked,
-					FUNCTION_HEADER_REGEX, functionEndRegex);
-		} else {
-
-			functionHeader = getFunctionHeader(codeToBeChecked,
-					SUBROUTINE_HEADER_REGEX);
-			if (functionHeader != null) {
-				functionName = getFunctionName(functionHeader,
-						SUBROUTINE_KEYWORD, SUBROUTINE_NAME_REGEX);
-
-				isSearchNeaded = isFortranFunction(codeToBeChecked,
-						SUBROUTINE_HEADER_REGEX, functionName);
-			}
-		}
-		toret = new HeuristicCheckerResult(isSearchNeaded, false,
-				codeToBeChecked, this.getClass());
-		return toret;
-	}
-
-	/**
-	 * Method will return false if there are some characters before  
subprograms
-	 * or after subprogram. Depends on limit property, function can return  
false
-	 * if matched subprogram length is smaller then limit value.
-	 *
-	 * @param codeToBeChecked
-	 * @param functionHeader
-	 * @param functionEndRegex
-	 * @return true if this is Fortran subprogram.
-	 */
-	boolean isFortranFunction(String codeToBeChecked, String functionHeader,
-			String functionEndRegex) {
-		boolean toret = false;
-		String functionRegex = functionHeader + "[\\s\\S]*" + functionEndRegex;
-		out.println(functionRegex);
-		Pattern p = Pattern.compile(functionRegex, Pattern.MULTILINE);
-		// Run matches
-		Matcher m = p.matcher(codeToBeChecked);
-
-		if (m.find()) {
-			String found = m.group();
-			if (codeToBeChecked.equals(found)) {
-				out.println("Found function: " + found);
-				toret = found.length() > limit ? true : false;
-			}
-		}
-
-		return toret;
-	}
-
-	/**
-	 * Method will return functions name from a functions header
-	 *
-	 * @param functionHeader
-	 * @param keywordRegex
-	 * @param functionNameRegex
-	 * @return functions name
-	 */
-	String getFunctionName(String functionHeader, String keywordRegex,
-			String functionNameRegex) {
-		String toret = null;
-
-		Pattern p = Pattern.compile(functionNameRegex, Pattern.MULTILINE
-				& Pattern.CASE_INSENSITIVE);
-		// Run matches
-		Matcher m = p.matcher(functionHeader);
-
-		if (m.find()) {
-			toret = m.group();
-			toret = toret.replaceFirst(keywordRegex, "");
-		}
-
-		return toret;
-	}
-
-	/**
-	 * Method will return functions header from a string. Functions header is
-	 * matched by a regular expression regex.
-	 *
-	 * @param codeToBeChecked
-	 * @param regex
-	 * @return functions header if it functions
-	 */
-	String getFunctionHeader(String codeToBeChecked, String regex) {
-		String toret = null;
-
-		Pattern p = Pattern.compile(regex, Pattern.MULTILINE
-				& Pattern.CASE_INSENSITIVE);
-		// Run matches
-		Matcher m = p.matcher(codeToBeChecked);
-
-		if (m.find()) {
-			toret = m.group();
-		}
-
-		return toret;
-	}
-
-	@Override
-	public String getLanguage() {
-		return this.language;
-	}
+    /**
+     * This regular expression matches key word FUNCTION which is case
+     * insensitive followed by one or more blanks.
+     */
+    public static final String FUNCTION_KEYWORD = "(?i:FUNCTION) +";
+
+    /**
+     * This regular expression matches key word SUBROUTINE which is case
+     * insensitive followed by one or more blanks.
+     */
+    public static final String SUBROUTINE_KEYWORD = "(?i:SUBROUTINE) +";
+
+    /**
+     * This regular expression matches name of a functions starting with a  
key
+     * word FUNCTION
+     */
+    public static final String FUNCTION_NAME_REGEX = "(?i:FUNCTION) +\\w+";
+
+    /**
+     * This regular expression matches name of a subroutine starting with  
a key
+     * word SUBROUTINE.
+     */
+    public static final String SUBROUTINE_NAME_REGEX = "(?i:SUBROUTINE)  
+\\w+";
+
+    /**
+     * This regular expression matches functions header in Fortran.
+     */
+    public static final String FUNCTION_HEADER_REGEX = "\\w+  
+(?i:FUNCTION) +\\w+ *\\(.*\\).*\\n";
+
+    /**
+     * This regular expression matches subroutines header in Fortran.
+     */
+    public static final String SUBROUTINE_HEADER_REGEX = "  
*(?i:SUBROUTINE) +\\w+ *\\(.*\\).*\\n";
+
+    private int limit;
+    private final String language;
+    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());
+        boolean isSearchNeaded = false;
+        String functionHeader = getFunctionHeader(codeToBeChecked,  
FUNCTION_HEADER_REGEX);
+        String functionName;
+        if (functionHeader != null) {
+            functionName = getFunctionName(functionHeader,  
FUNCTION_KEYWORD, FUNCTION_NAME_REGEX);
+            // TODO This regular expression can hung up an application.
+            String functionEndRegex = // "(?i:END) +(?i:FUNCTION) +" +
+            "" + functionName;
+            isSearchNeaded = isFortranFunction(codeToBeChecked,  
FUNCTION_HEADER_REGEX, functionEndRegex);
+        } else {
+
+            functionHeader = getFunctionHeader(codeToBeChecked,  
SUBROUTINE_HEADER_REGEX);
+            if (functionHeader != null) {
+                functionName = getFunctionName(functionHeader,  
SUBROUTINE_KEYWORD, SUBROUTINE_NAME_REGEX);
+
+                isSearchNeaded = isFortranFunction(codeToBeChecked,  
SUBROUTINE_HEADER_REGEX, functionName);
+            }
+        }
+        toret = new HeuristicCheckerResult(isSearchNeaded, false,  
codeToBeChecked, this.getClass());
+        return toret;
+    }
+
+    /**
+     * Method will return false if there are some characters before  
subprograms
+     * or after subprogram. Depends on limit property, function can return  
false
+     * if matched subprogram length is smaller then limit value.
+     *
+     * @param codeToBeChecked
+     * @param functionHeader
+     * @param functionEndRegex
+     * @return true if this is Fortran subprogram.
+     */
+    boolean isFortranFunction(String codeToBeChecked, String  
functionHeader, String functionEndRegex) {
+        boolean toret = false;
+        String functionRegex = functionHeader + "[\\s\\S]*" +  
functionEndRegex;
+        out.println(functionRegex);
+        Pattern p = Pattern.compile(functionRegex, Pattern.MULTILINE);
+        // Run matches
+        Matcher m = p.matcher(codeToBeChecked);
+
+        if (m.find()) {
+            String found = m.group();
+            if (codeToBeChecked.equals(found)) {
+                out.println("Found function: " + found);
+                toret = found.length() > limit ? true : false;
+            }
+        }
+
+        return toret;
+    }
+
+    /**
+     * Method will return functions name from a functions header
+     *
+     * @param functionHeader
+     * @param keywordRegex
+     * @param functionNameRegex
+     * @return functions name
+     */
+    String getFunctionName(String functionHeader, String keywordRegex,  
String functionNameRegex) {
+        String toret = null;
+
+        Pattern p = Pattern.compile(functionNameRegex, Pattern.MULTILINE &  
Pattern.CASE_INSENSITIVE);
+        // Run matches
+        Matcher m = p.matcher(functionHeader);
+
+        if (m.find()) {
+            toret = m.group();
+            toret = toret.replaceFirst(keywordRegex, "");
+        }
+
+        return toret;
+    }
+
+    /**
+     * Method will return functions header from a string. Functions header  
is
+     * matched by a regular expression regex.
+     *
+     * @param codeToBeChecked
+     * @param regex
+     * @return functions header if it functions
+     */
+    String getFunctionHeader(String codeToBeChecked, String regex) {
+        String toret = null;
+
+        Pattern p = Pattern.compile(regex, Pattern.MULTILINE &  
Pattern.CASE_INSENSITIVE);
+        // Run matches
+        Matcher m = p.matcher(codeToBeChecked);
+
+        if (m.find()) {
+            toret = m.group();
+        }
+
+        return toret;
+    }
+
+    @Override
+    public String getLanguage() {
+        return this.language;
+    }

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/FunctionHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/FunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -32,97 +32,89 @@
   * functions.
   *
   * @author maka
- *
   */
  public class FunctionHeuristicChecker implements IHeuristicChecker {
-	private final String CLOSED_BRACKET;
-	private final String OPENED_BRACKET;
-	private final String FUNCTION_REGEX;
-	private final int limit;
-	private final String language;
-	private final PrintStream out;
-
-	/**
-	 * @param limit
-	 *            minimal length of comment which will be considered
-	 * @param regex
-	 *            regular expression to match comment in current language
-	 * @param openedBrackets
-	 *            opened brackets in particular programming language( for
-	 *            example "{" in c)
-	 * @param closedBrackets
-	 *            closed brackets in particular programming language( for
-	 *            example "}" in c)
-	 * @param language
-	 *            programming language
-	 * @param out
-	 *            print stream for logging purposes
-	 */
-	public FunctionHeuristicChecker(int limit, String regex,
-			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;
-	}
-
-	/* (non-Javadoc)
-	 * @see  
org.apache.rat.pd.heuristic.IHeuristicChecker#checkByHeuristic(java.lang.String)
-	 */
-	public HeuristicCheckerResult checkByHeuristic(String codeToBeChecked) {
-		HeuristicCheckerResult toret = new HeuristicCheckerResult(false, true,
-				codeToBeChecked, this.getClass());
-
-		Pattern p = Pattern.compile(FUNCTION_REGEX, Pattern.MULTILINE);
-		// Run matches
-		Matcher m = p.matcher(codeToBeChecked);
-
-		if (m.find()) {
-			String found = m.group();
-			if (codeToBeChecked.endsWith(found)) {
-				boolean isSearchNeaded = found.length() > limit
-						&& filterWrongMatches(found) ? true : false;
-				toret = new HeuristicCheckerResult(isSearchNeaded, false,
-						found, this.getClass());
-				out.println("Found function: " + found);
-			}
-		}
-		return toret;
-	}
-
-	/**
-	 *
-	 * This method can filter correct functions from incomplete ones. Function
-	 * must have equal number of opened and closed segment symbols. Java
-	 * example: public String toString(){ return super.toString(); } have one
-	 * opened and one closed brackets. This function have correct syntax.
-	 *
-	 * @param codeToBeChecked
-	 * @return true if codeToBeChecked is correct function
-	 */
-	private boolean filterWrongMatches(String codeToBeChecked) {
-		int numberOfOpenedBrackets = count(OPENED_BRACKET, codeToBeChecked);
-		int numberOfClosedBrackets = count(CLOSED_BRACKET, codeToBeChecked);
-		return numberOfOpenedBrackets == numberOfClosedBrackets;
-	}
-
-	// TODO think about brackets in comments inside functions
-	private int count(String regex, String codeToBeChecked) {
-		int toret = 0;
-		Pattern p = Pattern.compile(regex, Pattern.MULTILINE);
-		Matcher m = p.matcher(codeToBeChecked);
-		while (m.find()) {
-			toret++;
-		}
-		return toret;
-	}
-
-	@Override
-	public String getLanguage() {
-		return this.language;
-	}
+    private final String CLOSED_BRACKET;
+    private final String OPENED_BRACKET;
+    private final String FUNCTION_REGEX;
+    private final int limit;
+    private final String language;
+    private final PrintStream out;
+
+    /**
+     * @param limit minimal length of comment which will be considered
+     * @param regex regular expression to match comment in current language
+     * @param openedBrackets opened brackets in particular programming  
language(
+     *        for example "{" in c)
+     * @param closedBrackets closed brackets in particular programming  
language(
+     *        for example "}" in c)
+     * @param language programming language
+     * @param out print stream for logging purposes
+     */
+    public FunctionHeuristicChecker(int limit, String regex, 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;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     *  
org.apache.rat.pd.heuristic.IHeuristicChecker#checkByHeuristic(java.lang
+     * .String)
+     */
+    public HeuristicCheckerResult checkByHeuristic(String codeToBeChecked)  
{
+        HeuristicCheckerResult toret = new HeuristicCheckerResult(false,  
true, codeToBeChecked, this.getClass());
+
+        Pattern p = Pattern.compile(FUNCTION_REGEX, Pattern.MULTILINE);
+        // Run matches
+        Matcher m = p.matcher(codeToBeChecked);
+
+        if (m.find()) {
+            String found = m.group();
+            if (codeToBeChecked.endsWith(found)) {
+                boolean isSearchNeaded = found.length() > limit &&  
filterWrongMatches(found) ? true : false;
+                toret = new HeuristicCheckerResult(isSearchNeaded, false,  
found, this.getClass());
+                out.println("Found function: " + found);
+            }
+        }
+        return toret;
+    }
+
+    /**
+     * This method can filter correct functions from incomplete ones.  
Function
+     * must have equal number of opened and closed segment symbols. Java
+     * example: public String toString(){ return super.toString(); } have  
one
+     * opened and one closed brackets. This function have correct syntax.
+     *
+     * @param codeToBeChecked
+     * @return true if codeToBeChecked is correct function
+     */
+    private boolean filterWrongMatches(String codeToBeChecked) {
+        int numberOfOpenedBrackets = count(OPENED_BRACKET,  
codeToBeChecked);
+        int numberOfClosedBrackets = count(CLOSED_BRACKET,  
codeToBeChecked);
+        return numberOfOpenedBrackets == numberOfClosedBrackets;
+    }
+
+    // TODO think about brackets in comments inside functions
+    private int count(String regex, String codeToBeChecked) {
+        int toret = 0;
+        Pattern p = Pattern.compile(regex, Pattern.MULTILINE);
+        Matcher m = p.matcher(codeToBeChecked);
+        while (m.find()) {
+            toret++;
+        }
+        return toret;
+    }
+
+    @Override
+    public String getLanguage() {
+        return this.language;
+    }

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/JavaFunctionHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/JavaFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -28,30 +28,27 @@
   * on: {@link}  
http://java.sun.com/docs/books/tutorial/java/javaOO/methods.html
   *
   * @author maka
- *
   */
  public class JavaFunctionHeuristicChecker extends FunctionHeuristicChecker  
{

-	private static final String JAVA_CLOSED_BRACKET = "\\}";
-	private static final String JAVA_OPENED_BRACKET = "\\{";
-
-	/**
-	 * This regular expression can match java functions from source code.  
Only condition is
-	 * that function definition must start from new line. More info about Java
-	 * functions on: {@link}
-	 * http://java.sun.com/docs/books/tutorial/java/javaOO/methods.html
-	 *
-	 */
-	private static final String JAVA_FUNCTION_REGEX = "^[\t  
]*([(\\w+)<>\\[\\],\\?]|( +))+ +(\\w+) *\\([^()]*?\\) *(throws  
+\\w+([\\s,\\w+]*?))*?\\s*"
-			+ "\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * @param limit minimal length of function which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public JavaFunctionHeuristicChecker(int limit, PrintStream out) {
-		super(limit, JAVA_FUNCTION_REGEX, JAVA_OPENED_BRACKET,
-				JAVA_CLOSED_BRACKET, "java", out);
-	}
+    private static final String JAVA_CLOSED_BRACKET = "\\}";
+    private static final String JAVA_OPENED_BRACKET = "\\{";
+
+    /**
+     * This regular expression can match java functions from source code.  
Only
+     * condition is that function definition must start from new line.  
More info
+     * about Java functions on: {@link}
+     * http://java.sun.com/docs/books/tutorial/java/javaOO/methods.html
+     */
+    private static final String JAVA_FUNCTION_REGEX = "^[\t  
]*([(\\w+)<>\\[\\],\\?]|( +))+ +(\\w+) *\\([^()]*?\\) *(throws  
+\\w+([\\s,\\w+]*?))*?\\s*"
+            + "\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * @param limit minimal length of function which will be considered
+     * @param out print stream for logging purposes
+     */
+    public JavaFunctionHeuristicChecker(int limit, PrintStream out) {
+        super(limit, JAVA_FUNCTION_REGEX, JAVA_OPENED_BRACKET,  
JAVA_CLOSED_BRACKET, "java", out);
+    }

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/JavaScriptFunctionHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/JavaScriptFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -26,29 +26,26 @@
   * JavaScript: {@link} http://www.w3schools.com/jS/js_functions.asp
   *
   * @author maka
- *
   */
-public class JavaScriptFunctionHeuristicChecker extends
-		FunctionHeuristicChecker {
-
-	private static final String JAVA_SCRIPT_CLOSED_BRACKET = "\\}";
-	private static final String JAVA_SCRIPT_OPENED_BRACKET = "\\{";
-
-	/**
-	 * This regular expression can match functions from JavaScript. More info
-	 * about functions in JavaScript: {@link}
-	 * http://www.w3schools.com/jS/js_functions.asp
-	 *
-	 */
-	private static final String JAVA_SCRIPT_FUNCTION_REGEX = "function +\\w+  
*\\([^()]*?\\)\\s*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * @param limit minimal length of function which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public JavaScriptFunctionHeuristicChecker(int limit, PrintStream out) {
-		super(limit, JAVA_SCRIPT_FUNCTION_REGEX, JAVA_SCRIPT_OPENED_BRACKET,
-				JAVA_SCRIPT_CLOSED_BRACKET, "javascript", out);
-	}
+public class JavaScriptFunctionHeuristicChecker extends  
FunctionHeuristicChecker {
+
+    private static final String JAVA_SCRIPT_CLOSED_BRACKET = "\\}";
+    private static final String JAVA_SCRIPT_OPENED_BRACKET = "\\{";
+
+    /**
+     * This regular expression can match functions from JavaScript. More  
info
+     * about functions in JavaScript: {@link}
+     * http://www.w3schools.com/jS/js_functions.asp
+     */
+    private static final String JAVA_SCRIPT_FUNCTION_REGEX = "function  
+\\w+ *\\([^()]*?\\)\\s*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * @param limit minimal length of function which will be considered
+     * @param out print stream for logging purposes
+     */
+    public JavaScriptFunctionHeuristicChecker(int limit, PrintStream out) {
+        super(limit, JAVA_SCRIPT_FUNCTION_REGEX,  
JAVA_SCRIPT_OPENED_BRACKET, JAVA_SCRIPT_CLOSED_BRACKET, "javascript",
+                out);
+    }

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/PHPFunctionHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/PHPFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -27,24 +27,23 @@
   * {@link} http://www.w3schools.com/PHP/php_functions.asp
   *
   * @author maka
- *
   */
  public class PHPFunctionHeuristicChecker extends FunctionHeuristicChecker {
-	private static final String PHP_CLOSED_BRACKET = "\\}";
-	private static final String PHP_OPENED_BRACKET = "\\{";
-
-	/**
-	 * This regular expression match PHP functions. More info about functions  
in PHP on:
-	 * {@link} http://www.w3schools.com/PHP/php_functions.asp
-	 */
-	private static final String PHP_FUNCTION_REGEX = "function +\\w+  
*\\([^()]*?\\)\\s*\\{[\\s\\S]*\\}[\n\r]*";
-
-	/**
-	 * @param limit minimal length of function which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public PHPFunctionHeuristicChecker(int limit, PrintStream out) {
-		super(limit, PHP_FUNCTION_REGEX, PHP_OPENED_BRACKET,  
PHP_CLOSED_BRACKET, "php", out);
-	}
+    private static final String PHP_CLOSED_BRACKET = "\\}";
+    private static final String PHP_OPENED_BRACKET = "\\{";
+
+    /**
+     * This regular expression match PHP functions. More info about  
functions in
+     * PHP on: {@link} http://www.w3schools.com/PHP/php_functions.asp
+     */
+    private static final String PHP_FUNCTION_REGEX = "function +\\w+  
*\\([^()]*?\\)\\s*\\{[\\s\\S]*\\}[\n\r]*";
+
+    /**
+     * @param limit minimal length of function which will be considered
+     * @param out print stream for logging purposes
+     */
+    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	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/PascalFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -27,39 +27,37 @@
   * http://www.learn-programming.za.net/programming_pascal_learn09.html
   *
   * @author maka
- *
   */
  public class PascalFunctionHeuristicChecker extends  
FunctionHeuristicChecker {

-	private static final String PASCAL_CLOSED_BRACKET = "(?i:END)";
-	private static final String PASCAL_OPENED_BRACKET = "(?i:BEGIN)";
-
-	/**
-	 * This regular expression match functions in Pascal.
-	 */
-	private static final String PASCAL_FUNCTION_REGEX = "(?i:function)  
+(.*)\\([^()]*?\\)(\\s)*\\: *\\w+ *;(\\s)*(?i:BEGIN)[\\s\\S]*(?i:END;)";
-
-	/**
-	 * This regular expression match procedures in Pascal.
-	 */
-	private static final String PASCAL_PROCEDURE_REGEX = "(?i:procedure)  
+(.*)\\([^()]*?\\)(\\s)*;(\\s)*(?i:BEGIN)[\\s\\S]*(?i:END;)";
-
-	/**
-	 * This regular expression matches procedures and functions in Pascal.  
Since
-	 * Pascal is case-insensitive program language the regular expression is
-	 * written in that way that it is case-insensitive for key words -
-	 * procedure, function, begin and end. For example: BEGIN,BeGiN and begin
-	 * are treated as equal.
-	 */
-	private static final String PASCAL_SUBPROGRAM_REGEX = "("
-			+ PASCAL_FUNCTION_REGEX + ")|(" + PASCAL_PROCEDURE_REGEX + ")";
-
-	/**
-	 * @param limit minimal length of function which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public PascalFunctionHeuristicChecker(int limit, PrintStream out) {
-		super(limit, PASCAL_SUBPROGRAM_REGEX, PASCAL_OPENED_BRACKET,
-				PASCAL_CLOSED_BRACKET, "pascal", out);
-	}
-}
+    private static final String PASCAL_CLOSED_BRACKET = "(?i:END)";
+    private static final String PASCAL_OPENED_BRACKET = "(?i:BEGIN)";
+
+    /**
+     * This regular expression match functions in Pascal.
+     */
+    private static final String PASCAL_FUNCTION_REGEX = "(?i:function)  
+(.*)\\([^()]*?\\)(\\s)*\\: *\\w+ *;(\\s)*(?i:BEGIN)[\\s\\S]*(?i:END;)";
+
+    /**
+     * This regular expression match procedures in Pascal.
+     */
+    private static final String PASCAL_PROCEDURE_REGEX = "(?i:procedure)  
+(.*)\\([^()]*?\\)(\\s)*;(\\s)*(?i:BEGIN)[\\s\\S]*(?i:END;)";
+
+    /**
+     * This regular expression matches procedures and functions in Pascal.  
Since
+     * Pascal is case-insensitive program language the regular expression  
is
+     * written in that way that it is case-insensitive for key words -
+     * procedure, function, begin and end. For example: BEGIN,BeGiN and  
begin
+     * are treated as equal.
+     */
+    private static final String PASCAL_SUBPROGRAM_REGEX = "(" +  
PASCAL_FUNCTION_REGEX + ")|(" + PASCAL_PROCEDURE_REGEX
+            + ")";
+
+    /**
+     * @param limit minimal length of function which will be considered
+     * @param out print stream for logging purposes
+     */
+    public PascalFunctionHeuristicChecker(int limit, PrintStream out) {
+        super(limit, PASCAL_SUBPROGRAM_REGEX, PASCAL_OPENED_BRACKET,  
PASCAL_CLOSED_BRACKET, "pascal", out);
+    }
+}
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/VisualBasicFunctionHeuristicChecker.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/VisualBasicFunctionHeuristicChecker.java	 
Fri Aug 21 06:53:09 2009
@@ -30,90 +30,86 @@
   * http://en.wikiversity.org/wiki/Functions_and_Subroutines_in_VB6
   *
   * @author maka
- *
   */
-public class VisualBasicFunctionHeuristicChecker extends
-		FunctionHeuristicChecker {
-
-	private static final String VISUAL_BASIC_OPENED_BRACKET = "\\{";
-	private static final String VISUAL_BASIC_CLOSED_BRACKET = "\\}";
-
-	/**
-	 * This regular expression match functions in Visual Basic which have  
access
-	 * modifier. For example :
-	 * <p>
-	 * Private Function Add(ByVal x As Integer, ByVal y As Integer) As Integer
-	 * <p>
-	 * Dim Res as integer Res = x + y Add = Res
-	 * <p>
-	 * End Function
-	 */
-	private static final String VISUAL_BASIC_FUNCTION_REGEX_1  
= "((?i:private)|(?i:public)) +Function +\\w+ *\\([^()]*?\\) *(As)  
+\\w+[\\s\\S]*End +Function[\n\r]*";
-
-	/**
-	 * This regular expression match functions in Visual Basic which don't  
have
-	 * access modifier. For example :
-	 * <p>
-	 * Function Add(ByVal x As Integer, ByVal y As Integer) As Integer
-	 * <p>
-	 * Dim Res as integer Res = x + y Add = Res
-	 * <p>
-	 * End Function
-	 */
-	private static final String VISUAL_BASIC_FUNCTION_REGEX_2 = "Function  
+\\w+ *\\([^()]*?\\) *(As) +\\w+[\\s\\S]*End +Function[\n\r]*";
-
-	/**
-	 * This regular expression matches functions in Visual Basic.
-	 */
-	private static final String VISUAL_BASIC_FUNCTION_REGEX = "("
-			+ VISUAL_BASIC_FUNCTION_REGEX_1 + ")|("
-			+ VISUAL_BASIC_FUNCTION_REGEX_2 + ")";
-
-	/**
-	 * This regular expression match subroutines in Visual Basic which have
-	 * access modifier. For example :
-	 * <p>
-	 * Private Sub Form_Load()
-	 * <p>
-	 * DisplayAdd 5, 2
-	 * <p>
-	 * End Sub
-	 */
-	private static final String VISUAL_BASIC_SUBROUTINES_REGEX_1  
= "((?i:private)|(?i:public)) +Sub +\\w+ *\\([^()]*?\\)[\\s\\S]*End  
+Sub[\n\r]*";
-
-	/**
-	 * This regular expression match subroutines in Visual Basic which do not
-	 * have access modifier. For example:
-	 * <p>
-	 * Sub TestSub()
-	 * <p>
-	 * MsgBox "Code in TestSub()"
-	 * <p>
-	 * End Sub
-	 */
-	private static final String VISUAL_BASIC_SUBROUTINES_REGEX_2 = "Sub +\\w+  
*\\([^()]*?\\)[\\s\\S]*End +Sub[\n\r]*";
-
-	/**
-	 * This regular expression matches subroutines in Visual Basic.
-	 */
-	private static final String VISUAL_BASIC_SUBROUTINES_REGEX = "("
-			+ VISUAL_BASIC_SUBROUTINES_REGEX_1 + ")|("
-			+ VISUAL_BASIC_SUBROUTINES_REGEX_2 + ")";
-
-	/**
-	 * This regular expression matches both functions and subroutines in  
Visual
-	 * Basic.
-	 */
-	private static final String VISUAL_BASIC_SUBPROGRAMS_REGEX =  
VISUAL_BASIC_FUNCTION_REGEX
-			+ "|" + VISUAL_BASIC_SUBROUTINES_REGEX;
-
-	/**
-	 * @param limit minimal length of function which will be considered
-	 * @param out print stream for logging purposes
-	 */
-	public VisualBasicFunctionHeuristicChecker(int limit, PrintStream out) {
-		super(limit, VISUAL_BASIC_SUBPROGRAMS_REGEX,
-				VISUAL_BASIC_OPENED_BRACKET, VISUAL_BASIC_CLOSED_BRACKET,  
IHeuristicChecker.ALL_LANGUAGES, out);
-	}
+public class VisualBasicFunctionHeuristicChecker extends  
FunctionHeuristicChecker {
+
+    private static final String VISUAL_BASIC_OPENED_BRACKET = "\\{";
+    private static final String VISUAL_BASIC_CLOSED_BRACKET = "\\}";
+
+    /**
+     * This regular expression match functions in Visual Basic which have  
access
+     * modifier. For example :
+     * <p>
+     * Private Function Add(ByVal x As Integer, ByVal y As Integer) As  
Integer
+     * <p>
+     * Dim Res as integer Res = x + y Add = Res
+     * <p>
+     * End Function
+     */
+    private static final String VISUAL_BASIC_FUNCTION_REGEX_1  
= "((?i:private)|(?i:public)) +Function +\\w+ *\\([^()]*?\\) *(As)  
+\\w+[\\s\\S]*End +Function[\n\r]*";
+
+    /**
+     * This regular expression match functions in Visual Basic which don't  
have
+     * access modifier. For example :
+     * <p>
+     * Function Add(ByVal x As Integer, ByVal y As Integer) As Integer
+     * <p>
+     * Dim Res as integer Res = x + y Add = Res
+     * <p>
+     * End Function
+     */
+    private static final String VISUAL_BASIC_FUNCTION_REGEX_2 = "Function  
+\\w+ *\\([^()]*?\\) *(As) +\\w+[\\s\\S]*End +Function[\n\r]*";
+
+    /**
+     * This regular expression matches functions in Visual Basic.
+     */
+    private static final String VISUAL_BASIC_FUNCTION_REGEX = "(" +  
VISUAL_BASIC_FUNCTION_REGEX_1 + ")|("
+            + VISUAL_BASIC_FUNCTION_REGEX_2 + ")";
+
+    /**
+     * This regular expression match subroutines in Visual Basic which have
+     * access modifier. For example :
+     * <p>
+     * Private Sub Form_Load()
+     * <p>
+     * DisplayAdd 5, 2
+     * <p>
+     * End Sub
+     */
+    private static final String VISUAL_BASIC_SUBROUTINES_REGEX_1  
= "((?i:private)|(?i:public)) +Sub +\\w+ *\\([^()]*?\\)[\\s\\S]*End  
+Sub[\n\r]*";
+
+    /**
+     * This regular expression match subroutines in Visual Basic which do  
not
+     * have access modifier. For example:
+     * <p>
+     * Sub TestSub()
+     * <p>
+     * MsgBox "Code in TestSub()"
+     * <p>
+     * End Sub
+     */
+    private static final String VISUAL_BASIC_SUBROUTINES_REGEX_2 = "Sub  
+\\w+ *\\([^()]*?\\)[\\s\\S]*End +Sub[\n\r]*";
+
+    /**
+     * This regular expression matches subroutines in Visual Basic.
+     */
+    private static final String VISUAL_BASIC_SUBROUTINES_REGEX = "(" +  
VISUAL_BASIC_SUBROUTINES_REGEX_1 + ")|("
+            + VISUAL_BASIC_SUBROUTINES_REGEX_2 + ")";
+
+    /**
+     * This regular expression matches both functions and subroutines in  
Visual
+     * Basic.
+     */
+    private static final String VISUAL_BASIC_SUBPROGRAMS_REGEX =  
VISUAL_BASIC_FUNCTION_REGEX + "|"
+            + VISUAL_BASIC_SUBROUTINES_REGEX;
+
+    /**
+     * @param limit minimal length of function which will be considered
+     * @param out print stream for logging purposes
+     */
+    public VisualBasicFunctionHeuristicChecker(int limit, PrintStream out)  
{
+        super(limit, VISUAL_BASIC_SUBPROGRAMS_REGEX,  
VISUAL_BASIC_OPENED_BRACKET, VISUAL_BASIC_CLOSED_BRACKET,
+                IHeuristicChecker.ALL_LANGUAGES, out);
+    }

  }
=======================================
---  
/trunk/src/main/java/org/apache/rat/pd/heuristic/misspellings/Dictionary.java	 
Sun Aug 16 16:43:54 2009
+++  
/trunk/src/main/java/org/apache/rat/pd/heuristic/misspellings/Dictionary.java	 
Fri Aug 21 06:53:09 2009
@@ -31,65 +31,62 @@
   * return information about existence of some word in that dictionary.
   *
   * @author maka
- *
   */
  public class Dictionary implements IDictionary {

-	/**
-	 * When we load dictionary, this structure ensure proper order and log(n)
-	 * search performance
-	 */
-	private TreeSet<String> dictionary = new TreeSet<String>();
-
-	/**
-	 * @param is input stream for dictionary
-	 * @throws IOException
-	 */
-	public Dictionary(InputStream is) throws IOException {
-		initializeBasicSet();
-		readDictionary(is);
-	}
-
-	/**
-	 * This method load dictionary from Input Stream
-	 *
-	 * @param is
-	 *            input stream
-	 * @throws IOException
-	 */
-	private void readDictionary(InputStream is) throws IOException
-	{
-		BufferedReader input = new BufferedReader(new InputStreamReader(is));
-		//TODO think about this - exception can be caught here
-		try {
-			String line = null;
-			while ((line = input.readLine()) != null) {
-				dictionary.add(line.toLowerCase());
-			}
-		} finally {
-			input.close();
-		}
-	}
-
-	/**
-	 * We must add in dictionary alphabet letters. Single character strings  
are
-	 * not interesting to us.
-	 */
-	private void initializeBasicSet() {
-		char letter;
-		for (letter = 'a'; letter <= 'z'; letter++) {
-			dictionary.add(Character.toString(letter));
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see
-	 * org.apache.rat.pd.heuristic.misspellings.IDictionary#exist(java.lang.
-	 * String)
-	 */
-	public boolean exist(String toFind) {
-		return dictionary.contains(toFind);
-	}
-}
+    /**
+     * When we load dictionary, this structure ensure proper order and  
log(n)
+     * search performance
+     */
+    private TreeSet<String> dictionary = new TreeSet<String>();
+
+    /**
+     * @param is input stream for dictionary
+     * @throws IOException
+     */
+    public Dictionary(InputStream is) throws IOException {
+        initializeBasicSet();
+        readDictionary(is);
+    }
+
+    /**
+     * This method load dictionary from Input Stream
+     *
+     * @param is input stream
+     * @throws IOException
+     */
+    private void readDictionary(InputStream is) throws IOException {
+        BufferedReader input = new BufferedReader(new  
InputStreamReader(is));
+        // TODO think about this - exception can be caught here
+        try {
+            String line = null;
+            while ((line = input.readLine()) != null) {
+                dictionary.add(line.toLowerCase());
+            }
+        } finally {
+            input.close();
+        }
+    }
+
+    /**
+     * We must add in dictionary alphabet letters. Single character  
strings are
+     * not interesting to us.
+     */
+    private void initializeBasicSet() {
+        char letter;
+        for (letter = 'a'; letter <= 'z'; letter++) {
+            dictionary.add(Character.toString(letter));
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     *  
org.apache.rat.pd.heuristic.misspellings.IDictionary#exist(java.lang.
+     * String)
+     */
+    public boolean exist(String toFind) {
+        return dictionary.contains(toFind);
+    }
+}
=======================================
***Additional files exist in this changeset.***