Class Patch<T>
java.lang.Object
com.github.difflib.patch.Patch<T>
- Type Parameters:
T- The type of the compared elements in the 'lines'.
- All Implemented Interfaces:
Serializable
Describes the patch holding all deltas between the original and revised
texts.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ConflictOutput<T> Standard Patch behaviour to throw an exception for pathching conflicts.static final ConflictOutput<String> Git like merge conflict output.private ConflictOutput<T> private final List<AbstractDelta<T>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDelta(AbstractDelta<T> delta) Add the given delta to this patchapplyFuzzy(List<T> target, int maxFuzz) Apply this patch to the given targetprivate static <T> Chunk<T> buildChunk(int start, int end, List<T> data) private intfindPositionFuzzy(Patch.PatchApplyingContext<T> ctx, AbstractDelta<T> delta) private intfindPositionWithFuzz(Patch.PatchApplyingContext<T> ctx, AbstractDelta<T> delta, int fuzz) private intfindPositionWithFuzzAndMoreDelta(Patch.PatchApplyingContext<T> ctx, AbstractDelta<T> delta, int fuzz, int moreDelta) static <T> Patch<T> static <T> Patch<T> Get the list of computed deltasRestore the text to original.toString()withConflictOutput(ConflictOutput<T> conflictOutput) Alter normal conflict output behaviour to e.g.
-
Field Details
-
deltas
-
CONFLICT_PRODUCES_EXCEPTION
Standard Patch behaviour to throw an exception for pathching conflicts. -
CONFLICT_PRODUCES_MERGE_CONFLICT
Git like merge conflict output. -
conflictOutput
-
-
Constructor Details
-
Patch
public Patch() -
Patch
public Patch(int estimatedPatchSize)
-
-
Method Details
-
applyTo
Apply this patch to the given target- Returns:
- the patched text
- Throws:
PatchFailedException- if can't apply patch
-
applyFuzzy
- Throws:
PatchFailedException
-
findPositionFuzzy
private int findPositionFuzzy(Patch.PatchApplyingContext<T> ctx, AbstractDelta<T> delta) throws PatchFailedException - Throws:
PatchFailedException
-
findPositionWithFuzz
private int findPositionWithFuzz(Patch.PatchApplyingContext<T> ctx, AbstractDelta<T> delta, int fuzz) throws PatchFailedException - Throws:
PatchFailedException
-
findPositionWithFuzzAndMoreDelta
private int findPositionWithFuzzAndMoreDelta(Patch.PatchApplyingContext<T> ctx, AbstractDelta<T> delta, int fuzz, int moreDelta) throws PatchFailedException - Throws:
PatchFailedException
-
withConflictOutput
Alter normal conflict output behaviour to e.g. inclide some conflict statements in the result, like git does it. -
restore
-
addDelta
Add the given delta to this patch- Parameters:
delta- the given delta
-
getDeltas
-
toString
-
generate
-
buildChunk
-
generate
-