commands needed to transform
one objects sequence into another objects sequence.
An edit script is the most general view of the differences between two
sequences. It is built as the result of the comparison between two sequences
by the SequencesComparator class. The user can
walk through it using the visitor design pattern.
It is guaranteed that the objects embedded in the insert
commands come from the second sequence and that the objects embedded in
either the delete commands or keep
commands come from the first sequence. This can be important if subclassing
is used for some elements in the first sequence and the equals
method is specialized.
SequencesComparator, EditCommand, CommandVisitor, ReplacementsHandler
| Modifier and Type | Field and Description |
|---|---|
| private final List | commands
Container for the commands. |
| private int | lcsLength
Length of the longest common subsequence. |
| private int | modifications
Number of modifications. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public int | Returns: length of the Longest Common SubsequenceGet the length of the Longest Common Subsequence (LCS). |
| public int | Returns: number of effective modificationsGet the number of effective modifications. |
| public void | visit(final CommandVisitor<T>
the visitor that will visit all commands in turn visitor)Visit the script. |
| commands | back to summary |
|---|---|
| private final List<EditCommand<T>> commands Container for the commands. | |
| lcsLength | back to summary |
|---|---|
| private int lcsLength Length of the longest common subsequence. | |
| modifications | back to summary |
|---|---|
| private int modifications Number of modifications. | |
| EditScript | back to summary |
|---|---|
| public EditScript() Simple constructor. Creates a new empty script. | |
| append | back to summary |
|---|---|
| public void append(final KeepCommand<T> command) Add a keep command to the script.
| |
| append | back to summary |
|---|---|
| public void append(final InsertCommand<T> command) Add an insert command to the script.
| |
| append | back to summary |
|---|---|
| public void append(final DeleteCommand<T> command) Add a delete command to the script.
| |
| getLCSLength | back to summary |
|---|---|
| public int getLCSLength() Get the length of the Longest Common Subsequence (LCS). The length of the
longest common subsequence is the number of
| |
| getModifications | back to summary |
|---|---|
| public int getModifications() Get the number of effective modifications. The number of effective
modification is the number of
| |
| visit | back to summary |
|---|---|
| public void visit(final CommandVisitor<T> visitor) Visit the script. The script implements the visitor design pattern, this method is the entry point to which the user supplies its own visitor, the script will be responsible to drive it through the commands in order and call the appropriate method as each command is encountered.
| |