1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.util;
16  
17  import java.io.Reader;
18  
19  import java.util.List;
20  
21  /**
22   * <a href="DiffUtil.java.html"><b><i>View Source</i></b></a>
23   *
24   * <p>
25   * This class can compare two different versions of a text. Source refers to the
26   * earliest version of the text and target refers to a modified version of
27   * source. Changes are considered either as a removal from the source or as an
28   * addition to the target. This class detects changes to an entire line and also
29   * detects changes within lines, such as, removal or addition of characters.
30   * Take a look at <code>DiffTest</code> to see the expected inputs and outputs.
31   * </p>
32   *
33   * @author Bruno Farache
34   * @see    com.liferay.portal.kernel.util.DiffUtil
35   */
36  public class DiffUtil {
37  
38      public static List<DiffResult>[] diff(Reader source, Reader target) {
39          return getDiff().diff(source, target);
40      }
41  
42      public static List<DiffResult>[] diff(
43          Reader source, Reader target, String addedMarkerStart,
44          String addedMarkerEnd, String deletedMarkerStart,
45          String deletedMarkerEnd, int margin) {
46  
47          return getDiff().diff(
48              source, target, addedMarkerStart, addedMarkerEnd,
49              deletedMarkerStart, deletedMarkerEnd, margin);
50      }
51  
52      public static Diff getDiff() {
53          return _diff;
54      }
55  
56      public void setDiff(Diff diff) {
57          _diff = diff;
58      }
59  
60      private static Diff _diff;
61  
62  }