[apache-rat-pd] r55 committed - Defaulting of language is added in PdCommandLine and language. PrintSt...

0 views
Skip to first unread message

codesite...@google.com

unread,
Aug 22, 2009, 6:22:46 PM8/22/09
to apache-rat...@googlegroups.com
Revision: 55
Author: maka82
Date: Sat Aug 22 15:21:34 2009
Log: Defaulting of language is added in PdCommandLine and language.
PrintStream out class property is not static anymore.
http://code.google.com/p/apache-rat-pd/source/detail?r=55

Modified:
/trunk/src/main/java/org/apache/rat/pd/core/PdCommandLine.java
/trunk/src/main/java/org/apache/rat/pd/core/PlagiarismDetector.java

=======================================
--- /trunk/src/main/java/org/apache/rat/pd/core/PdCommandLine.java Sat Aug
22 10:09:36 2009
+++ /trunk/src/main/java/org/apache/rat/pd/core/PdCommandLine.java Sat Aug
22 15:21:34 2009
@@ -35,6 +35,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.lang.Validate;
+import org.apache.rat.pd.heuristic.IHeuristicChecker;
import org.apache.rat.pd.util.FileManipulator;

/**
@@ -87,6 +88,7 @@
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 DEFAULT_LANGUAGE_MSG = "Progremming
language is not set.In use is default language: ";
private static final String VERBOSE_OPT_LONG = "verbose";
private static final String LANGUAGE_OPT_LONG = "language";
private static final String HEURISTICS_OPT_LONG = "heuristics";
@@ -224,6 +226,10 @@
this.out.println(DEFAULT_HEURISTIC_MSG + DEFAULT_HEURISTIC);
this.heuristics.add(DEFAULT_HEURISTIC);
}
+ if (this.language == null) {
+ this.out.println(DEFAULT_LANGUAGE_MSG +
IHeuristicChecker.ALL_LANGUAGES);
+ this.language = IHeuristicChecker.ALL_LANGUAGES;
+ }
}

/**
=======================================
--- /trunk/src/main/java/org/apache/rat/pd/core/PlagiarismDetector.java Fri
Aug 21 17:04:14 2009
+++ /trunk/src/main/java/org/apache/rat/pd/core/PlagiarismDetector.java Sat
Aug 22 15:21:34 2009
@@ -86,7 +86,7 @@
public class PlagiarismDetector {

// stream for printing current information
- private static PrintStream out;
+ private PrintStream out;

/**
* @param args
@@ -103,7 +103,7 @@
System.exit(1);
}
// stream for printing current information
- out = pd.getProperPrintStream(pdCommandLine);
+ pd.out = pd.getProperPrintStream(pdCommandLine);
// we add all rules we are interested in
final List<IHeuristicChecker> algorithmsForChecking =
pd.configureHeuristicCheckers(pdCommandLine);
// making one or more parsers
@@ -117,7 +117,7 @@

// analyzer is sliding-window checker
final SourceCodeAnalyser analyser = new
SourceCodeAnalyser(searchEngines, algorithmsForChecking,
- reportDocument, out);
+ reportDocument, pd.out);

final PlagiarismDetectorReport plagiarismDetectorReport = new
PlagiarismDetectorReport(analyser);

@@ -176,7 +176,7 @@

for (String heuristicChecker : pdCommandLine.getHeuristics()) {
if (heuristicChecker.equals("BruteForceHeuristicChecker")) {
- toRet.add(new
BruteForceHeuristicChecker(IHeuristicChecker.ALL_LANGUAGES));
+ toRet.add(new
BruteForceHeuristicChecker(pdCommandLine.getLanguage()));
}
// ///////////////////////////////////////////////////
// Comment heuristic checkers
@@ -250,7 +250,7 @@
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));
+ toRet.add(new MisspellingsHeuristicChecker(dictionary,
pdCommandLine.getLanguage(), out));
}

else {
@@ -261,7 +261,7 @@
}

/**
- * @param raportName file name
+ * @param reportName file name
* @param reportContent content of report file
*/
private void saveReport(String raportName, String reportContent) {
@@ -301,7 +301,7 @@
*/
private String getLanguage(PdCommandLine commandLine,
List<IHeuristicChecker> algorithmsForChecking) {
String toRet = IHeuristicChecker.ALL_LANGUAGES;
- if (commandLine.getLanguage() != null) {
+ if
(!commandLine.getLanguage().equals(IHeuristicChecker.ALL_LANGUAGES)) {
toRet = commandLine.getLanguage();
} else {
toRet = getLanguageFromHeuristic(algorithmsForChecking);

Reply all
Reply to author
Forward
0 new messages