Class SimilarityComputer
java.lang.Object
org.eclipse.emf.compare.ide.ui.internal.logical.SimilarityComputer
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
Modifier and TypeFieldDescriptionstatic final int
The minimum length both sides must have to not be ignored (short text contents might seem similar and cause false negatives).static final double
The maximum percentage of differing lines contained in the content for files to be considered a rename. -
Method Summary
Modifier and TypeMethodDescriptionstatic double
Computes the difference between twoInputStream
instances.static boolean
isSimilar
(InputStream a, InputStream b) Decides whether two input streams are similar.
-
Field Details
-
MINIMUM_LENGTH
public static final int MINIMUM_LENGTHThe minimum length both sides must have to not be ignored (short text contents might seem similar and cause false negatives).- See Also:
-
THRESHOLD
public static final double THRESHOLDThe maximum percentage of differing lines contained in the content for files to be considered a rename.- See Also:
-
-
Method Details
-
isSimilar
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
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
-