Package generic.algorithms
Class WordDiffer
java.lang.Object
generic.algorithms.WordDiffer
Finds differences between two words (any two Strings). The results are available via
getParts().-
Nested Class Summary
Nested ClassesChangeModifier and TypeClassDescriptionclassclassclassA String that is part of a larger String. -
Constructor Summary
ConstructorsChangeConstructorDescriptionWordDiffer(String oldWord, String newWord) Diffs the text between the old and new word. -
Method Summary
ChangeModifier and TypeMethodDescriptiongetMergedParts(int maxSize) The same asgetParts()except that this method will merge differences that are separated only bymaxSizeor less characters.getParts()Returns the 'new word' broken into Strings with offsets, with each part being the same text or different text.toString()
-
Constructor Details
-
WordDiffer
Diffs the text between the old and new word. The new word is the current version of two Strings, the old word is the previous version.- Parameters:
oldWord- the previous version of the textnewWord- the current version of the text
-
-
Method Details
-
getParts
Returns the 'new word' broken into Strings with offsets, with each part being the same text or different text.- Returns:
- the parts; empty if the LCS could not be created
-
getMergedParts
The same asgetParts()except that this method will merge differences that are separated only bymaxSizeor less characters. This method allows clients to combine many smaller differences into larger differences that span similar characters. Merging parts can reduce visual clutter when displaying the differences, at the expense of accuracy.- Parameters:
maxSize- the maximum span of characters past which not to merge two differences- Returns:
- the parts
-
toString
-