org.crosswire.common.diff
Class LineMap

java.lang.Object
  extended by org.crosswire.common.diff.LineMap

public class LineMap
extends Object

LineMap is a heuristic algorithm that allows the differencing of a representation of lines. A Diff of the source and target maps can be reconstituted with restore.

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  List lines
          The lines from the original.
private  String sourceMap
          Each character in sourceMap provides an integer representation of the line in the original.
private  String targetMap
          Each character in sourceMap provides an integer representation of the line in the original.
 
Constructor Summary
LineMap(String source, String target)
          Split two texts into a list of strings.
 
Method Summary
 List getLines()
           
 String getSourceMap()
           
 String getTargetMap()
           
private  String linesToCharsMunge(String text, List linearray, Map linehash)
          Split a text into a list of strings.
 void restore(List diffs)
          Rehydrate the text in a diff from a string of line hashes to real lines of text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourceMap

private String sourceMap
Each character in sourceMap provides an integer representation of the line in the original.


targetMap

private String targetMap
Each character in sourceMap provides an integer representation of the line in the original.


lines

private List lines
The lines from the original. Useful for reconstitution.

Constructor Detail

LineMap

public LineMap(String source,
               String target)
Split two texts into a list of strings. Reduce the texts to a string of hashes where each Unicode character represents one line. The result is that text1 is encoded into

Parameters:
source - Baseline string
target - Changed string
Method Detail

restore

public void restore(List diffs)
Rehydrate the text in a diff from a string of line hashes to real lines of text.

Parameters:
diffs - List of Difference objects

getSourceMap

public String getSourceMap()
Returns:
the sourceMap

getTargetMap

public String getTargetMap()
Returns:
the targetMap

getLines

public List getLines()
Returns:
the lines

linesToCharsMunge

private String linesToCharsMunge(String text,
                                 List linearray,
                                 Map linehash)
Split a text into a list of strings. Reduce the texts to a string of hashes where each Unicode character represents one line.

Parameters:
text - String to encode
linearray - List of unique strings
linehash - Map of strings to indices
Returns:
Encoded string

Copyright ยจ 2003-2007