Class SimilarityComputer
- java.lang.Object
-
- org.eclipse.emf.compare.ide.ui.internal.logical.SimilarityComputer
-
public final class SimilarityComputer extends Object
This class is responsible for computing similarities between two text contents and deciding whether they are close enough to be considered a rename.
-
-
Field Summary
Fields Modifier and Type Field Description static int
MINIMUM_LENGTH
The minimum length both sides must have to not be ignored (short text contents might seem similar and cause false negatives).static double
THRESHOLD
The maximum percentage of differing lines contained in the content for files to be considered a rename.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
computeDifference(InputStream a, InputStream b)
Computes the difference between twoInputStream
instances.static boolean
isSimilar(InputStream a, InputStream b)
Decides whether two input streams are similar.
-
-
-
Field Detail
-
MINIMUM_LENGTH
public static final int MINIMUM_LENGTH
The minimum length both sides must have to not be ignored (short text contents might seem similar and cause false negatives).- See Also:
- Constant Field Values
-
THRESHOLD
public static final double THRESHOLD
The maximum percentage of differing lines contained in the content for files to be considered a rename.- See Also:
- Constant Field Values
-
-
Method Detail
-
isSimilar
public static boolean isSimilar(InputStream a, InputStream b) throws IOException
Decides whether two input streams are similar. This methods callscomputeDifference(InputStream, InputStream)
and compares the value withTHRESHOLD
.- Parameters:
a
- the first input streamb
- the second input stream- Returns:
true
if the input streams are similar- Throws:
IOException
- if reading of one of the input streams fails
-
computeDifference
public static double computeDifference(InputStream a, InputStream b) throws IOException
Computes the difference between twoInputStream
instances. The returned value is a ratio of changed lines to total lines, where total lines is denoted by the maximum of the line counts of both input streams. This method returnsDouble.MAX_VALUE
if one or both of the streams arenull
or if the content is too short to be compared (shorter thanMINIMUM_LENGTH
).- Parameters:
a
- the first input streamb
- the second input stream- Returns:
- how different the two streams are
- Throws:
IOException
- if reading of one of the input streams fails
-
-