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 LineMap

    java.lang.Object
      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
See Also:
  `The GNU Lesser General Public License for details.`

Field Summary
`private List<String>` | `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<String>` | `getLines()`
`String` | `getSourceMap()`
`String` | `getTargetMap()`
`private String` | `linesToCharsMunge(String text, List<String> linearray, Map<String,Integer> 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<String> 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<String> getLines()

  Returns:
    the lines

### linesToCharsMunge

    private String linesToCharsMunge(String text,
                                     List<String> linearray,
                                     Map<String,Integer> 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

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