public class DifferenceEngine extends Object
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
private String |
source
Made final because we now rely on caching the string lengths (they could be cached
at method level if require non-final in future)
The baseline text.
|
private int |
sourceLength |
private String |
target
The changed text.
|
private int |
targetLength |
private static float |
timeout |
private static float |
TIMEOUT
Number of seconds to map a diff before giving up.
|
Constructor and Description |
---|
DifferenceEngine()
Empty Difference Engine, which won't find anything.
|
DifferenceEngine(String source,
String target)
Find the differences between two texts.
|
Modifier and Type | Method and Description |
---|---|
List<Difference> |
generate()
Explore the intersection points between the two texts.
|
protected List<Difference> |
path1(List<Set<String>> vMap,
String newSource,
String newTarget)
Work from the middle back to the start to determine the path.
|
protected List<Difference> |
path2(List<Set<String>> vMap,
String newSource,
String newTarget)
Work from the middle back to the end to determine the path.
|
static void |
setTimeout(float newTimeout)
Set the timeout for the diff operation.
|
private static final float TIMEOUT
private static float timeout
private final String source
private final String target
private final int targetLength
private final int sourceLength
public DifferenceEngine()
public List<Difference> generate()
protected List<Difference> path1(List<Set<String>> vMap, String newSource, String newTarget)
vMap
- List of path sets.newSource
- Old string fragment to be diffednewTarget
- New string fragment to be diffedprotected List<Difference> path2(List<Set<String>> vMap, String newSource, String newTarget)
vMap
- List of path sets.newSource
- Old string fragment to be diffednewTarget
- New string fragment to be diffedpublic static void setTimeout(float newTimeout)
newTimeout
- the new timeout