Package ro.sync.diff.api
Interface DifferencePerformer
-
@API(type=NOT_EXTENDABLE, src=PUBLIC) public interface DifferencePerformer
TheDifferencePerformer
is used to compare two resources of a given content type using a set of options. The result of the diff is a list with the differences between the resources.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<Difference>
performDiff(java.io.Reader leftContentReader, java.io.Reader rightContentReader, java.io.Reader baseContentReader, java.lang.String leftSystemId, java.lang.String rightSystemId, java.lang.String baseSystemId, java.lang.String contentType, DiffOptions diffOptions, DiffProgressListener diffProgressListener)
Performs the diff operation between the resources represented by the three readers.java.util.List<Difference>
performDiff(java.io.Reader leftContentReader, java.io.Reader rightContentReader, java.lang.String leftSystemId, java.lang.String rightSystemId, java.lang.String contentType, DiffOptions diffOptions, DiffProgressListener diffProgressListener)
Performs the diff operation between the resources represented by the two readers.void
stop()
Signal to the diff performer that it must stop.
-
-
-
Method Detail
-
performDiff
java.util.List<Difference> performDiff(java.io.Reader leftContentReader, java.io.Reader rightContentReader, java.lang.String leftSystemId, java.lang.String rightSystemId, java.lang.String contentType, DiffOptions diffOptions, DiffProgressListener diffProgressListener) throws DiffException
Performs the diff operation between the resources represented by the two readers. The resources are compared taking into account the content type and the provided options.
Please note that the content of the readers will be processed before comparison and all end lines will be replaced with\n
.- Parameters:
leftContentReader
- The first resource content reader. It cannot benull
.rightContentReader
- The second resource content reader. It cannot benull
.leftSystemId
- The left resource URL as string. It can benull
when a system ID is not relevant.rightSystemId
- The right resource URL as string. It can benull
when a system ID is not relevant.contentType
- The content type of the two resources, constants fromDiffContentTypes
. It is used only when the diff algorithm takes into account the tokens of the language associated with the resources. It can benull
when the used algorithm is not syntax aware.diffOptions
- The options used by the diff performer to perform the comparison. It can benull
meaning a default set of options wil be used.diffProgressListener
- TheDiffProgressListener
notified about the progress of the diff. It can benull
when the diff progress doesn't need to be monitored.- Returns:
- The list with the differences. The differences are represented by
Difference
objects. If the resources are identical or the diff fails the list will be empty.
If the hierarchical diff is activated (DiffOptions.isEnableHierarchicalDiff()
returns true) then the returned list containsDifferenceParent
elements. - Throws:
DiffException
- If the diff operation fails or it is stopped before it finishes.
-
performDiff
java.util.List<Difference> performDiff(java.io.Reader leftContentReader, java.io.Reader rightContentReader, java.io.Reader baseContentReader, java.lang.String leftSystemId, java.lang.String rightSystemId, java.lang.String baseSystemId, java.lang.String contentType, DiffOptions diffOptions, DiffProgressListener diffProgressListener) throws java.io.IOException, CannotHandleException, DiffException
Performs the diff operation between the resources represented by the three readers. The resources are compared taking into account the content type and the provided options.- Parameters:
leftContentReader
- The first resource content reader. Cannot benull
.rightContentReader
- The second resource content reader.Cannot benull
.baseContentReader
- The content reader of the base resource to which the other 2 resources are compared against. It can benull in which case the diff operation is reduced to the direct comparison between the first and the second resource. leftSystemId
- The left resource URL as string. Can benull
if a system ID is not relevant.rightSystemId
- The right resource URL as string. Can benull
if a system ID is not relevant.baseSystemId
- The base resource URL as string. Can benull
when a system ID is not relevant.contentType
- The content type of the resources, constants fromDiffContentTypes
. It is used only when the diff algorithm takes into account the tokens of the language associated with the resources. Can benull
when the used algorithm is not syntax aware.diffOptions
- The options used by the diff performer to perform the comparison. Can benull
and that means a default set of options is used.diffProgressListener
- TheDiffProgressListener
notified about the progress of the diff. Can benull
when the diff progress doesn't need to be monitored.- Returns:
- The list with the differences. The differences are represented by
Difference
objects. - Throws:
java.io.IOException
- If an I/O exception occurs while handling the resource content readers.CannotHandleException
- When the algorithm cannot handle the documents (most probably issues regarding the parsing of not well formed documents).DiffException
- If the diff operation fails or it is stopped before it finishes.
-
stop
void stop()
Signal to the diff performer that it must stop.
-
-