001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.util;
016    
017    import java.io.Reader;
018    
019    import java.util.List;
020    
021    /**
022     * <p>
023     * This class can compare two different versions of a text. Source refers to the
024     * earliest version of the text and target refers to a modified version of
025     * source. Changes are considered either as a removal from the source or as an
026     * addition to the target. This class detects changes to an entire line and also
027     * detects changes within lines, such as, removal or addition of characters.
028     * Take a look at <code>DiffTest</code> to see the expected inputs and outputs.
029     * </p>
030     *
031     * @author Bruno Farache
032     * @see    com.liferay.portal.kernel.util.DiffUtil
033     */
034    public class DiffUtil {
035    
036            public static List<DiffResult>[] diff(Reader source, Reader target) {
037                    return getDiff().diff(source, target);
038            }
039    
040            public static List<DiffResult>[] diff(
041                    Reader source, Reader target, String addedMarkerStart,
042                    String addedMarkerEnd, String deletedMarkerStart,
043                    String deletedMarkerEnd, int margin) {
044    
045                    return getDiff().diff(
046                            source, target, addedMarkerStart, addedMarkerEnd,
047                            deletedMarkerStart, deletedMarkerEnd, margin);
048            }
049    
050            public static Diff getDiff() {
051                    return _diff;
052            }
053    
054            public void setDiff(Diff diff) {
055                    _diff = diff;
056            }
057    
058            private static Diff _diff;
059    
060    }