The comparison of two objects sequences leads to the identification of common
parts and parts which only belong to the first or to the second sequence. The
common parts appear in the edit script in the form of keep commands,
they can be considered as synchronization objects between the two sequences.
These synchronization objects split the two sequences in synchronized
sub-sequences. The first sequence can be transformed into the second one by
replacing each synchronized sub-sequence of the first sequence by the
corresponding sub-sequence of the second sequence. This is a synthetic way to
see an edit script, replacing individual
delete, keep and
insert commands by fewer replacements acting on
complete sub-sequences.
This class is devoted to perform this interpretation. It visits an
edit script (because it implements the
CommandVisitor interface) and calls a user-supplied
handler implementing the ReplacementsHandler
interface to process the sub-sequences.
ReplacementsHandler, EditScript, SequencesComparator
| Modifier and Type | Field and Description |
|---|---|
| private final ReplacementsHandler | handler
Handler to call when synchronized sequences are found. |
| private final List | |
| private final List | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | ReplacementsFinder(final ReplacementsHandler<T>
handler to call when synchronized sequences are found handler)Simple constructor. |
| Modifier and Type | Method and Description |
|---|---|
| public void | visitDeleteCommand(final T
object to delete object)Implements org. |
| public void | visitInsertCommand(final T
object to insert object)Implements org. |
| public void | visitKeepCommand(final T
synchronization object detected object)Implements org. |
| handler | back to summary |
|---|---|
| private final ReplacementsHandler<T> handler Handler to call when synchronized sequences are found. | |
| pendingDeletions | back to summary |
|---|---|
| private final List<T> pendingDeletions | |
| pendingInsertions | back to summary |
|---|---|
| private final List<T> pendingInsertions | |
| skipped | back to summary |
|---|---|
| private int skipped | |
| ReplacementsFinder | back to summary |
|---|---|
| public ReplacementsFinder(final ReplacementsHandler<T> handler) Simple constructor. Creates a new instance of
| |
| visitDeleteCommand | back to summary |
|---|---|
| public void visitDeleteCommand(final T object) Implements org. Add an object to the pending deletions set.
| |
| visitInsertCommand | back to summary |
|---|---|
| public void visitInsertCommand(final T object) Implements org. Add an object to the pending insertions set.
| |
| visitKeepCommand | back to summary |
|---|---|
| public void visitKeepCommand(final T object) Implements org. Handle a synchronization object. When a synchronization object is identified, the pending insertions and pending deletions sets are provided to the user handler as subsequences.
| |