Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.common.diff
Class DifferenceEngine

    java.lang.Object
      org.crosswire.common.diff.DifferenceEngine

    public class DifferenceEngine

extends Object

Builds a map of a baseline/source text and a changed/target text, navigating it to determine differences. Based on the LGPL Diff_Match_Patch v1.5 javascript of Neil Fraser, Copyright (C) 2006 http://neil.fraser.name/software/diff_match_patch/

Author:
  DM Smith [dmsmith555 at yahoo dot com]
See Also:
  `for license details.
  The copyright to this program is held by it's authors.`

Field Summary
`private String` | `source` The baseline text.
`private String` | `target` The changed text.
`private static float` | `timeout`
`private static float` | `TIMEOUT` Number of seconds to map a diff before giving up.

Constructor Summary
`DifferenceEngine()` Empty Difference Engine, which won't find anything.
`DifferenceEngine(String source, String target)` Find the differences between two texts.

Method Summary
`List` | `generate()` Explore the intersection points between the two texts.
`protected List` | `path1(List vMap, String newSource, String newTarget)` Work from the middle back to the start to determine the path.
`protected List` | `path2(List vMap, String newSource, String newTarget)` Work from the middle back to the end to determine the path.
`void` | `setSource(String newSource)`
`void` | `setTarget(String newTarget)`
`static void` | `setTimeout(float newTimeout)` Set the timeout for the diff operation.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TIMEOUT

    private static final float TIMEOUT

  Number of seconds to map a diff before giving up. Use 0 for infinity.

  See Also:
    Constant Field Values

### timeout

    private static float timeout

### source

    private String source

  The baseline text.

### target

    private String target

  The changed text.

Constructor Detail

### DifferenceEngine

    public DifferenceEngine()

  Empty Difference Engine, which won't find anything.

### DifferenceEngine

    public DifferenceEngine(String source,
                            String target)

  Find the differences between two texts. Simplifies the problem by stripping any common prefix or suffix off the texts before diffing.

  Parameters:
    `source` - Old string to be diffed
    `target` - New string to be diffed

Method Detail

### setSource

    public void setSource(String newSource)

  Parameters:
    `newSource` - the source to set

### setTarget

    public void setTarget(String newTarget)

  Parameters:
    `newTarget` - the target to set

### generate

    public List generate()

  Explore the intersection points between the two texts.

  Returns:
    List of Difference objects or null if no diff available

### path1

    protected List path1(List vMap,
                         String newSource,
                         String newTarget)

  Work from the middle back to the start to determine the path.

  Parameters:
    `vMap` - List of path sets.
    `newSource` - Old string fragment to be diffed
    `newTarget` - New string fragment to be diffed
  Returns:
    List of Difference objects

### path2

    protected List path2(List vMap,
                         String newSource,
                         String newTarget)

  Work from the middle back to the end to determine the path.

  Parameters:
    `vMap` - List of path sets.
    `newSource` - Old string fragment to be diffed
    `newTarget` - New string fragment to be diffed
  Returns:
    List of Difference objects

### setTimeout

    public static void setTimeout(float newTimeout)

  Set the timeout for the diff operation. The default is 1 second. Use 0 for infinity.

  Parameters:
    `newTimeout` -

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¨ 2003-2007
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD