package fitnesse.responders.versions;

import java.util.LinkedList;
import java.util.List;

import difflib.DiffUtils;
import difflib.Patch;

public class VersionComparer {

  private List<String> differences;
  
  public boolean compare(String originalVersion, String originalContent, String revisedVersion, String revisedContent) {
    Patch patch = DiffUtils.diff(contentToLines(originalContent), contentToLines(revisedContent));
    differences = DiffUtils.generateUnifiedDiff(originalVersion, revisedVersion,
        contentToLines(originalContent), patch, 5);
    return true;
  }

  public List<String> getDifferences() {
    return differences;
  }
  
  private List<String> contentToLines(String content) {
    List<String> lines = new LinkedList<String>();
    for(String line : content.split("\n"))
      lines.add(line);
    return lines;
  }

}

@@ -202,18 +202,16 @@
 rences;%0A
-  
 %0A  publi
@@ -333,16 +333,24 @@
    Patch
+%3CString%3E
  patch =
@@ -655,18 +655,16 @@
 es;%0A  %7D%0A
-  
 %0A  priva

Fix raw type usage