com.liferay.portal.util
Class DiffImpl
java.lang.Object
com.liferay.portal.util.DiffImpl
- All Implemented Interfaces:
- com.liferay.portal.kernel.util.Diff
public class DiffImpl
- extends java.lang.Object
- implements com.liferay.portal.kernel.util.Diff
View Source
This class can compare two different versions of a text. Source refers to
the earliest version of the text and target refers to a modified version of
source. Changes are considered either as a removal from the source or as an
addition to the target. This class detects changes to an entire line and also
detects changes within lines, such as, removal or addition of characters.
Take a look at DiffTest
to see the expected inputs and outputs.
- Author:
- Bruno Farache
Fields inherited from interface com.liferay.portal.kernel.util.Diff |
CLOSE_DEL, CLOSE_INS, CONTEXT_LINE, OPEN_DEL, OPEN_INS |
Method Summary |
java.util.List<com.liferay.portal.kernel.util.DiffResult>[] |
diff(java.io.Reader source,
java.io.Reader target)
This is a diff method with default values. |
java.util.List<com.liferay.portal.kernel.util.DiffResult>[] |
diff(java.io.Reader source,
java.io.Reader target,
java.lang.String addedMarkerStart,
java.lang.String addedMarkerEnd,
java.lang.String deletedMarkerStart,
java.lang.String deletedMarkerEnd,
int margin)
The main entrance of this class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DiffImpl
public DiffImpl()
diff
public java.util.List<com.liferay.portal.kernel.util.DiffResult>[] diff(java.io.Reader source,
java.io.Reader target)
- This is a diff method with default values.
- Specified by:
diff
in interface com.liferay.portal.kernel.util.Diff
- Parameters:
source
- the Reader
of the source texttarget
- the Reader
of the target text
- Returns:
- an array containing two lists of
DiffResults
,
the first element contains DiffResults related to changes
in source and the second element to changes in target
diff
public java.util.List<com.liferay.portal.kernel.util.DiffResult>[] diff(java.io.Reader source,
java.io.Reader target,
java.lang.String addedMarkerStart,
java.lang.String addedMarkerEnd,
java.lang.String deletedMarkerStart,
java.lang.String deletedMarkerEnd,
int margin)
- The main entrance of this class. This method will compare the two texts,
highlight the changes by enclosing them with markers and return a list
of
DiffResults
.
- Specified by:
diff
in interface com.liferay.portal.kernel.util.Diff
- Parameters:
source
- the Reader
of the source text, this can
be for example, an instance of FileReader or StringReadertarget
- the Reader
of the target textaddedMarkerStart
- the initial marker for highlighting
additionsaddedMarkerEnd
- the end marker for highlighting additionsdeletedMarkerStart
- the initial marker for highlighting
removalsdeletedMarkerEnd
- the end marker for highlighting removalsmargin
- the number of lines that will be added before the
first changed line
- Returns:
- an array containing two lists of
DiffResults
,
the first element contains DiffResults related to changes
in source and the second element to changes in target