Class ReplacementsFinder<T>
- java.lang.Object
 - 
- org.apache.commons.collections4.sequence.ReplacementsFinder<T>
 
 
- 
- All Implemented Interfaces:
 CommandVisitor<T>
public class ReplacementsFinder<T> extends java.lang.Object implements CommandVisitor<T>
This class handles sequences of replacements resulting from a comparison.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 individualdelete,keepandinsertcommands by fewer replacements acting on complete sub-sequences.This class is devoted to perform this interpretation. It visits an
edit script(because it implements theCommandVisitorinterface) and calls a user-supplied handler implementing theReplacementsHandlerinterface to process the sub-sequences.- Since:
 - 4.0
 - See Also:
 ReplacementsHandler,EditScript,SequencesComparator
 
- 
- 
Constructor Summary
Constructors Constructor Description ReplacementsFinder(ReplacementsHandler<T> handler)Simple constructor. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidvisitDeleteCommand(T object)Add an object to the pending deletions set.voidvisitInsertCommand(T object)Add an object to the pending insertions set.voidvisitKeepCommand(T object)Handle a synchronization object. 
 - 
 
- 
- 
Constructor Detail
- 
ReplacementsFinder
public ReplacementsFinder(ReplacementsHandler<T> handler)
Simple constructor. Creates a new instance ofReplacementsFinder.- Parameters:
 handler- handler to call when synchronized sequences are found
 
 - 
 
- 
Method Detail
- 
visitInsertCommand
public void visitInsertCommand(T object)
Add an object to the pending insertions set.- Specified by:
 visitInsertCommandin interfaceCommandVisitor<T>- Parameters:
 object- object to insert
 
- 
visitKeepCommand
public void visitKeepCommand(T object)
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.
- Specified by:
 visitKeepCommandin interfaceCommandVisitor<T>- Parameters:
 object- synchronization object detected
 
- 
visitDeleteCommand
public void visitDeleteCommand(T object)
Add an object to the pending deletions set.- Specified by:
 visitDeleteCommandin interfaceCommandVisitor<T>- Parameters:
 object- object to delete
 
 - 
 
 -