Просмотр исходного кода

Revert "Removed wildcard imports."

This reverts commit 7d10fcd6116b0202ef97be958b1a96482d28279f.
Dominik Fuchß 4 лет назад
Родитель
Сommit
6abaf6cb35
50 измененных файлов с 1141 добавлено и 1904 удалено
  1. 1 29
      jplag.cli/src/main/java/de/jplag/CLI.java
  2. 1 3
      jplag.cli/src/test/java/de/jplag/cli/MinTokenMatchTest.java
  3. 1 2
      jplag.frontend.csharp-6/src/main/java/de/jplag/csharp/grammar/CSharpLexerBase.java
  4. 1 20
      jplag.frontend.csharp-6/src/test/java/de/jplag/csharp/MinimalCSharpFrontendTest.java
  5. 1 54
      jplag.frontend.kotlin/src/main/java/de/jplag/kotlin/JPlagKotlinListener.java
  6. 1 56
      jplag.frontend.kotlin/src/main/java/de/jplag/kotlin/KotlinToken.java
  7. 1 1
      jplag.frontend.rlang/src/main/java/de/jplag/rlang/JplagRListener.java
  8. 1 4
      jplag.frontend.rlang/src/main/java/de/jplag/rlang/RCombinedBaseListener.java
  9. 1 2
      jplag.frontend.rlang/src/test/java/de/jplag/rlang/RFrontendTest.java
  10. 1 10
      jplag/src/main/java/de/jplag/SubmissionSetBuilder.java
  11. 1 7
      jplag/src/main/java/de/jplag/clustering/ClusteringResult.java
  12. 1 6
      jplag/src/main/java/de/jplag/clustering/algorithm/AgglomerativeClustering.java
  13. 2 10
      jplag/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java
  14. 2 10
      jplag/src/main/java/de/jplag/strategy/ParallelComparisonStrategy.java
  15. 1 3
      jplag/src/test/java/de/jplag/InvalidSubmissionTest.java
  16. 1 5
      jplag/src/test/java/de/jplag/clustering/preprocessors/PreprocessingTestBase.java
  17. 1 3
      jplag/src/test/java/de/jplag/reporting/reportobject/mapper/MetricMapperTest.java
  18. 2 2
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java10.java
  19. 3 2
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java12.java
  20. 5 7
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java16.java
  21. 39 39
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17.java
  22. 32 32
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17Preview.java
  23. 2 2
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java10.java
  24. 3 2
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java12.java
  25. 2 5
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java14.java
  26. 5 7
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java16.java
  27. 39 39
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17.java
  28. 32 32
      jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17Preview.java
  29. 243 241
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/GSTiling.java
  30. 42 51
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/Match.java
  31. 48 48
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/Matches.java
  32. 2 136
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/Table.java
  33. 43 53
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/Token.java
  34. 6 5
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/TokenConstants.java
  35. 2 136
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/B/Table.java
  36. 43 53
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/B/Token.java
  37. 6 5
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/B/TokenConstants.java
  38. 243 241
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/GSTiling.java
  39. 42 51
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/Match.java
  40. 48 48
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/Matches.java
  41. 2 136
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/Table.java
  42. 43 53
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/Token.java
  43. 6 5
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/TokenConstants.java
  44. 42 51
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/Match.java
  45. 48 48
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/Matches.java
  46. 2 93
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/Table.java
  47. 38 48
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/Token.java
  48. 7 6
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/TokenConstants.java
  49. 1 1
      jplag/src/test/resources/de/jplag/samples/SimpleDuplicate/A/SimpleDuplicate.java
  50. 1 1
      jplag/src/test/resources/de/jplag/samples/SimpleDuplicate/B/SimpleDuplicate.java

+ 1 - 29
jplag.cli/src/main/java/de/jplag/CLI.java

@@ -1,34 +1,6 @@
 package de.jplag;
 
-import static de.jplag.CommandLineArgument.BASE_CODE;
-import static de.jplag.CommandLineArgument.CLUSTER_AGGLOMERATIVE_INTER_CLUSTER_SIMILARITY;
-import static de.jplag.CommandLineArgument.CLUSTER_AGGLOMERATIVE_THRESHOLD;
-import static de.jplag.CommandLineArgument.CLUSTER_ALGORITHM;
-import static de.jplag.CommandLineArgument.CLUSTER_ENABLE;
-import static de.jplag.CommandLineArgument.CLUSTER_METRIC;
-import static de.jplag.CommandLineArgument.CLUSTER_PREPROCESSING_CDF;
-import static de.jplag.CommandLineArgument.CLUSTER_PREPROCESSING_NONE;
-import static de.jplag.CommandLineArgument.CLUSTER_PREPROCESSING_PERCENTILE;
-import static de.jplag.CommandLineArgument.CLUSTER_PREPROCESSING_THRESHOLD;
-import static de.jplag.CommandLineArgument.CLUSTER_SPECTRAL_BANDWIDTH;
-import static de.jplag.CommandLineArgument.CLUSTER_SPECTRAL_KMEANS_ITERATIONS;
-import static de.jplag.CommandLineArgument.CLUSTER_SPECTRAL_MAX_RUNS;
-import static de.jplag.CommandLineArgument.CLUSTER_SPECTRAL_MIN_RUNS;
-import static de.jplag.CommandLineArgument.CLUSTER_SPECTRAL_NOISE;
-import static de.jplag.CommandLineArgument.COMPARISON_MODE;
-import static de.jplag.CommandLineArgument.DEBUG;
-import static de.jplag.CommandLineArgument.EXCLUDE_FILE;
-import static de.jplag.CommandLineArgument.LANGUAGE;
-import static de.jplag.CommandLineArgument.MIN_TOKEN_MATCH;
-import static de.jplag.CommandLineArgument.NEW_DIRECTORY;
-import static de.jplag.CommandLineArgument.OLD_DIRECTORY;
-import static de.jplag.CommandLineArgument.RESULT_FOLDER;
-import static de.jplag.CommandLineArgument.ROOT_DIRECTORY;
-import static de.jplag.CommandLineArgument.SHOWN_COMPARISONS;
-import static de.jplag.CommandLineArgument.SIMILARITY_THRESHOLD;
-import static de.jplag.CommandLineArgument.SUBDIRECTORY;
-import static de.jplag.CommandLineArgument.SUFFIXES;
-import static de.jplag.CommandLineArgument.VERBOSITY;
+import static de.jplag.CommandLineArgument.*;
 
 import java.security.SecureRandom;
 import java.util.ArrayList;

+ 1 - 3
jplag.cli/src/test/java/de/jplag/cli/MinTokenMatchTest.java

@@ -1,9 +1,7 @@
 package de.jplag.cli;
 
 import static com.github.stefanbirkner.systemlambda.SystemLambda.catchSystemExit;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.junit.jupiter.api.Test;
 

+ 1 - 2
jplag.frontend.csharp-6/src/main/java/de/jplag/csharp/grammar/CSharpLexerBase.java

@@ -2,8 +2,7 @@ package de.jplag.csharp.grammar;
 
 import java.util.Stack;
 
-import org.antlr.v4.runtime.CharStream;
-import org.antlr.v4.runtime.Lexer;
+import org.antlr.v4.runtime.*;
 
 /**
  * This class was taken from <a href="https://github.com/antlr/grammars-v4/tree/master/csharp">antlr/grammars-v4</a>. It

+ 1 - 20
jplag.frontend.csharp-6/src/test/java/de/jplag/csharp/MinimalCSharpFrontendTest.java

@@ -1,25 +1,6 @@
 package de.jplag.csharp;
 
-import static de.jplag.csharp.CSharpTokenConstants.ACCESSORS_BEGIN;
-import static de.jplag.csharp.CSharpTokenConstants.ACCESSORS_END;
-import static de.jplag.csharp.CSharpTokenConstants.ACCESSOR_BEGIN;
-import static de.jplag.csharp.CSharpTokenConstants.ACCESSOR_END;
-import static de.jplag.csharp.CSharpTokenConstants.ASSIGNMENT;
-import static de.jplag.csharp.CSharpTokenConstants.CLASS;
-import static de.jplag.csharp.CSharpTokenConstants.CLASS_BEGIN;
-import static de.jplag.csharp.CSharpTokenConstants.CLASS_END;
-import static de.jplag.csharp.CSharpTokenConstants.CONSTRUCTOR;
-import static de.jplag.csharp.CSharpTokenConstants.FIELD;
-import static de.jplag.csharp.CSharpTokenConstants.IF;
-import static de.jplag.csharp.CSharpTokenConstants.IF_BEGIN;
-import static de.jplag.csharp.CSharpTokenConstants.IF_END;
-import static de.jplag.csharp.CSharpTokenConstants.INVOCATION;
-import static de.jplag.csharp.CSharpTokenConstants.LOCAL_VARIABLE;
-import static de.jplag.csharp.CSharpTokenConstants.METHOD;
-import static de.jplag.csharp.CSharpTokenConstants.METHOD_BEGIN;
-import static de.jplag.csharp.CSharpTokenConstants.METHOD_END;
-import static de.jplag.csharp.CSharpTokenConstants.PROPERTY;
-import static de.jplag.csharp.CSharpTokenConstants.RETURN;
+import static de.jplag.csharp.CSharpTokenConstants.*;
 import static java.util.stream.Collectors.toList;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;

+ 1 - 54
jplag.frontend.kotlin/src/main/java/de/jplag/kotlin/JPlagKotlinListener.java

@@ -1,59 +1,6 @@
 package de.jplag.kotlin;
 
-import static de.jplag.kotlin.KotlinTokenConstants.ASSIGNMENT;
-import static de.jplag.kotlin.KotlinTokenConstants.BREAK;
-import static de.jplag.kotlin.KotlinTokenConstants.CATCH;
-import static de.jplag.kotlin.KotlinTokenConstants.CATCH_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.CATCH_BODY_START;
-import static de.jplag.kotlin.KotlinTokenConstants.CLASS_BODY_BEGIN;
-import static de.jplag.kotlin.KotlinTokenConstants.CLASS_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.CLASS_DECLARATION;
-import static de.jplag.kotlin.KotlinTokenConstants.COMPANION_DECLARATION;
-import static de.jplag.kotlin.KotlinTokenConstants.CONSTRUCTOR;
-import static de.jplag.kotlin.KotlinTokenConstants.CONTINUE;
-import static de.jplag.kotlin.KotlinTokenConstants.CONTROL_STRUCTURE_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.CONTROL_STRUCTURE_BODY_START;
-import static de.jplag.kotlin.KotlinTokenConstants.CREATE_OBJECT;
-import static de.jplag.kotlin.KotlinTokenConstants.DO_WHILE_EXPRESSION_END;
-import static de.jplag.kotlin.KotlinTokenConstants.DO_WHILE_EXPRESSION_START;
-import static de.jplag.kotlin.KotlinTokenConstants.ENUM_CLASS_BODY_BEGIN;
-import static de.jplag.kotlin.KotlinTokenConstants.ENUM_CLASS_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.ENUM_ENTRY;
-import static de.jplag.kotlin.KotlinTokenConstants.FINALLY;
-import static de.jplag.kotlin.KotlinTokenConstants.FINALLY_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.FINALLY_BODY_START;
-import static de.jplag.kotlin.KotlinTokenConstants.FOR_EXPRESSION_BEGIN;
-import static de.jplag.kotlin.KotlinTokenConstants.FOR_EXPRESSION_END;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_BODY_BEGIN;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_INVOCATION;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_LITERAL_BEGIN;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_LITERAL_END;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_PARAMETER;
-import static de.jplag.kotlin.KotlinTokenConstants.GETTER;
-import static de.jplag.kotlin.KotlinTokenConstants.IF_EXPRESSION_END;
-import static de.jplag.kotlin.KotlinTokenConstants.IF_EXPRESSION_START;
-import static de.jplag.kotlin.KotlinTokenConstants.IMPORT;
-import static de.jplag.kotlin.KotlinTokenConstants.INITIALIZER;
-import static de.jplag.kotlin.KotlinTokenConstants.INITIALIZER_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.INITIALIZER_BODY_START;
-import static de.jplag.kotlin.KotlinTokenConstants.OBJECT_DECLARATION;
-import static de.jplag.kotlin.KotlinTokenConstants.PACKAGE;
-import static de.jplag.kotlin.KotlinTokenConstants.PROPERTY_DECLARATION;
-import static de.jplag.kotlin.KotlinTokenConstants.RETURN;
-import static de.jplag.kotlin.KotlinTokenConstants.SETTER;
-import static de.jplag.kotlin.KotlinTokenConstants.THROW;
-import static de.jplag.kotlin.KotlinTokenConstants.TRY_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.TRY_BODY_START;
-import static de.jplag.kotlin.KotlinTokenConstants.TRY_EXPRESSION;
-import static de.jplag.kotlin.KotlinTokenConstants.TYPE_PARAMETER;
-import static de.jplag.kotlin.KotlinTokenConstants.VARIABLE_DECLARATION;
-import static de.jplag.kotlin.KotlinTokenConstants.WHEN_CONDITION;
-import static de.jplag.kotlin.KotlinTokenConstants.WHEN_EXPRESSION_END;
-import static de.jplag.kotlin.KotlinTokenConstants.WHEN_EXPRESSION_START;
-import static de.jplag.kotlin.KotlinTokenConstants.WHILE_EXPRESSION_END;
-import static de.jplag.kotlin.KotlinTokenConstants.WHILE_EXPRESSION_START;
+import static de.jplag.kotlin.KotlinTokenConstants.*;
 
 import java.util.Optional;
 

+ 1 - 56
jplag.frontend.kotlin/src/main/java/de/jplag/kotlin/KotlinToken.java

@@ -1,61 +1,6 @@
 package de.jplag.kotlin;
 
-import static de.jplag.kotlin.KotlinTokenConstants.ASSIGNMENT;
-import static de.jplag.kotlin.KotlinTokenConstants.BREAK;
-import static de.jplag.kotlin.KotlinTokenConstants.CATCH;
-import static de.jplag.kotlin.KotlinTokenConstants.CATCH_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.CATCH_BODY_START;
-import static de.jplag.kotlin.KotlinTokenConstants.CLASS_BODY_BEGIN;
-import static de.jplag.kotlin.KotlinTokenConstants.CLASS_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.CLASS_DECLARATION;
-import static de.jplag.kotlin.KotlinTokenConstants.COMPANION_DECLARATION;
-import static de.jplag.kotlin.KotlinTokenConstants.CONSTRUCTOR;
-import static de.jplag.kotlin.KotlinTokenConstants.CONTINUE;
-import static de.jplag.kotlin.KotlinTokenConstants.CONTROL_STRUCTURE_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.CONTROL_STRUCTURE_BODY_START;
-import static de.jplag.kotlin.KotlinTokenConstants.CREATE_OBJECT;
-import static de.jplag.kotlin.KotlinTokenConstants.DO_WHILE_EXPRESSION_END;
-import static de.jplag.kotlin.KotlinTokenConstants.DO_WHILE_EXPRESSION_START;
-import static de.jplag.kotlin.KotlinTokenConstants.ENUM_CLASS_BODY_BEGIN;
-import static de.jplag.kotlin.KotlinTokenConstants.ENUM_CLASS_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.ENUM_ENTRY;
-import static de.jplag.kotlin.KotlinTokenConstants.FILE_END;
-import static de.jplag.kotlin.KotlinTokenConstants.FINALLY;
-import static de.jplag.kotlin.KotlinTokenConstants.FINALLY_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.FINALLY_BODY_START;
-import static de.jplag.kotlin.KotlinTokenConstants.FOR_EXPRESSION_BEGIN;
-import static de.jplag.kotlin.KotlinTokenConstants.FOR_EXPRESSION_END;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_BODY_BEGIN;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_INVOCATION;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_LITERAL_BEGIN;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_LITERAL_END;
-import static de.jplag.kotlin.KotlinTokenConstants.FUNCTION_PARAMETER;
-import static de.jplag.kotlin.KotlinTokenConstants.GETTER;
-import static de.jplag.kotlin.KotlinTokenConstants.IF_EXPRESSION_END;
-import static de.jplag.kotlin.KotlinTokenConstants.IF_EXPRESSION_START;
-import static de.jplag.kotlin.KotlinTokenConstants.IMPORT;
-import static de.jplag.kotlin.KotlinTokenConstants.INITIALIZER;
-import static de.jplag.kotlin.KotlinTokenConstants.INITIALIZER_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.INITIALIZER_BODY_START;
-import static de.jplag.kotlin.KotlinTokenConstants.OBJECT_DECLARATION;
-import static de.jplag.kotlin.KotlinTokenConstants.PACKAGE;
-import static de.jplag.kotlin.KotlinTokenConstants.PROPERTY_DECLARATION;
-import static de.jplag.kotlin.KotlinTokenConstants.RETURN;
-import static de.jplag.kotlin.KotlinTokenConstants.SEPARATOR_TOKEN;
-import static de.jplag.kotlin.KotlinTokenConstants.SETTER;
-import static de.jplag.kotlin.KotlinTokenConstants.THROW;
-import static de.jplag.kotlin.KotlinTokenConstants.TRY_BODY_END;
-import static de.jplag.kotlin.KotlinTokenConstants.TRY_BODY_START;
-import static de.jplag.kotlin.KotlinTokenConstants.TRY_EXPRESSION;
-import static de.jplag.kotlin.KotlinTokenConstants.TYPE_PARAMETER;
-import static de.jplag.kotlin.KotlinTokenConstants.VARIABLE_DECLARATION;
-import static de.jplag.kotlin.KotlinTokenConstants.WHEN_CONDITION;
-import static de.jplag.kotlin.KotlinTokenConstants.WHEN_EXPRESSION_END;
-import static de.jplag.kotlin.KotlinTokenConstants.WHEN_EXPRESSION_START;
-import static de.jplag.kotlin.KotlinTokenConstants.WHILE_EXPRESSION_END;
-import static de.jplag.kotlin.KotlinTokenConstants.WHILE_EXPRESSION_START;
+import static de.jplag.kotlin.KotlinTokenConstants.*;
 
 import de.jplag.Token;
 

+ 1 - 1
jplag.frontend.rlang/src/main/java/de/jplag/rlang/JplagRListener.java

@@ -2,7 +2,7 @@ package de.jplag.rlang;
 
 import org.antlr.v4.runtime.Token;
 
-import de.jplag.rlang.grammar.RParser;
+import de.jplag.rlang.grammar.*;
 
 /**
  * Listener class for visiting the R ANTLR parse tree. Transforms the visited ANTLR token into JPlag tokens. Based on an

+ 1 - 4
jplag.frontend.rlang/src/main/java/de/jplag/rlang/RCombinedBaseListener.java

@@ -4,10 +4,7 @@ import org.antlr.v4.runtime.ParserRuleContext;
 import org.antlr.v4.runtime.tree.ErrorNode;
 import org.antlr.v4.runtime.tree.TerminalNode;
 
-import de.jplag.rlang.grammar.RFilter;
-import de.jplag.rlang.grammar.RFilterListener;
-import de.jplag.rlang.grammar.RListener;
-import de.jplag.rlang.grammar.RParser;
+import de.jplag.rlang.grammar.*;
 
 /**
  * Empty base implementation for {@link RListener} and {@link RFilterListener}.

+ 1 - 2
jplag.frontend.rlang/src/test/java/de/jplag/rlang/RFrontendTest.java

@@ -3,8 +3,7 @@ package de.jplag.rlang;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.fail;
 
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.List;

+ 1 - 10
jplag/src/main/java/de/jplag/SubmissionSetBuilder.java

@@ -2,16 +2,7 @@ package de.jplag;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
+import java.util.*;
 import java.util.function.Function;
 
 import org.slf4j.Logger;

+ 1 - 7
jplag/src/main/java/de/jplag/clustering/ClusteringResult.java

@@ -1,12 +1,6 @@
 package de.jplag.clustering;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.function.BiFunction;
 import java.util.stream.DoubleStream;
 

+ 1 - 6
jplag/src/main/java/de/jplag/clustering/algorithm/AgglomerativeClustering.java

@@ -1,11 +1,6 @@
 package de.jplag.clustering.algorithm;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.PriorityQueue;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import org.apache.commons.math3.linear.RealMatrix;

+ 2 - 10
jplag/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java

@@ -13,19 +13,11 @@ import java.util.List;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import de.jplag.JPlagComparison;
-import de.jplag.JPlagResult;
-import de.jplag.Submission;
-import de.jplag.Token;
-import de.jplag.TokenList;
+import de.jplag.*;
 import de.jplag.reporting.reportobject.mapper.ClusteringResultMapper;
 import de.jplag.reporting.reportobject.mapper.MetricMapper;
-import de.jplag.reporting.reportobject.model.ComparisonReport;
-import de.jplag.reporting.reportobject.model.FilesOfSubmission;
-import de.jplag.reporting.reportobject.model.JPlagReport;
+import de.jplag.reporting.reportobject.model.*;
 import de.jplag.reporting.reportobject.model.Match;
-import de.jplag.reporting.reportobject.model.Metric;
-import de.jplag.reporting.reportobject.model.OverviewReport;
 
 /**
  * Factory class, responsible for converting a JPlagResult object to Overview and Comparison DTO classes.

+ 2 - 10
jplag/src/main/java/de/jplag/strategy/ParallelComparisonStrategy.java

@@ -3,22 +3,14 @@ package de.jplag.strategy;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import de.jplag.GreedyStringTiling;
-import de.jplag.JPlagComparison;
-import de.jplag.JPlagResult;
-import de.jplag.Submission;
-import de.jplag.SubmissionSet;
+import de.jplag.*;
 import de.jplag.options.JPlagOptions;
 
 /**

+ 1 - 3
jplag/src/test/java/de/jplag/InvalidSubmissionTest.java

@@ -1,8 +1,6 @@
 package de.jplag;
 
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.File;
 import java.nio.file.Path;

+ 1 - 5
jplag/src/test/java/de/jplag/clustering/preprocessors/PreprocessingTestBase.java

@@ -3,11 +3,7 @@ package de.jplag.clustering.preprocessors;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 import java.util.function.BiConsumer;
 import java.util.function.IntUnaryOperator;
 import java.util.stream.Collectors;

+ 1 - 3
jplag/src/test/java/de/jplag/reporting/reportobject/mapper/MetricMapperTest.java

@@ -1,8 +1,6 @@
 package de.jplag.reporting.reportobject.mapper;
 
-import static org.mockito.Mockito.anyInt;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.*;
 
 import java.util.ArrayList;
 import java.util.List;

+ 2 - 2
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java10.java

@@ -3,9 +3,9 @@ import java.util.List;
 import java.util.Optional;
 
 public class Java10 {
-
+    
     List<Optional<String>> test;
-
+    
     public Java10() {
         // Var type for local variables (JEP 286):
         test = new ArrayList<>();

+ 3 - 2
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java12.java

@@ -7,9 +7,10 @@ public class Java12 { // Java 12 has no new relevant structural features
         String text = "ABCD";
         text.indent(5);
         text.transform(it -> it + "!");
-
+        
         // Compact number format:
-        NumberFormat fmt = NumberFormat.getCompactNumberInstance(new Locale("hi", "IN"), NumberFormat.Style.SHORT);
+        NumberFormat fmt = NumberFormat.getCompactNumberInstance(
+                new Locale("hi", "IN"), NumberFormat.Style.SHORT);
         String result = fmt.format(1000);
         System.out.println(result);
     }

+ 5 - 7
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java16.java

@@ -1,24 +1,22 @@
 
 public class Java16 {
     public static void main(String[] args) {
-        // Text blocks (JEP 378):
+        // Text blocks (JEP 378): 
         String query = """
                 SELECT "EMP_ID", "LAST_NAME"
                 FROM "EMPLOYEE_TB";
                 """;
         System.out.println(query);
-
+        
         // Pattern matching for instanceof (JEP 394):
         String x = "123";
-        if (x instanceof String s) {
-            String a = s;
-        }
-
+        if (x instanceof String s) { String a = s; }
+        
         // Record types (JEP 395):
         Point p = new Point(1, 2);
         System.out.println(p.add());
     }
-
+    
     record Point(int x, int y) {
         public int add() {
             return x + y;

+ 39 - 39
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17.java

@@ -1,42 +1,42 @@
 public class Java17 {
 
-    public Java17() {
-        Shape s = Math.random() > 0.5 ? new Circle(42) : new Rect(1, 4);
-        Shape c = new Circle(432);
-        Shape r = new Rect(1, 2);
-        double area = s.area() + c.area() + r.area();
-        System.out.println(area);
-    }
-
-    private abstract static sealed class Shape permits Circle,Rect {
-        public abstract double area();
-    }
-
-    private static final class Circle extends Shape {
-        private double r;
-
-        private Circle(double r) {
-            this.r = r;
-        }
-
-        @Override
-        public double area() {
-            return 2 * Math.PI * r * r;
-        }
-    }
-
-    private static final class Rect extends Shape {
-        private final int a;
-        private final int b;
-
-        private Rect(int a, int b) {
-            this.a = a;
-            this.b = b;
-        }
-
-        @Override
-        public double area() {
-            return a * b;
-        }
-    }
+	public Java17() {
+		Shape s = Math.random() > 0.5 ? new Circle(42) : new Rect(1, 4);
+		Shape c = new Circle(432);
+		Shape r = new Rect(1, 2);
+		double area = s.area() + c.area() + r.area();
+		System.out.println(area);
+	}
+
+	private abstract static sealed class Shape permits Circle, Rect {
+		public abstract double area();
+	}
+
+	private static final class Circle extends Shape {
+		private double r;
+
+		private Circle(double r) {
+			this.r = r;
+		}
+
+		@Override
+		public double area() {
+			return 2 * Math.PI * r * r;
+		}
+	}
+
+	private static final class Rect extends Shape {
+		private final int a;
+		private final int b;
+
+		private Rect(int a, int b) {
+			this.a = a;
+			this.b = b;
+		}
+
+		@Override
+		public double area() {
+			return a * b;
+		}
+	}
 }

+ 32 - 32
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/A/Java17Preview.java

@@ -1,6 +1,6 @@
 public class Java17Preview {
 
-    public Java17Preview() {
+	public Java17Preview() {
 		Shape s = Math.random() > 0.5 ? new Circle(42) : new Rect(1, 4);
 		double area = switch (s) {
 			case Circle c -> c.area() + 0.123;
@@ -10,35 +10,35 @@ public class Java17Preview {
 		System.out.println(area);
 	}
 
-    private abstract static sealed class Shape permits Circle,Rect {
-        public abstract double area();
-    }
-
-    private static final class Circle extends Shape {
-        private double r;
-
-        private Circle(double r) {
-            this.r = r;
-        }
-
-        @Override
-        public double area() {
-            return 2 * Math.PI * r * r;
-        }
-    }
-
-    private static final class Rect extends Shape {
-        private final int a;
-        private final int b;
-
-        private Rect(int a, int b) {
-            this.a = a;
-            this.b = b;
-        }
-
-        @Override
-        public double area() {
-            return a * b;
-        }
-    }
+	private abstract static sealed class Shape permits Circle, Rect {
+		public abstract double area();
+	}
+
+	private static final class Circle extends Shape {
+		private double r;
+
+		private Circle(double r) {
+			this.r = r;
+		}
+
+		@Override
+		public double area() {
+			return 2 * Math.PI * r * r;
+		}
+	}
+
+	private static final class Rect extends Shape {
+		private final int a;
+		private final int b;
+
+		private Rect(int a, int b) {
+			this.a = a;
+			this.b = b;
+		}
+
+		@Override
+		public double area() {
+			return a * b;
+		}
+	}
 }

+ 2 - 2
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java10.java

@@ -3,9 +3,9 @@ import java.util.List;
 import java.util.Optional;
 
 public class Java10 {
-
+    
     List<Optional<String>> test;
-
+    
     public Java10() {
         // Typed variables as usual:
         test = new ArrayList<>();

+ 3 - 2
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java12.java

@@ -7,9 +7,10 @@ public class Java12 { // Java 12 has no new relevant structural features
         String text = "ABCD";
         text.indent(2);
         text.transform(it -> it + "?");
-
+        
         // Compact number format:
-        NumberFormat fmt = NumberFormat.getCompactNumberInstance(new Locale("hi", "IN"), NumberFormat.Style.SHORT);
+        NumberFormat fmt = NumberFormat.getCompactNumberInstance(
+                new Locale("hi", "IN"), NumberFormat.Style.SHORT);
         String result = fmt.format(1000);
         System.out.println(result);
     }

+ 2 - 5
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java14.java

@@ -10,11 +10,8 @@ public enum Java14 {
         boolean isWeekend;
         switch (MONDAY) {
             case SATURDAY:
-            case SUNDAY:
-                isWeekend = true;
-                break;
-            default:
-                isWeekend = false;
+            case SUNDAY: isWeekend = true; break;
+            default: isWeekend = false;
         }
         System.out.println(isWeekend);
     }

+ 5 - 7
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java16.java

@@ -1,24 +1,22 @@
 
 public class Java16 {
     public static void main(String[] args) {
-        // Text blocks (JEP 378):
+        // Text blocks (JEP 378): 
         String query = """
                 SELECT "EMPLOYEE_ID", "NAME"
                 FROM "EMPLOYEE_TABLE";
                 """;
         System.out.println(query);
-
+        
         // Pattern matching for instanceof (JEP 394):
         String x = "123";
-        if (x instanceof String text) {
-            String answer = text;
-        }
-
+        if (x instanceof String text) { String answer = text; }
+        
         // Record types (JEP 395):
         Point q = new Point(1, 2);
         System.out.println(q.add());
     }
-
+    
     record Point(int x, int y) {
         public int add() {
             return y + x;

+ 39 - 39
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17.java

@@ -1,42 +1,42 @@
 public class Java17 {
 
-    public Java17() {
-        Shape s = Math.random() > 0.6 ? new Circle(5435) : new Rect(54, 4);
-        Shape c = new Circle(43425);
-        Shape r = new Rect(14, 21);
-        double area = s.area() + c.area() + r.area();
-        System.out.println(area);
-    }
-
-    private abstract static sealed class Shape permits Circle,Rect {
-        public abstract double area();
-    }
-
-    private static final class Circle extends Shape {
-        private double r;
-
-        private Circle(double r) {
-            this.r = r;
-        }
-
-        @Override
-        public double area() {
-            return 2 * Math.PI * r * r;
-        }
-    }
-
-    private static final class Rect extends Shape {
-        private final int a;
-        private final int b;
-
-        private Rect(int a, int b) {
-            this.a = a;
-            this.b = b;
-        }
-
-        @Override
-        public double area() {
-            return a * b;
-        }
-    }
+	public Java17() {
+		Shape s = Math.random() > 0.6 ? new Circle(5435) : new Rect(54, 4);
+		Shape c = new Circle(43425);
+		Shape r = new Rect(14, 21);
+		double area = s.area() + c.area() + r.area();
+		System.out.println(area);
+	}
+
+	private abstract static sealed class Shape permits Circle, Rect {
+		public abstract double area();
+	}
+
+	private static final class Circle extends Shape {
+		private double r;
+
+		private Circle(double r) {
+			this.r = r;
+		}
+
+		@Override
+		public double area() {
+			return 2 * Math.PI * r * r;
+		}
+	}
+
+	private static final class Rect extends Shape {
+		private final int a;
+		private final int b;
+
+		private Rect(int a, int b) {
+			this.a = a;
+			this.b = b;
+		}
+
+		@Override
+		public double area() {
+			return a * b;
+		}
+	}
 }

+ 32 - 32
jplag/src/test/resources/de/jplag/samples/NewJavaFeatures/B/Java17Preview.java

@@ -1,6 +1,6 @@
 public class Java17Preview {
 
-    public Java17Preview() {
+	public Java17Preview() {
 		Shape s = Math.random() > 0.5 ? new Circle(24) : new Rect(5, 1);
 		double area = switch (s) {
 			case Circle c -> c.area() + 2.345;
@@ -10,35 +10,35 @@ public class Java17Preview {
 		System.out.println(area);
 	}
 
-    private abstract static sealed class Shape permits Circle,Rect {
-        public abstract double area();
-    }
-
-    private static final class Circle extends Shape {
-        private double r;
-
-        private Circle(double r) {
-            this.r = r;
-        }
-
-        @Override
-        public double area() {
-            return 2 * Math.PI * r * r;
-        }
-    }
-
-    private static final class Rect extends Shape {
-        private final int a;
-        private final int b;
-
-        private Rect(int a, int b) {
-            this.a = a;
-            this.b = b;
-        }
-
-        @Override
-        public double area() {
-            return a * b;
-        }
-    }
+	private abstract static sealed class Shape permits Circle, Rect {
+		public abstract double area();
+	}
+
+	private static final class Circle extends Shape {
+		private double r;
+
+		private Circle(double r) {
+			this.r = r;
+		}
+
+		@Override
+		public double area() {
+			return 2 * Math.PI * r * r;
+		}
+	}
+
+	private static final class Rect extends Shape {
+		private final int a;
+		private final int b;
+
+		private Rect(int a, int b) {
+			this.a = a;
+			this.b = b;
+		}
+
+		@Override
+		public double area() {
+			return a * b;
+		}
+	}
 }

+ 243 - 241
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/GSTiling.java

@@ -1,245 +1,247 @@
 /*
- * Diese Klasse implementiert den GSTiling Algorithmus Allerdings ist sie sehr spezifisch auf die Klassen "Structure",
- * "Token", sowie "Matches" und "Match" ausgelegt
+ * Diese Klasse implementiert den GSTiling Algorithmus
+ * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token",
+ * sowie "Matches" und "Match" ausgelegt
  */
 public class GSTiling implements TokenConstants {
-    private Matches matches = new Matches();
-
-    /*
-     * creating hashes. The hash-code will be written in every Token for the next <hash_length> token. (includes the Token
-     * itself) Das Ganze laeuft in linearer Zeit. condition: 1 < hashLength < 26 !!!
-     */
-
-    public void create_hashes(Structure s, int hashLength, boolean makeTable) {
-        // Hier wird die obere Grenze der Hash-Laenge festgelegt.
-        // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl
-        // der Token.
-        if (hashLength < 1)
-            hashLength = 1;
-        hashLength = (hashLength < 26 ? hashLength : 25);
-
-        if (s.size() < hashLength)
-            return;
-
-        int modulo = ((1 << 6) - 1);   // Modulo 64!
-
-        int loops = s.size() - hashLength;
-        s.table = (makeTable ? new Table(3 * loops) : null);
-        int hash = 0;
-        int i;
-        int hashedLength = 0;
-        for (i = 0; i < hashLength; i++) {
-            hash = (2 * hash) + (s.tokens[i].type & modulo);
-            hashedLength++;
-            if (s.tokens[i].marked)
-                hashedLength = 0;
-        }
-        int factor = (hashLength != 1 ? (2 << (hashLength - 2)) : 1);
-
-        if (makeTable) {
-            for (i = 0; i < loops; i++) {
-                if (hashedLength >= hashLength) {
-                    s.tokens[i].hash = hash;
-                    s.table.add(hash, i);   // add into hashtable
-                } else
-                    s.tokens[i].hash = -1;
-                hash -= factor * (s.tokens[i].type & modulo);
-                hash = (2 * hash) + (s.tokens[i + hashLength].type & modulo);
-                if (s.tokens[i + hashLength].marked)
-                    hashedLength = 0;
-                else
-                    hashedLength++;
-            }
-        } else {
-            for (i = 0; i < loops; i++) {
-                s.tokens[i].hash = (hashedLength >= hashLength) ? hash : -1;
-                hash -= factor * (s.tokens[i].type & modulo);
-                hash = (2 * hash) + (s.tokens[i + hashLength].type & modulo);
-                if (s.tokens[i + hashLength].marked)
-                    hashedLength = 0;
-                else
-                    hashedLength++;
-            }
-        }
-        s.hash_length = hashLength;
-    }
-
-    public final void compare(Submission subA, Submission subB) {
-        Submission A, B, tmp;
-        if (subA.struct.size() > subB.struct.size()) {
-            A = subB;
-            B = subA;
-        } else {
-            A = subB;
-            B = subA;
-        }
-        // if hashtable exists in first but not in second structure: flip around!
-        if (B.struct.table == null && A.struct.table != null) {
-            tmp = A;
-            A = B;
-            B = tmp;
-        }
-    }
-
-    // first parameter should contain the smaller sequence!!!
-    private final void compare(Submission subA, Submission subB, int mml) {
-        Structure structA = subA.struct;
-        Structure structB = subB.struct;
-
-        // FILE_END used as pivot
-
-        // init
-        Token[] A = structA.tokens;
-        Token[] B = structB.tokens;
-        int lengthA = structA.size() - 1;  // minus pivots!
-        int lengthB = structB.size() - 1;  // minus pivots!
-
-        if (true) {
-            for (int i = 0; i <= lengthA; i++)
-                A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN;
-
-            for (int i = 0; i <= lengthB; i++)
-                B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN;
-        } else {
-            for (int i = 0; i <= lengthA; i++)
-                A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode;
-
-            for (int i = 0; i <= lengthB; i++)
-                B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode;
-        }
-
-        int maxmatch;
-        int[] elemsB;
-
-        do {
-            maxmatch = mml;
-            matches.clear();
-            for (int x = 0; x <= lengthA - maxmatch; x++) {
-                if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null)
-                    continue;
-                inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array
-                    int y = elemsB[i];
-                    if (B[y].marked || maxmatch > lengthB - y)
-                        continue;
-
-                    int j, hx, hy;
-                    for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind
-                        if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked)
-                            continue inner;
-                    }
-
-                    // expand match
-                    j = maxmatch;
-                    while (A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked)
-                        j++;
-
-                    if (j > maxmatch) {  // new biggest match? -> delete current smaller
-                        matches.clear();
-                        maxmatch = j;
-                    }
-                    matches.addMatch(x, y, j);  // add match
-                }
-            }
-            for (int i = matches.size() - 1; i >= 0; i--) {
-                int x = matches.matches[i].startA;  // begining of sequence A
-                int y = matches.matches[i].startB;  // begining of sequence B
-
-                // in order that "Match" will be newly build (because reusing)
-                for (int j = matches.matches[i].length; j > 0; j--)
-                    A[x++].marked = B[y++].marked = true;   // mark all Token!
-            }
-
-        } while (maxmatch != mml);
-    }
-
-    public final void compareWithBasecode(Submission subA, Submission subB) {
-        Submission A, B, tmp;
-        if (subA.struct.size() > subB.struct.size()) {
-            A = subB;
-            B = subA;
-        } else {
-            A = subB;
-            B = subA;
-        }
-        // if hashtable exists in first but not in second structure: flip around!
-        if (B.struct.table == null && A.struct.table != null) {
-            tmp = A;
-            A = B;
-            B = tmp;
-        }
-    }
-
-    private final void compareWithBasecode(Submission subA, Submission subB, int mml) {
-        Structure structA = subA.struct;
-        Structure structB = subB.struct;
-
-        // FILE_END used as pivot
-
-        // init
-        Token[] A = structA.tokens;
-        Token[] B = structB.tokens;
-        int lengthA = structA.size() - 1;  // minus pivots!
-        int lengthB = structB.size() - 1;  // minus pivots!
-
-        // Initialize
-        for (int i = 0; i <= lengthA; i++)
-            A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN;
-
-        for (int i = 0; i <= lengthB; i++)
-            B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN;
-
-        int maxmatch;
-        int[] elemsB;
-
-        do {
-            maxmatch = mml;
-            matches.clear();
-            for (int x = 0; x <= lengthA - maxmatch; x++) {
-                if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null)
-                    continue;
-                inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array
-                    int y = elemsB[i];
-                    if (B[y].marked || maxmatch > lengthB - y)
-                        continue;
-
-                    int j, hx, hy;
-                    for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind
-                        if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked)
-                            continue inner;
-                    }
-                    // expand match
-                    j = maxmatch;
-                    while (A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked)
-                        j++;
-
-                    if (j != maxmatch) {  // new biggest match? -> delete current smaller
-                        matches.clear();
-                        maxmatch = j;
-                    }
-                    matches.addMatch(x, y, j);  // add match
-                }
-            }
-            for (int i = matches.size() - 1; i >= 0; i--) {
-                int x = matches.matches[i].startA;  // beginning in sequence A
-                int y = matches.matches[i].startB;  // beginning in sequence B
-
-                // in order that "Match" will be newly build (because reusing)
-                for (int j = matches.matches[i].length; j > 0; j--) {
-                    A[x].marked = B[y].marked = true;   // mark all Token!
-                    A[x].basecode = B[y].basecode = true;
-                    x++;
-                    y++;
-                }
-            }
-        } while (maxmatch != mml);
-
-    }
-
-    public void resetBaseSubmission(Submission sub) {
-        Structure tmpStruct = sub.struct;
-        Token[] tok = tmpStruct.tokens;
-        for (int z = 0; z < tmpStruct.size() - 1; z++) {
-            tok[z].basecode = false;
-        }
-    }
+	private Matches matches = new Matches();
+
+	/*
+	 * creating hashes.
+	 * The hash-code will be written in every Token for the next <hash_length> token.
+	 * (includes the Token itself)
+	 * Das Ganze laeuft in linearer Zeit.
+	 * condition: 1 < hashLength < 26   !!!
+	 */
+
+	public void create_hashes(Structure s, int hashLength, boolean makeTable) {
+		// Hier wird die obere Grenze der Hash-Laenge festgelegt.
+		// Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl
+		// der Token.
+		if (hashLength<1) hashLength = 1;
+		hashLength = (hashLength<26 ? hashLength : 25);
+
+		if (s.size()<hashLength) return;
+
+		int modulo = ((1 << 6) - 1);   // Modulo 64!
+
+		int loops = s.size()-hashLength;
+		s.table = (makeTable ? new Table(3*loops) : null);
+		int hash = 0;
+		int i;
+		int hashedLength = 0;
+		for (i=0; i<hashLength; i++) {
+			hash = (2*hash) + (s.tokens[i].type & modulo);
+			hashedLength++;
+			if (s.tokens[i].marked)
+				hashedLength = 0;
+		}
+		int factor = (hashLength != 1 ? (2<<(hashLength-2)) : 1);
+
+		if (makeTable) {
+			for (i=0; i<loops; i++) {
+				if (hashedLength >= hashLength) {
+					s.tokens[i].hash = hash;
+					s.table.add(hash, i);   // add into hashtable
+				} else
+					s.tokens[i].hash = -1;
+				hash -= factor * (s.tokens[i].type & modulo);
+				hash = (2*hash) + (s.tokens[i+hashLength].type & modulo);
+				if (s.tokens[i+hashLength].marked)
+					hashedLength = 0;
+				else
+					hashedLength++;
+			}
+		} else {
+			for (i=0; i<loops; i++) {
+				s.tokens[i].hash = (hashedLength >= hashLength) ? hash : -1;
+				hash -= factor * (s.tokens[i].type & modulo);
+				hash = (2*hash) + (s.tokens[i+hashLength].type & modulo);
+				if (s.tokens[i+hashLength].marked)
+					hashedLength = 0;
+				else
+					hashedLength++;
+			}
+		}
+		s.hash_length = hashLength;
+	}
+
+	public final void compare(Submission subA, Submission subB) {
+		Submission A, B, tmp;
+		if (subA.struct.size() > subB.struct.size()) {
+			A = subB;  B = subA;
+		} else {
+			A = subB;  B = subA;
+		}
+		// if hashtable exists in first but not in second structure: flip around!
+		if (B.struct.table == null && A.struct.table != null) {
+			tmp = A;
+			A = B;
+			B = tmp;
+		}
+	}
+
+	// first parameter should contain the smaller sequence!!! 
+	private final void compare(Submission subA, Submission subB, int mml) {
+		Structure structA = subA.struct;
+		Structure structB = subB.struct;
+
+		// FILE_END used as pivot
+
+		// init
+		Token[] A = structA.tokens;
+		Token[] B = structB.tokens;
+		int lengthA = structA.size()-1;  // minus pivots!
+		int lengthB = structB.size()-1;  // minus pivots!
+
+
+		if(true) {
+			for(int i = 0; i <= lengthA; i++)
+				A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN;
+
+			for(int i = 0; i <= lengthB; i++)
+				B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN;
+		} else {
+			for(int i = 0; i <= lengthA; i++)
+				A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode;
+
+			for(int i = 0; i <= lengthB; i++)
+				B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode;
+		}
+
+
+		int maxmatch;
+		int[] elemsB;
+
+		do {
+			maxmatch = mml;
+			matches.clear();
+			for (int x = 0; x <= lengthA - maxmatch; x++) {
+				if (A[x].marked || A[x].hash == -1
+						|| (elemsB = structB.table.get(A[x].hash)) == null)
+					continue;
+inner:			for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array
+					int y = elemsB[i];
+					if (B[y].marked || maxmatch > lengthB - y) continue;
+
+					int j, hx, hy;
+					for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind
+						if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked)
+							continue inner;
+					}
+
+					// expand match
+					j = maxmatch;
+					while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked)
+						j++;
+
+					if (j > maxmatch) {  // new biggest match? -> delete current smaller
+						matches.clear();
+						maxmatch = j;
+					}
+					matches.addMatch(x, y, j);  // add match
+				}
+			}
+			for (int i = matches.size() - 1; i >= 0; i--) {
+				int x = matches.matches[i].startA;  // begining of sequence A
+				int y = matches.matches[i].startB;  // begining of sequence B
+
+				//in order that "Match" will be newly build     (because reusing)
+				for (int j = matches.matches[i].length; j > 0; j--)
+					A[x++].marked = B[y++].marked = true;   // mark all Token!
+			}
+
+		} while (maxmatch != mml);
+	}
+
+	public final void compareWithBasecode(Submission subA, Submission subB) {
+		Submission A, B, tmp;
+		if (subA.struct.size() > subB.struct.size()) {
+			A = subB;  B = subA;
+		} else {
+			A = subB;  B = subA;
+		}
+		// if hashtable exists in first but not in second structure: flip around!
+		if (B.struct.table == null && A.struct.table != null) {
+			tmp = A;
+			A = B;
+			B = tmp;
+		}
+	}
+
+	private final void compareWithBasecode(Submission subA, Submission subB, int mml) {
+		Structure structA = subA.struct;
+		Structure structB = subB.struct;
+
+		// FILE_END used as pivot
+
+		// init
+		Token[] A = structA.tokens;
+		Token[] B = structB.tokens;
+		int lengthA = structA.size()-1;  // minus pivots!
+		int lengthB = structB.size()-1;  // minus pivots!
+
+
+		// Initialize
+		for(int i = 0; i <= lengthA; i++)
+			A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN;
+
+		for(int i = 0; i <= lengthB; i++)
+			B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN;
+
+
+
+
+		int maxmatch;
+		int[] elemsB;
+
+		do {
+			maxmatch = mml;
+			matches.clear();
+			for (int x = 0; x <= lengthA - maxmatch; x++) {
+				if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null)
+					continue;
+inner:			for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array
+					int y = elemsB[i];
+					if (B[y].marked || maxmatch > lengthB - y) continue;
+
+					int j,hx,hy;
+					for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind
+						if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked)
+							continue inner;
+					}
+					// expand match
+					j = maxmatch;
+					while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked)
+						j++;
+
+					if (j != maxmatch) {  // new biggest match? -> delete current smaller
+						matches.clear();
+						maxmatch = j;
+					}
+					matches.addMatch(x, y, j);  // add match
+				}
+			}
+			for (int i = matches.size() - 1; i >= 0; i--) {
+				int x = matches.matches[i].startA;  // beginning in sequence A
+				int y = matches.matches[i].startB;  // beginning in sequence B
+
+				//in order that "Match" will be newly build     (because reusing)
+				for (int j = matches.matches[i].length; j > 0; j--){
+					A[x].marked = B[y].marked = true;   // mark all Token!
+					A[x].basecode = B[y].basecode= true;
+					x++; y++;
+				}
+			}
+		} while (maxmatch != mml);
+
+	}
+
+	public void resetBaseSubmission(Submission sub){
+		Structure tmpStruct = sub.struct;
+		Token[] tok = tmpStruct.tokens;
+		for (int z = 0; z < tmpStruct.size()-1;z++){
+			tok[z].basecode = false;
+		}
+	}
 }

+ 42 - 51
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/Match.java

@@ -1,61 +1,52 @@
 public class Match {
-    public int startA;
-    public int startB;
-    public int length;
+  public int startA;
+  public int startB;
+  public int length;
 
-    public Match(int startA, int startB, int length) {
-        this.startA = startA;
-        this.startB = startB;
-        this.length = length;
-    }
+  public Match(int startA, int startB, int length) {
+    this.startA = startA;
+    this.startB = startB;
+    this.length = length;
+  }
+  public Match() {}
 
-    public Match() {
-    }
+  public void set(int startA, int startB, int length) {
+    this.startA = startA;
+    this.startB = startB;
+    this.length = length;
+  }
 
-    public void set(int startA, int startB, int length) {
-        this.startA = startA;
-        this.startB = startB;
-        this.length = length;
-    }
+  public final boolean contains(int index, int sub) {
+    int start = (sub==0 ? startA : startB);
+    return (start <= index && index < (start+length));
+  }
 
-    public final boolean contains(int index, int sub) {
-        int start = (sub == 0 ? startA : startB);
-        return (start <= index && index < (start + length));
+  public final boolean overlap(Match other) {
+    if (startA < other.startA) {
+      if ((other.startA - startA) < length) return true;
+    } else {
+      if ((startA - other.startA) < other.length) return true;
     }
-
-    public final boolean overlap(Match other) {
-        if (startA < other.startA) {
-            if ((other.startA - startA) < length)
-                return true;
-        } else {
-            if ((startA - other.startA) < other.length)
-                return true;
-        }
-        if (startB < other.startB) {
-            if ((other.startB - startB) < length)
-                return true;
-        } else {
-            if ((startB - other.startB) < other.length)
-                return true;
-        }
-        return false;
+    if (startB < other.startB) {
+      if ((other.startB - startB) < length) return true;
+    } else {
+      if ((startB - other.startB) < other.length) return true;
     }
+    return false;
+  }
 
-    public final boolean overlap(int oStartA, int oStartB, int oLength) {
-        if (startA < oStartA) {
-            if ((oStartA - startA) < length)
-                return true;
-        } else {
-            if ((startA - oStartA) < oLength)
-                return true;
-        }
-        if (startB < oStartB) {
-            if ((oStartB - startB) < length)
-                return true;
-        } else {
-            if ((startB - oStartB) < oLength)
-                return true;
-        }
-        return false;
+  public final boolean overlap(int oStartA, int oStartB, int oLength) {
+    if (startA < oStartA) {
+      if ((oStartA - startA) < length) return true;
+    } else {
+      if ((startA - oStartA) < oLength) return true;
+    }
+    if (startB < oStartB) {
+      if ((oStartB - startB) < length) return true;
+    } else {
+      if ((startB - oStartB) < oLength) return true;
     }
+    return false;
+  }
 }
+

+ 48 - 48
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/Matches.java

@@ -1,57 +1,57 @@
-/*
- * Minimal class that stores "Match" objects.
+/* Minimal class that stores "Match" objects.
  */
 public class Matches {
-    public Match[] matches;
+  public Match[] matches;
 
-    private int anzahl;
-    private final int increment = 20;
+  private int anzahl;
+  private final int increment = 20;
+  
+  public Matches() {
+    matches = new Match[10];
+    for (int i=0; i<10; i++) matches[i] = new Match();
+    anzahl = 0;
+  }
 
-    public Matches() {
-        matches = new Match[10];
-        for (int i = 0; i < 10; i++)
-            matches[i] = new Match();
-        anzahl = 0;
-    }
+  public final int size() {
+    return anzahl;
+  }
 
-    public final int size() {
-        return anzahl;
+  public final void ensureCapacity(int minCapacity) {
+    int oldCapacity = matches.length;
+    if (minCapacity > oldCapacity) {
+      Match[] oldMatches = matches;
+      int newCapacity = (oldCapacity + increment);
+      if (newCapacity < minCapacity) {
+	newCapacity = minCapacity;
+      }
+      matches = new Match[newCapacity];
+      System.arraycopy(oldMatches, 0, matches, 0, oldCapacity);
+      for (int i=oldCapacity; i<newCapacity; i++)
+	matches[i] = new Match();
     }
-
-    public final void ensureCapacity(int minCapacity) {
-        int oldCapacity = matches.length;
-        if (minCapacity > oldCapacity) {
-            Match[] oldMatches = matches;
-            int newCapacity = (oldCapacity + increment);
-            if (newCapacity < minCapacity) {
-                newCapacity = minCapacity;
-            }
-            matches = new Match[newCapacity];
-            System.arraycopy(oldMatches, 0, matches, 0, oldCapacity);
-            for (int i = oldCapacity; i < newCapacity; i++)
-                matches[i] = new Match();
-        }
+  }
+  /*
+  public final void addMatch(Match match) {
+    for (int i=0; i<anzahl; i++)
+      if (match.overlap(matches[i])) return;  // do not allow overlaps
+    ensureCapacity(anzahl + 1);
+    matches[anzahl++] = match;
+  }
+  */
+  public final void addMatch(int startA, int startB, int length) {
+    for (int i=anzahl-1; i>=0; i--) { // starting at the end is better(?)
+      if (matches[i].overlap(startA,startB,length)) return;
+                                      // no overlaps!
     }
+    ensureCapacity(anzahl + 1);
+    //if (matches[anzahl] != null)  // object recycling...
+    matches[anzahl].set(startA,startB,length);
+    //else
+    //matches[anzahl ] = new Match(startA,startB,length);
+    anzahl++;
+  }
 
-    /*
-     * public final void addMatch(Match match) { for (int i=0; i<anzahl; i++) if (match.overlap(matches[i])) return; // do
-     * not allow overlaps ensureCapacity(anzahl + 1); matches[anzahl++] = match; }
-     */
-    public final void addMatch(int startA, int startB, int length) {
-        for (int i = anzahl - 1; i >= 0; i--) { // starting at the end is better(?)
-            if (matches[i].overlap(startA, startB, length))
-                return;
-            // no overlaps!
-        }
-        ensureCapacity(anzahl + 1);
-        // if (matches[anzahl] != null) // object recycling...
-        matches[anzahl].set(startA, startB, length);
-        // else
-        // matches[anzahl ] = new Match(startA,startB,length);
-        anzahl++;
-    }
-
-    public final void clear() {
-        anzahl = 0;
-    }
+  public final void clear() {
+    anzahl=0;
+  }
 }

Разница между файлами не показана из-за своего большого размера
+ 2 - 136
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/Table.java


+ 43 - 53
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/Token.java

@@ -1,57 +1,47 @@
 import java.io.Serializable;
 
 public abstract class Token implements TokenConstants, Serializable {
-    private static final long serialVersionUID = 862935679966383302L;
-    public int type;
-    public String file;
-
-    protected boolean marked;
-    protected boolean basecode = false;
-    protected int hash = -1;// hash-value. set and used by main algorithm (GSTiling)
-
-    public Token(int type, String file, int line) {
-        this(type, file, line, -1, -1);
-    }
-
-    public Token(int type, String file, int line, int column, int length) {
-        this.type = type;
-        this.file = file;
-        setLine(line > 0 ? line : 1);
-        setColumn(column);
-        setLength(length);
-    }
-
-    // abstract members
-    public abstract int getLine();
-
-    public abstract int getColumn();
-
-    public abstract int getLength();
-
-    protected void setLine(int line) {
-    }
-
-    protected void setColumn(int line) {
-    }
-
-    protected void setLength(int line) {
-    }
-
-    // this is made to distinguish the character front end.
-    // maybe other front ends can use it too?
-    protected int getIndex() {
-        return -1;
-    }
-
-    public static String type2string(int type) {
-        return "<abstract>";
-    }
-
-    public String toString() {
-        return type2string(type);
-    }
-
-    public static int numberOfTokens() {
-        return 1;
-    }
+	private static final long serialVersionUID = 862935679966383302L;
+	public int type;
+	public String file;
+	
+	protected boolean marked;
+	protected boolean basecode = false;
+	protected int hash = -1;// hash-value. set and used by main algorithm (GSTiling)
+	
+	public Token(int type, String file, int line) {
+		this(type, file, line, -1, -1);
+	}
+	
+	public Token(int type, String file, int line, int column, int length) {
+		this.type = type;
+		this.file = file;
+		setLine(line>0 ? line : 1);
+		setColumn(column);
+		setLength(length);
+	}
+	
+	// abstract members
+	public abstract int getLine();
+	public abstract int getColumn();
+	public abstract int getLength();
+	protected void setLine(int line) {}
+	protected void setColumn(int line) {}
+	protected void setLength(int line) {}
+	
+	// this is made to distinguish the character front end.
+	// maybe other front ends can use it too?
+	protected int getIndex() { return -1; }
+	
+	public static String type2string(int type) {
+		return "<abstract>";
+	}
+	
+	public String toString() {
+		return type2string(type);
+	}
+	
+	public static int numberOfTokens() { 
+		return 1;
+	} 
 }

+ 6 - 5
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/TokenConstants.java

@@ -1,7 +1,8 @@
 public interface TokenConstants {
-    final static int FILE_END = 0;
-    /**
-     * Used to optionally separate methods from each other with an always marked token
-     */
-    final static int SEPARATOR_TOKEN = 1;
+  final static int FILE_END = 0;
+	/**
+	 * Used to optionally separate methods from each other with an always marked
+	 * token
+	 */
+  final static int SEPARATOR_TOKEN = 1;
 }

Разница между файлами не показана из-за своего большого размера
+ 2 - 136
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/B/Table.java


+ 43 - 53
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/B/Token.java

@@ -1,57 +1,47 @@
 import java.io.Serializable;
 
 public abstract class Token implements TokenConstants, Serializable {
-    private static final long serialVersionUID = 862935679966383302L;
-    public int type;
-    public String file;
-
-    protected boolean marked;
-    protected boolean basecode = false;
-    protected int hash = -1;// hash-value. set and used by main algorithm (GSTiling)
-
-    public Token(int type, String file, int line) {
-        this(type, file, line, -1, -1);
-    }
-
-    public Token(int type, String file, int line, int column, int length) {
-        this.type = type;
-        this.file = file;
-        setLine(line > 0 ? line : 1);
-        setColumn(column);
-        setLength(length);
-    }
-
-    // abstract members
-    public abstract int getLine();
-
-    public abstract int getColumn();
-
-    public abstract int getLength();
-
-    protected void setLine(int line) {
-    }
-
-    protected void setColumn(int line) {
-    }
-
-    protected void setLength(int line) {
-    }
-
-    // this is made to distinguish the character front end.
-    // maybe other front ends can use it too?
-    protected int getIndex() {
-        return -1;
-    }
-
-    public static String type2string(int type) {
-        return "<abstract>";
-    }
-
-    public String toString() {
-        return type2string(type);
-    }
-
-    public static int numberOfTokens() {
-        return 1;
-    }
+	private static final long serialVersionUID = 862935679966383302L;
+	public int type;
+	public String file;
+	
+	protected boolean marked;
+	protected boolean basecode = false;
+	protected int hash = -1;// hash-value. set and used by main algorithm (GSTiling)
+	
+	public Token(int type, String file, int line) {
+		this(type, file, line, -1, -1);
+	}
+	
+	public Token(int type, String file, int line, int column, int length) {
+		this.type = type;
+		this.file = file;
+		setLine(line>0 ? line : 1);
+		setColumn(column);
+		setLength(length);
+	}
+	
+	// abstract members
+	public abstract int getLine();
+	public abstract int getColumn();
+	public abstract int getLength();
+	protected void setLine(int line) {}
+	protected void setColumn(int line) {}
+	protected void setLength(int line) {}
+	
+	// this is made to distinguish the character front end.
+	// maybe other front ends can use it too?
+	protected int getIndex() { return -1; }
+	
+	public static String type2string(int type) {
+		return "<abstract>";
+	}
+	
+	public String toString() {
+		return type2string(type);
+	}
+	
+	public static int numberOfTokens() { 
+		return 1;
+	} 
 }

+ 6 - 5
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/B/TokenConstants.java

@@ -1,7 +1,8 @@
 public interface TokenConstants {
-    final static int FILE_END = 0;
-    /**
-     * Used to optionally separate methods from each other with an always marked token
-     */
-    final static int SEPARATOR_TOKEN = 1;
+  final static int FILE_END = 0;
+	/**
+	 * Used to optionally separate methods from each other with an always marked
+	 * token
+	 */
+  final static int SEPARATOR_TOKEN = 1;
 }

+ 243 - 241
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/GSTiling.java

@@ -1,245 +1,247 @@
 /*
- * Diese Klasse implementiert den GSTiling Algorithmus Allerdings ist sie sehr spezifisch auf die Klassen "Structure",
- * "Token", sowie "Matches" und "Match" ausgelegt
+ * Diese Klasse implementiert den GSTiling Algorithmus
+ * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token",
+ * sowie "Matches" und "Match" ausgelegt
  */
 public class GSTiling implements TokenConstants {
-    private Matches matches = new Matches();
-
-    /*
-     * creating hashes. The hash-code will be written in every Token for the next <hash_length> token. (includes the Token
-     * itself) Das Ganze laeuft in linearer Zeit. condition: 1 < hashLength < 26 !!!
-     */
-
-    public void create_hashes(Structure s, int hashLength, boolean makeTable) {
-        // Hier wird die obere Grenze der Hash-Laenge festgelegt.
-        // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl
-        // der Token.
-        if (hashLength < 1)
-            hashLength = 1;
-        hashLength = (hashLength < 26 ? hashLength : 25);
-
-        if (s.size() < hashLength)
-            return;
-
-        int modulo = ((1 << 6) - 1);   // Modulo 64!
-
-        int loops = s.size() - hashLength;
-        s.table = (makeTable ? new Table(3 * loops) : null);
-        int hash = 0;
-        int i;
-        int hashedLength = 0;
-        for (i = 0; i < hashLength; i++) {
-            hash = (2 * hash) + (s.tokens[i].type & modulo);
-            hashedLength++;
-            if (s.tokens[i].marked)
-                hashedLength = 0;
-        }
-        int factor = (hashLength != 1 ? (2 << (hashLength - 2)) : 1);
-
-        if (makeTable) {
-            for (i = 0; i < loops; i++) {
-                if (hashedLength >= hashLength) {
-                    s.tokens[i].hash = hash;
-                    s.table.add(hash, i);   // add into hashtable
-                } else
-                    s.tokens[i].hash = -1;
-                hash -= factor * (s.tokens[i].type & modulo);
-                hash = (2 * hash) + (s.tokens[i + hashLength].type & modulo);
-                if (s.tokens[i + hashLength].marked)
-                    hashedLength = 0;
-                else
-                    hashedLength++;
-            }
-        } else {
-            for (i = 0; i < loops; i++) {
-                s.tokens[i].hash = (hashedLength >= hashLength) ? hash : -1;
-                hash -= factor * (s.tokens[i].type & modulo);
-                hash = (2 * hash) + (s.tokens[i + hashLength].type & modulo);
-                if (s.tokens[i + hashLength].marked)
-                    hashedLength = 0;
-                else
-                    hashedLength++;
-            }
-        }
-        s.hash_length = hashLength;
-    }
-
-    public final void compare(Submission subA, Submission subB) {
-        Submission A, B, tmp;
-        if (subA.struct.size() > subB.struct.size()) {
-            A = subB;
-            B = subA;
-        } else {
-            A = subB;
-            B = subA;
-        }
-        // if hashtable exists in first but not in second structure: flip around!
-        if (B.struct.table == null && A.struct.table != null) {
-            tmp = A;
-            A = B;
-            B = tmp;
-        }
-    }
-
-    // first parameter should contain the smaller sequence!!!
-    private final void compare(Submission subA, Submission subB, int mml) {
-        Structure structA = subA.struct;
-        Structure structB = subB.struct;
-
-        // FILE_END used as pivot
-
-        // init
-        Token[] A = structA.tokens;
-        Token[] B = structB.tokens;
-        int lengthA = structA.size() - 1;  // minus pivots!
-        int lengthB = structB.size() - 1;  // minus pivots!
-
-        if (true) {
-            for (int i = 0; i <= lengthA; i++)
-                A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN;
-
-            for (int i = 0; i <= lengthB; i++)
-                B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN;
-        } else {
-            for (int i = 0; i <= lengthA; i++)
-                A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode;
-
-            for (int i = 0; i <= lengthB; i++)
-                B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode;
-        }
-
-        int maxmatch;
-        int[] elemsB;
-
-        do {
-            maxmatch = mml;
-            matches.clear();
-            for (int x = 0; x <= lengthA - maxmatch; x++) {
-                if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null)
-                    continue;
-                inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array
-                    int y = elemsB[i];
-                    if (B[y].marked || maxmatch > lengthB - y)
-                        continue;
-
-                    int j, hx, hy;
-                    for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind
-                        if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked)
-                            continue inner;
-                    }
-
-                    // expand match
-                    j = maxmatch;
-                    while (A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked)
-                        j++;
-
-                    if (j > maxmatch) {  // new biggest match? -> delete current smaller
-                        matches.clear();
-                        maxmatch = j;
-                    }
-                    matches.addMatch(x, y, j);  // add match
-                }
-            }
-            for (int i = matches.size() - 1; i >= 0; i--) {
-                int x = matches.matches[i].startA;  // begining of sequence A
-                int y = matches.matches[i].startB;  // begining of sequence B
-
-                // in order that "Match" will be newly build (because reusing)
-                for (int j = matches.matches[i].length; j > 0; j--)
-                    A[x++].marked = B[y++].marked = true;   // mark all Token!
-            }
-
-        } while (maxmatch != mml);
-    }
-
-    public final void compareWithBasecode(Submission subA, Submission subB) {
-        Submission A, B, tmp;
-        if (subA.struct.size() > subB.struct.size()) {
-            A = subB;
-            B = subA;
-        } else {
-            A = subB;
-            B = subA;
-        }
-        // if hashtable exists in first but not in second structure: flip around!
-        if (B.struct.table == null && A.struct.table != null) {
-            tmp = A;
-            A = B;
-            B = tmp;
-        }
-    }
-
-    private final void compareWithBasecode(Submission subA, Submission subB, int mml) {
-        Structure structA = subA.struct;
-        Structure structB = subB.struct;
-
-        // FILE_END used as pivot
-
-        // init
-        Token[] A = structA.tokens;
-        Token[] B = structB.tokens;
-        int lengthA = structA.size() - 1;  // minus pivots!
-        int lengthB = structB.size() - 1;  // minus pivots!
-
-        // Initialize
-        for (int i = 0; i <= lengthA; i++)
-            A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN;
-
-        for (int i = 0; i <= lengthB; i++)
-            B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN;
-
-        int maxmatch;
-        int[] elemsB;
-
-        do {
-            maxmatch = mml;
-            matches.clear();
-            for (int x = 0; x <= lengthA - maxmatch; x++) {
-                if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null)
-                    continue;
-                inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array
-                    int y = elemsB[i];
-                    if (B[y].marked || maxmatch > lengthB - y)
-                        continue;
-
-                    int j, hx, hy;
-                    for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind
-                        if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked)
-                            continue inner;
-                    }
-                    // expand match
-                    j = maxmatch;
-                    while (A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked)
-                        j++;
-
-                    if (j != maxmatch) {  // new biggest match? -> delete current smaller
-                        matches.clear();
-                        maxmatch = j;
-                    }
-                    matches.addMatch(x, y, j);  // add match
-                }
-            }
-            for (int i = matches.size() - 1; i >= 0; i--) {
-                int x = matches.matches[i].startA;  // beginning in sequence A
-                int y = matches.matches[i].startB;  // beginning in sequence B
-
-                // in order that "Match" will be newly build (because reusing)
-                for (int j = matches.matches[i].length; j > 0; j--) {
-                    A[x].marked = B[y].marked = true;   // mark all Token!
-                    A[x].basecode = B[y].basecode = true;
-                    x++;
-                    y++;
-                }
-            }
-        } while (maxmatch != mml);
-
-    }
-
-    public void resetBaseSubmission(Submission sub) {
-        Structure tmpStruct = sub.struct;
-        Token[] tok = tmpStruct.tokens;
-        for (int z = 0; z < tmpStruct.size() - 1; z++) {
-            tok[z].basecode = false;
-        }
-    }
+	private Matches matches = new Matches();
+
+	/*
+	 * creating hashes.
+	 * The hash-code will be written in every Token for the next <hash_length> token.
+	 * (includes the Token itself)
+	 * Das Ganze laeuft in linearer Zeit.
+	 * condition: 1 < hashLength < 26   !!!
+	 */
+
+	public void create_hashes(Structure s, int hashLength, boolean makeTable) {
+		// Hier wird die obere Grenze der Hash-Laenge festgelegt.
+		// Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl
+		// der Token.
+		if (hashLength<1) hashLength = 1;
+		hashLength = (hashLength<26 ? hashLength : 25);
+
+		if (s.size()<hashLength) return;
+
+		int modulo = ((1 << 6) - 1);   // Modulo 64!
+
+		int loops = s.size()-hashLength;
+		s.table = (makeTable ? new Table(3*loops) : null);
+		int hash = 0;
+		int i;
+		int hashedLength = 0;
+		for (i=0; i<hashLength; i++) {
+			hash = (2*hash) + (s.tokens[i].type & modulo);
+			hashedLength++;
+			if (s.tokens[i].marked)
+				hashedLength = 0;
+		}
+		int factor = (hashLength != 1 ? (2<<(hashLength-2)) : 1);
+
+		if (makeTable) {
+			for (i=0; i<loops; i++) {
+				if (hashedLength >= hashLength) {
+					s.tokens[i].hash = hash;
+					s.table.add(hash, i);   // add into hashtable
+				} else
+					s.tokens[i].hash = -1;
+				hash -= factor * (s.tokens[i].type & modulo);
+				hash = (2*hash) + (s.tokens[i+hashLength].type & modulo);
+				if (s.tokens[i+hashLength].marked)
+					hashedLength = 0;
+				else
+					hashedLength++;
+			}
+		} else {
+			for (i=0; i<loops; i++) {
+				s.tokens[i].hash = (hashedLength >= hashLength) ? hash : -1;
+				hash -= factor * (s.tokens[i].type & modulo);
+				hash = (2*hash) + (s.tokens[i+hashLength].type & modulo);
+				if (s.tokens[i+hashLength].marked)
+					hashedLength = 0;
+				else
+					hashedLength++;
+			}
+		}
+		s.hash_length = hashLength;
+	}
+
+	public final void compare(Submission subA, Submission subB) {
+		Submission A, B, tmp;
+		if (subA.struct.size() > subB.struct.size()) {
+			A = subB;  B = subA;
+		} else {
+			A = subB;  B = subA;
+		}
+		// if hashtable exists in first but not in second structure: flip around!
+		if (B.struct.table == null && A.struct.table != null) {
+			tmp = A;
+			A = B;
+			B = tmp;
+		}
+	}
+
+	// first parameter should contain the smaller sequence!!! 
+	private final void compare(Submission subA, Submission subB, int mml) {
+		Structure structA = subA.struct;
+		Structure structB = subB.struct;
+
+		// FILE_END used as pivot
+
+		// init
+		Token[] A = structA.tokens;
+		Token[] B = structB.tokens;
+		int lengthA = structA.size()-1;  // minus pivots!
+		int lengthB = structB.size()-1;  // minus pivots!
+
+
+		if(true) {
+			for(int i = 0; i <= lengthA; i++)
+				A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN;
+
+			for(int i = 0; i <= lengthB; i++)
+				B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN;
+		} else {
+			for(int i = 0; i <= lengthA; i++)
+				A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode;
+
+			for(int i = 0; i <= lengthB; i++)
+				B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode;
+		}
+
+
+		int maxmatch;
+		int[] elemsB;
+
+		do {
+			maxmatch = mml;
+			matches.clear();
+			for (int x = 0; x <= lengthA - maxmatch; x++) {
+				if (A[x].marked || A[x].hash == -1
+						|| (elemsB = structB.table.get(A[x].hash)) == null)
+					continue;
+inner:			for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array
+					int y = elemsB[i];
+					if (B[y].marked || maxmatch > lengthB - y) continue;
+
+					int j, hx, hy;
+					for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind
+						if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked)
+							continue inner;
+					}
+
+					// expand match
+					j = maxmatch;
+					while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked)
+						j++;
+
+					if (j > maxmatch) {  // new biggest match? -> delete current smaller
+						matches.clear();
+						maxmatch = j;
+					}
+					matches.addMatch(x, y, j);  // add match
+				}
+			}
+			for (int i = matches.size() - 1; i >= 0; i--) {
+				int x = matches.matches[i].startA;  // begining of sequence A
+				int y = matches.matches[i].startB;  // begining of sequence B
+
+				//in order that "Match" will be newly build     (because reusing)
+				for (int j = matches.matches[i].length; j > 0; j--)
+					A[x++].marked = B[y++].marked = true;   // mark all Token!
+			}
+
+		} while (maxmatch != mml);
+	}
+
+	public final void compareWithBasecode(Submission subA, Submission subB) {
+		Submission A, B, tmp;
+		if (subA.struct.size() > subB.struct.size()) {
+			A = subB;  B = subA;
+		} else {
+			A = subB;  B = subA;
+		}
+		// if hashtable exists in first but not in second structure: flip around!
+		if (B.struct.table == null && A.struct.table != null) {
+			tmp = A;
+			A = B;
+			B = tmp;
+		}
+	}
+
+	private final void compareWithBasecode(Submission subA, Submission subB, int mml) {
+		Structure structA = subA.struct;
+		Structure structB = subB.struct;
+
+		// FILE_END used as pivot
+
+		// init
+		Token[] A = structA.tokens;
+		Token[] B = structB.tokens;
+		int lengthA = structA.size()-1;  // minus pivots!
+		int lengthB = structB.size()-1;  // minus pivots!
+
+
+		// Initialize
+		for(int i = 0; i <= lengthA; i++)
+			A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN;
+
+		for(int i = 0; i <= lengthB; i++)
+			B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN;
+
+
+
+
+		int maxmatch;
+		int[] elemsB;
+
+		do {
+			maxmatch = mml;
+			matches.clear();
+			for (int x = 0; x <= lengthA - maxmatch; x++) {
+				if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null)
+					continue;
+inner:			for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array
+					int y = elemsB[i];
+					if (B[y].marked || maxmatch > lengthB - y) continue;
+
+					int j,hx,hy;
+					for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind
+						if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked)
+							continue inner;
+					}
+					// expand match
+					j = maxmatch;
+					while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked)
+						j++;
+
+					if (j != maxmatch) {  // new biggest match? -> delete current smaller
+						matches.clear();
+						maxmatch = j;
+					}
+					matches.addMatch(x, y, j);  // add match
+				}
+			}
+			for (int i = matches.size() - 1; i >= 0; i--) {
+				int x = matches.matches[i].startA;  // beginning in sequence A
+				int y = matches.matches[i].startB;  // beginning in sequence B
+
+				//in order that "Match" will be newly build     (because reusing)
+				for (int j = matches.matches[i].length; j > 0; j--){
+					A[x].marked = B[y].marked = true;   // mark all Token!
+					A[x].basecode = B[y].basecode= true;
+					x++; y++;
+				}
+			}
+		} while (maxmatch != mml);
+
+	}
+
+	public void resetBaseSubmission(Submission sub){
+		Structure tmpStruct = sub.struct;
+		Token[] tok = tmpStruct.tokens;
+		for (int z = 0; z < tmpStruct.size()-1;z++){
+			tok[z].basecode = false;
+		}
+	}
 }

+ 42 - 51
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/Match.java

@@ -1,61 +1,52 @@
 public class Match {
-    public int startA;
-    public int startB;
-    public int length;
+  public int startA;
+  public int startB;
+  public int length;
 
-    public Match(int startA, int startB, int length) {
-        this.startA = startA;
-        this.startB = startB;
-        this.length = length;
-    }
+  public Match(int startA, int startB, int length) {
+    this.startA = startA;
+    this.startB = startB;
+    this.length = length;
+  }
+  public Match() {}
 
-    public Match() {
-    }
+  public void set(int startA, int startB, int length) {
+    this.startA = startA;
+    this.startB = startB;
+    this.length = length;
+  }
 
-    public void set(int startA, int startB, int length) {
-        this.startA = startA;
-        this.startB = startB;
-        this.length = length;
-    }
+  public final boolean contains(int index, int sub) {
+    int start = (sub==0 ? startA : startB);
+    return (start <= index && index < (start+length));
+  }
 
-    public final boolean contains(int index, int sub) {
-        int start = (sub == 0 ? startA : startB);
-        return (start <= index && index < (start + length));
+  public final boolean overlap(Match other) {
+    if (startA < other.startA) {
+      if ((other.startA - startA) < length) return true;
+    } else {
+      if ((startA - other.startA) < other.length) return true;
     }
-
-    public final boolean overlap(Match other) {
-        if (startA < other.startA) {
-            if ((other.startA - startA) < length)
-                return true;
-        } else {
-            if ((startA - other.startA) < other.length)
-                return true;
-        }
-        if (startB < other.startB) {
-            if ((other.startB - startB) < length)
-                return true;
-        } else {
-            if ((startB - other.startB) < other.length)
-                return true;
-        }
-        return false;
+    if (startB < other.startB) {
+      if ((other.startB - startB) < length) return true;
+    } else {
+      if ((startB - other.startB) < other.length) return true;
     }
+    return false;
+  }
 
-    public final boolean overlap(int oStartA, int oStartB, int oLength) {
-        if (startA < oStartA) {
-            if ((oStartA - startA) < length)
-                return true;
-        } else {
-            if ((startA - oStartA) < oLength)
-                return true;
-        }
-        if (startB < oStartB) {
-            if ((oStartB - startB) < length)
-                return true;
-        } else {
-            if ((startB - oStartB) < oLength)
-                return true;
-        }
-        return false;
+  public final boolean overlap(int oStartA, int oStartB, int oLength) {
+    if (startA < oStartA) {
+      if ((oStartA - startA) < length) return true;
+    } else {
+      if ((startA - oStartA) < oLength) return true;
+    }
+    if (startB < oStartB) {
+      if ((oStartB - startB) < length) return true;
+    } else {
+      if ((startB - oStartB) < oLength) return true;
     }
+    return false;
+  }
 }
+

+ 48 - 48
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/Matches.java

@@ -1,57 +1,57 @@
-/*
- * Minimal class that stores "Match" objects.
+/* Minimal class that stores "Match" objects.
  */
 public class Matches {
-    public Match[] matches;
+  public Match[] matches;
 
-    private int anzahl;
-    private final int increment = 20;
+  private int anzahl;
+  private final int increment = 20;
+  
+  public Matches() {
+    matches = new Match[10];
+    for (int i=0; i<10; i++) matches[i] = new Match();
+    anzahl = 0;
+  }
 
-    public Matches() {
-        matches = new Match[10];
-        for (int i = 0; i < 10; i++)
-            matches[i] = new Match();
-        anzahl = 0;
-    }
+  public final int size() {
+    return anzahl;
+  }
 
-    public final int size() {
-        return anzahl;
+  public final void ensureCapacity(int minCapacity) {
+    int oldCapacity = matches.length;
+    if (minCapacity > oldCapacity) {
+      Match[] oldMatches = matches;
+      int newCapacity = (oldCapacity + increment);
+      if (newCapacity < minCapacity) {
+	newCapacity = minCapacity;
+      }
+      matches = new Match[newCapacity];
+      System.arraycopy(oldMatches, 0, matches, 0, oldCapacity);
+      for (int i=oldCapacity; i<newCapacity; i++)
+	matches[i] = new Match();
     }
-
-    public final void ensureCapacity(int minCapacity) {
-        int oldCapacity = matches.length;
-        if (minCapacity > oldCapacity) {
-            Match[] oldMatches = matches;
-            int newCapacity = (oldCapacity + increment);
-            if (newCapacity < minCapacity) {
-                newCapacity = minCapacity;
-            }
-            matches = new Match[newCapacity];
-            System.arraycopy(oldMatches, 0, matches, 0, oldCapacity);
-            for (int i = oldCapacity; i < newCapacity; i++)
-                matches[i] = new Match();
-        }
+  }
+  /*
+  public final void addMatch(Match match) {
+    for (int i=0; i<anzahl; i++)
+      if (match.overlap(matches[i])) return;  // do not allow overlaps
+    ensureCapacity(anzahl + 1);
+    matches[anzahl++] = match;
+  }
+  */
+  public final void addMatch(int startA, int startB, int length) {
+    for (int i=anzahl-1; i>=0; i--) { // starting at the end is better(?)
+      if (matches[i].overlap(startA,startB,length)) return;
+                                      // no overlaps!
     }
+    ensureCapacity(anzahl + 1);
+    //if (matches[anzahl] != null)  // object recycling...
+    matches[anzahl].set(startA,startB,length);
+    //else
+    //matches[anzahl ] = new Match(startA,startB,length);
+    anzahl++;
+  }
 
-    /*
-     * public final void addMatch(Match match) { for (int i=0; i<anzahl; i++) if (match.overlap(matches[i])) return; // do
-     * not allow overlaps ensureCapacity(anzahl + 1); matches[anzahl++] = match; }
-     */
-    public final void addMatch(int startA, int startB, int length) {
-        for (int i = anzahl - 1; i >= 0; i--) { // starting at the end is better(?)
-            if (matches[i].overlap(startA, startB, length))
-                return;
-            // no overlaps!
-        }
-        ensureCapacity(anzahl + 1);
-        // if (matches[anzahl] != null) // object recycling...
-        matches[anzahl].set(startA, startB, length);
-        // else
-        // matches[anzahl ] = new Match(startA,startB,length);
-        anzahl++;
-    }
-
-    public final void clear() {
-        anzahl = 0;
-    }
+  public final void clear() {
+    anzahl=0;
+  }
 }

Разница между файлами не показана из-за своего большого размера
+ 2 - 136
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/Table.java


+ 43 - 53
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/Token.java

@@ -1,57 +1,47 @@
 import java.io.Serializable;
 
 public abstract class Token implements TokenConstants, Serializable {
-    private static final long serialVersionUID = 862935679966383302L;
-    public int type;
-    public String file;
-
-    protected boolean marked;
-    protected boolean basecode = false;
-    protected int hash = -1;// hash-value. set and used by main algorithm (GSTiling)
-
-    public Token(int type, String file, int line) {
-        this(type, file, line, -1, -1);
-    }
-
-    public Token(int type, String file, int line, int column, int length) {
-        this.type = type;
-        this.file = file;
-        setLine(line > 0 ? line : 1);
-        setColumn(column);
-        setLength(length);
-    }
-
-    // abstract members
-    public abstract int getLine();
-
-    public abstract int getColumn();
-
-    public abstract int getLength();
-
-    protected void setLine(int line) {
-    }
-
-    protected void setColumn(int line) {
-    }
-
-    protected void setLength(int line) {
-    }
-
-    // this is made to distinguish the character front end.
-    // maybe other front ends can use it too?
-    protected int getIndex() {
-        return -1;
-    }
-
-    public static String type2string(int type) {
-        return "<abstract>";
-    }
-
-    public String toString() {
-        return type2string(type);
-    }
-
-    public static int numberOfTokens() {
-        return 1;
-    }
+	private static final long serialVersionUID = 862935679966383302L;
+	public int type;
+	public String file;
+	
+	protected boolean marked;
+	protected boolean basecode = false;
+	protected int hash = -1;// hash-value. set and used by main algorithm (GSTiling)
+	
+	public Token(int type, String file, int line) {
+		this(type, file, line, -1, -1);
+	}
+	
+	public Token(int type, String file, int line, int column, int length) {
+		this.type = type;
+		this.file = file;
+		setLine(line>0 ? line : 1);
+		setColumn(column);
+		setLength(length);
+	}
+	
+	// abstract members
+	public abstract int getLine();
+	public abstract int getColumn();
+	public abstract int getLength();
+	protected void setLine(int line) {}
+	protected void setColumn(int line) {}
+	protected void setLength(int line) {}
+	
+	// this is made to distinguish the character front end.
+	// maybe other front ends can use it too?
+	protected int getIndex() { return -1; }
+	
+	public static String type2string(int type) {
+		return "<abstract>";
+	}
+	
+	public String toString() {
+		return type2string(type);
+	}
+	
+	public static int numberOfTokens() { 
+		return 1;
+	} 
 }

+ 6 - 5
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/TokenConstants.java

@@ -1,7 +1,8 @@
 public interface TokenConstants {
-    final static int FILE_END = 0;
-    /**
-     * Used to optionally separate methods from each other with an always marked token
-     */
-    final static int SEPARATOR_TOKEN = 1;
+  final static int FILE_END = 0;
+	/**
+	 * Used to optionally separate methods from each other with an always marked
+	 * token
+	 */
+  final static int SEPARATOR_TOKEN = 1;
 }

+ 42 - 51
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/Match.java

@@ -1,63 +1,54 @@
 package samples.PartialPlagiarism.D;
 
 public class Match {
-    public int startA;
-    public int startB;
-    public int length;
+  public int startA;
+  public int startB;
+  public int length;
 
-    public Match(int startA, int startB, int length) {
-        this.startA = startA;
-        this.startB = startB;
-        this.length = length;
-    }
+  public Match(int startA, int startB, int length) {
+    this.startA = startA;
+    this.startB = startB;
+    this.length = length;
+  }
+  public Match() {}
 
-    public Match() {
-    }
+  public void set(int startA, int startB, int length) {
+    this.startA = startA;
+    this.startB = startB;
+    this.length = length;
+  }
 
-    public void set(int startA, int startB, int length) {
-        this.startA = startA;
-        this.startB = startB;
-        this.length = length;
-    }
+  public final boolean contains(int index, int sub) {
+    int start = (sub==0 ? startA : startB);
+    return (start <= index && index < (start+length));
+  }
 
-    public final boolean contains(int index, int sub) {
-        int start = (sub == 0 ? startA : startB);
-        return (start <= index && index < (start + length));
+  public final boolean overlap(Match other) {
+    if (startA < other.startA) {
+      if ((other.startA - startA) < length) return true;
+    } else {
+      if ((startA - other.startA) < other.length) return true;
     }
-
-    public final boolean overlap(Match other) {
-        if (startA < other.startA) {
-            if ((other.startA - startA) < length)
-                return true;
-        } else {
-            if ((startA - other.startA) < other.length)
-                return true;
-        }
-        if (startB < other.startB) {
-            if ((other.startB - startB) < length)
-                return true;
-        } else {
-            if ((startB - other.startB) < other.length)
-                return true;
-        }
-        return false;
+    if (startB < other.startB) {
+      if ((other.startB - startB) < length) return true;
+    } else {
+      if ((startB - other.startB) < other.length) return true;
     }
+    return false;
+  }
 
-    public final boolean overlap(int oStartA, int oStartB, int oLength) {
-        if (startA < oStartA) {
-            if ((oStartA - startA) < length)
-                return true;
-        } else {
-            if ((startA - oStartA) < oLength)
-                return true;
-        }
-        if (startB < oStartB) {
-            if ((oStartB - startB) < length)
-                return true;
-        } else {
-            if ((startB - oStartB) < oLength)
-                return true;
-        }
-        return false;
+  public final boolean overlap(int oStartA, int oStartB, int oLength) {
+    if (startA < oStartA) {
+      if ((oStartA - startA) < length) return true;
+    } else {
+      if ((startA - oStartA) < oLength) return true;
+    }
+    if (startB < oStartB) {
+      if ((oStartB - startB) < length) return true;
+    } else {
+      if ((startB - oStartB) < oLength) return true;
     }
+    return false;
+  }
 }
+

+ 48 - 48
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/Matches.java

@@ -1,59 +1,59 @@
 package samples.PartialPlagiarism.D;
 
-/*
- * Minimal class that stores "Match" objects.
+/* Minimal class that stores "Match" objects.
  */
 public class Matches {
-    public Match[] matches;
+  public Match[] matches;
 
-    private int anzahl;
-    private final int increment = 20;
+  private int anzahl;
+  private final int increment = 20;
+  
+  public Matches() {
+    matches = new Match[10];
+    for (int i=0; i<10; i++) matches[i] = new Match();
+    anzahl = 0;
+  }
 
-    public Matches() {
-        matches = new Match[10];
-        for (int i = 0; i < 10; i++)
-            matches[i] = new Match();
-        anzahl = 0;
-    }
+  public final int size() {
+    return anzahl;
+  }
 
-    public final int size() {
-        return anzahl;
+  public final void ensureCapacity(int minCapacity) {
+    int oldCapacity = matches.length;
+    if (minCapacity > oldCapacity) {
+      Match[] oldMatches = matches;
+      int newCapacity = (oldCapacity + increment);
+      if (newCapacity < minCapacity) {
+	newCapacity = minCapacity;
+      }
+      matches = new Match[newCapacity];
+      System.arraycopy(oldMatches, 0, matches, 0, oldCapacity);
+      for (int i=oldCapacity; i<newCapacity; i++)
+	matches[i] = new Match();
     }
-
-    public final void ensureCapacity(int minCapacity) {
-        int oldCapacity = matches.length;
-        if (minCapacity > oldCapacity) {
-            Match[] oldMatches = matches;
-            int newCapacity = (oldCapacity + increment);
-            if (newCapacity < minCapacity) {
-                newCapacity = minCapacity;
-            }
-            matches = new Match[newCapacity];
-            System.arraycopy(oldMatches, 0, matches, 0, oldCapacity);
-            for (int i = oldCapacity; i < newCapacity; i++)
-                matches[i] = new Match();
-        }
+  }
+  /*
+  public final void addMatch(Match match) {
+    for (int i=0; i<anzahl; i++)
+      if (match.overlap(matches[i])) return;  // do not allow overlaps
+    ensureCapacity(anzahl + 1);
+    matches[anzahl++] = match;
+  }
+  */
+  public final void addMatch(int startA, int startB, int length) {
+    for (int i=anzahl-1; i>=0; i--) { // starting at the end is better(?)
+      if (matches[i].overlap(startA,startB,length)) return;
+                                      // no overlaps!
     }
+    ensureCapacity(anzahl + 1);
+    //if (matches[anzahl] != null)  // object recycling...
+    matches[anzahl].set(startA,startB,length);
+    //else
+    //matches[anzahl ] = new Match(startA,startB,length);
+    anzahl++;
+  }
 
-    /*
-     * public final void addMatch(Match match) { for (int i=0; i<anzahl; i++) if (match.overlap(matches[i])) return; // do
-     * not allow overlaps ensureCapacity(anzahl + 1); matches[anzahl++] = match; }
-     */
-    public final void addMatch(int startA, int startB, int length) {
-        for (int i = anzahl - 1; i >= 0; i--) { // starting at the end is better(?)
-            if (matches[i].overlap(startA, startB, length))
-                return;
-            // no overlaps!
-        }
-        ensureCapacity(anzahl + 1);
-        // if (matches[anzahl] != null) // object recycling...
-        matches[anzahl].set(startA, startB, length);
-        // else
-        // matches[anzahl ] = new Match(startA,startB,length);
-        anzahl++;
-    }
-
-    public final void clear() {
-        anzahl = 0;
-    }
+  public final void clear() {
+    anzahl=0;
+  }
 }

Разница между файлами не показана из-за своего большого размера
+ 2 - 93
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/Table.java


+ 38 - 48
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/Token.java

@@ -3,52 +3,42 @@ package samples.PartialPlagiarism.D;
 import java.io.Serializable;
 
 public abstract class Token implements TokenConstants, Serializable {
-    private static final long serialVersionUID = 862335679966383302L;
-    public int type;
-    public String file;
-
-    protected boolean marked;
-    protected boolean basecode = false;
-    protected int hash = -1;// hash-value. set and used by main algorithm (GSTiling)
-
-    public Token(int type, String file, int line, int column, int length) {
-        this.type = type;
-        this.file = file;
-        setLine(line > 0 ? line : 1);
-        setColumn(column);
-        setLength(length);
-    }
-
-    // abstract members
-    public abstract int getLine();
-
-    public abstract int getColumn();
-
-    public abstract int getLength();
-
-    protected void setLine(int line) {
-    }
-
-    protected void setColumn(int line) {
-    }
-
-    protected void setLength(int line) {
-    }
-
-    // This is original work not copied
-    protected int getIndex() {
-        return -1;
-    }
-
-    public static String type2string(int type) {
-        return "<abstract>";
-    }
-
-    public String toString() {
-        return type2string(type);
-    }
-
-    public static int numberOfTokens() {
-        return 1;
-    }
+	private static final long serialVersionUID = 862335679966383302L;
+	public int type;
+	public String file;
+	
+	protected boolean marked;
+	protected boolean basecode = false;
+	protected int hash = -1;// hash-value. set and used by main algorithm (GSTiling)
+	
+	public Token(int type, String file, int line, int column, int length) {
+		this.type = type;
+		this.file = file;
+		setLine(line>0 ? line : 1);
+		setColumn(column);
+		setLength(length);
+	}
+	
+	// abstract members
+	public abstract int getLine();
+	public abstract int getColumn();
+	public abstract int getLength();
+	protected void setLine(int line) {}
+	protected void setColumn(int line) {}
+	protected void setLength(int line) {}
+	
+	// This is original work not copied
+	protected int getIndex() { return -1; }
+	
+	public static String type2string(int type) {
+		return "<abstract>";
+	}
+	
+	public String toString() {
+		return type2string(type);
+	}
+	
+	public static int numberOfTokens() { 
+		return 1;
+	} 
 }

+ 7 - 6
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/TokenConstants.java

@@ -1,11 +1,12 @@
 package samples.PartialPlagiarism.D;
 
 public interface TokenConstants {
-    final static int FILE_END = 0;
-    /**
-     * Used to optionally separate methods from each other with an always marked token
-     */
-    final static int SEPARATOR_TOKEN = 1;
+  final static int FILE_END = 0;
+	/**
+	 * Used to optionally separate methods from each other with an always marked
+	 * token
+	 */
+  final static int SEPARATOR_TOKEN = 1;
 
-    final static int ANOTHER_TOKEN = 42;
+  final static int ANOTHER_TOKEN = 42;
 }

+ 1 - 1
jplag/src/test/resources/de/jplag/samples/SimpleDuplicate/A/SimpleDuplicate.java

@@ -3,7 +3,7 @@ public class SimpleDuplicate {
     public static void main(String[] args) {
         System.out.println("Hello World!");
 
-        for (int i = 0; i < 10; i++) {
+        for(int i = 0; i < 10; i++) {
             System.out.println("Number is " + i);
         }
     }

+ 1 - 1
jplag/src/test/resources/de/jplag/samples/SimpleDuplicate/B/SimpleDuplicate.java

@@ -4,7 +4,7 @@ public class SimpleDuplicate {
         System.out.println("Hello Plagiarism!");
 
         int max = 10;
-        for (int j = 0; j < max; j++) {
+        for(int j = 0; j < max; j++) {
             System.out.println("Number is " + j);
         }
     }

Некоторые файлы не были показаны из-за большого количества измененных файлов