Package org.eclipse.jgit.diff
Class RawTextComparator
- Direct Known Subclasses:
TextHashFunctions.Hash
Equivalence function for
RawText
.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RawTextComparator
No special treatment.static final RawTextComparator
Ignores all whitespace.static final RawTextComparator
Ignores whitespace occurring between non-whitespace characters.static final RawTextComparator
Ignore leading whitespace.static final RawTextComparator
Ignores trailing whitespace. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
findForwardLine
(IntList lines, int idx, int ptr) private static int
findReverseLine
(IntList lines, int idx, int ptr) int
Get a hash value for an item in a sequence.protected abstract int
hashRegion
(byte[] raw, int ptr, int end) Compute a hash code for a region.reduceCommonStartEnd
(RawText a, RawText b, Edit e) Modify the edit to remove common leading and trailing items.Methods inherited from class org.eclipse.jgit.diff.SequenceComparator
equals
-
Field Details
-
DEFAULT
No special treatment. -
WS_IGNORE_ALL
Ignores all whitespace. -
WS_IGNORE_LEADING
Ignore leading whitespace. -
WS_IGNORE_TRAILING
Ignores trailing whitespace. -
WS_IGNORE_CHANGE
Ignores whitespace occurring between non-whitespace characters.
-
-
Constructor Details
-
RawTextComparator
public RawTextComparator()
-
-
Method Details
-
hash
Description copied from class:SequenceComparator
Get a hash value for an item in a sequence. If two items are equal according to this comparator'sSequenceComparator.equals(Sequence, int, Sequence, int)
method, then this hash method must produce the same integer result for both items. It is not required for two items to have different hash values if they are unequal according to theequals()
method.- Specified by:
hash
in classSequenceComparator<RawText>
- Parameters:
seq
- the sequence.lno
- the item to obtain the hash for.- Returns:
- hash the hash value.
-
reduceCommonStartEnd
Modify the edit to remove common leading and trailing items. The supplied edite
is reduced in size by moving the beginning A and B points so the edit does not cover any items that are in common between the two sequences. The ending A and B points are also shifted to remove common items from the end of the region.- Overrides:
reduceCommonStartEnd
in classSequenceComparator<RawText>
- Parameters:
a
- the first sequence.b
- the second sequence.e
- the edit to start with and update.- Returns:
e
if it was updated in-place, otherwise a new edit containing the reduced region.
-
findForwardLine
-
findReverseLine
-
hashRegion
protected abstract int hashRegion(byte[] raw, int ptr, int end) Compute a hash code for a region.- Parameters:
raw
- the raw file content.ptr
- first byte of the region to hash.end
- 1 past the last byte of the region.- Returns:
- hash code for the region
[ptr, end)
of raw.
-