difflib
Class DiffRowGenerator

java.lang.Object
  extended by difflib.DiffRowGenerator

public class DiffRowGenerator
extends Object

This class for generating DiffRows for side-by-sidy view. You can customize the way of generating. For example, show inline diffs on not, ignoring white spaces or/and blank lines and so on. All parameters for generating are optional. If you do not specify them, the class will use the default values. These values are: showInlineDiffs = false; ignoreWhiteSpaces = true; ignoreBlankLines = true; ... For instantiating the DiffRowGenerator you should use the its builder. Like in example DiffRowGenerator generator = new DiffRowGenerator.Builder().showInlineDiffs(true). ignoreWhiteSpaces(true).columnWidth(100).build();

Author:
Dmitry Naumenko

Nested Class Summary
static class DiffRowGenerator.Builder
          This class used for building the DiffRowGenerator.
 
Method Summary
 List<DiffRow> generateDiffRows(List<String> original, List<String> revised)
          Get the DiffRows describing the difference between original and revised texts using the given patch.
 List<DiffRow> generateDiffRows(List<String> original, List<String> revised, Patch<String> patch)
          Generates the DiffRows describing the difference between original and revised texts using the given patch.
static LinkedList<String> wrapInTag(LinkedList<String> sequence, int startPosition, int endPosition, String tag, String cssClass)
          Wrap the elements in the sequence with the given tag
static String wrapInTag(String line, String tag, String cssClass)
          Wrap the given line with the given tag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

generateDiffRows

public List<DiffRow> generateDiffRows(List<String> original,
                                      List<String> revised)
Get the DiffRows describing the difference between original and revised texts using the given patch. Useful for displaying side-by-side diff.

Parameters:
original - the original text
revised - the revised text
Returns:
the DiffRows between original and revised texts

generateDiffRows

public List<DiffRow> generateDiffRows(List<String> original,
                                      List<String> revised,
                                      Patch<String> patch)
Generates the DiffRows describing the difference between original and revised texts using the given patch. Useful for displaying side-by-side diff.

Parameters:
original - the original text
revised - the revised text
patch - the given patch
Returns:
the DiffRows between original and revised texts

wrapInTag

public static LinkedList<String> wrapInTag(LinkedList<String> sequence,
                                           int startPosition,
                                           int endPosition,
                                           String tag,
                                           String cssClass)
Wrap the elements in the sequence with the given tag

Parameters:
startPosition - the position from which tag should start. The counting start from a zero.
endPosition - the position before which tag should should be closed.
tag - the tag name without angle brackets, just a word
cssClass - the optional css class

wrapInTag

public static String wrapInTag(String line,
                               String tag,
                               String cssClass)
Wrap the given line with the given tag

Parameters:
line - the given line
tag - the tag name without angle brackets, just a word
cssClass - the optional css class
Returns:
the wrapped string


Copyright © 2009-2013. All Rights Reserved.