Package org.eclipse.compare.internal
Class DocLineComparator
java.lang.Object
org.eclipse.compare.internal.DocLineComparator
- All Implemented Interfaces:
- ITokenComparator,- IRangeComparator
Implements the 
IRangeComparator interface for lines in a document.
 A DocLineComparator is used as the input for the RangeDifferencer
 engine to perform a line oriented compare on documents.
 
 A DocLineComparator doesn't know anything about line separators because
 its notion of lines is solely defined in the underlying IDocument.
- 
Constructor SummaryConstructorsConstructorDescriptionDocLineComparator(IDocument document, IRegion region, boolean ignoreWhiteSpace) Creates aDocLineComparatorfor the given document range.DocLineComparator(IDocument document, IRegion region, boolean ignoreWhiteSpace, ICompareFilter[] compareFilters, char contributor, Optional<IIgnoreWhitespaceContributor> ignoreWhitespaceContributor) Creates aDocLineComparatorfor the given document range.
- 
Method SummaryModifier and TypeMethodDescriptionintReturns the number of lines in the document.intgetTokenLength(int line) Returns the character length of the token with the given index.intgetTokenStart(int line) Returns the start character position of the token with the given index.booleanrangesEqual(int thisIndex, IRangeComparator otherComparator, int otherIndex) Returnstrueif a line given by the first index matches a line specified by the otherIRangeComparatorand index.booleanskipRangeComparison(int length, int maxLength, IRangeComparator other) Aborts the comparison if the number of tokens is too large.
- 
Constructor Details- 
DocLineComparatorCreates aDocLineComparatorfor the given document range. ignoreWhiteSpace controls whether comparing lines (in methodrangesEqual) should ignore whitespace.- Parameters:
- document- the document from which the lines are taken
- region- if non-- nullonly lines within this range are taken
- ignoreWhiteSpace- if- truewhite space is ignored when comparing lines
 
- 
DocLineComparatorpublic DocLineComparator(IDocument document, IRegion region, boolean ignoreWhiteSpace, ICompareFilter[] compareFilters, char contributor, Optional<IIgnoreWhitespaceContributor> ignoreWhitespaceContributor) Creates aDocLineComparatorfor the given document range. ignoreWhiteSpace controls whether comparing lines (in methodrangesEqual) should ignore whitespace. Compare filters may be used to affect the detection of line differences.- Parameters:
- document- the document from which the lines are taken
- region- if non-- nullonly lines within this range are taken
- ignoreWhiteSpace- if- truewhite space is ignored when comparing lines
- compareFilters- the active compare filters for the compare
- contributor- contributor of document
- ignoreWhitespaceContributor- contributor for ignore whitespace logic, empty optional allowed, but- nullis not allowed
 
 
- 
- 
Method Details- 
getRangeCountpublic int getRangeCount()Returns the number of lines in the document.- Specified by:
- getRangeCountin interface- IRangeComparator
- Returns:
- number of lines
 
- 
getTokenStartpublic int getTokenStart(int line) Description copied from interface:ITokenComparatorReturns the start character position of the token with the given index. If the index is out of range (but not negative) the character position behind the last character (the length of the input string) is returned.- Specified by:
- getTokenStartin interface- ITokenComparator
- Parameters:
- line- index of the token for which to return the start position
- Returns:
- the start position of the token with the given index
 
- 
getTokenLengthpublic int getTokenLength(int line) Description copied from interface:ITokenComparatorReturns the character length of the token with the given index. If the index is out of range (but not negative) the value 0 is returned.- Specified by:
- getTokenLengthin interface- ITokenComparator
- Parameters:
- line- index of the token for which to return the start position
- Returns:
- the character length of the token with the given index
 
- 
rangesEqualReturnstrueif a line given by the first index matches a line specified by the otherIRangeComparatorand index.- Specified by:
- rangesEqualin interface- IRangeComparator
- Parameters:
- thisIndex- the number of the line within this range comparator
- otherComparator- the range comparator to compare this with
- otherIndex- the number of the line within the other comparator
- Returns:
- trueif the lines are equal
 
- 
skipRangeComparisonAborts the comparison if the number of tokens is too large.- Specified by:
- skipRangeComparisonin interface- IRangeComparator
- Parameters:
- length- a number on which to base the decision whether to return- trueor- false
- maxLength- another number on which to base the decision whether to return- trueor- false
- other- the other- IRangeComparatorto compare with
- Returns:
- trueto avoid a too lengthy range comparison
 
 
-