Class TokenComparator
java.lang.Object
org.eclipse.compare.contentmergeviewer.TokenComparator
- All Implemented Interfaces:
- ITokenComparator,- IRangeComparator
Implements the 
ITokenComparator interface for words (or tokens)
 in a string.
 A TokenComparator is used as the input for the RangeDifferencer
 engine to perform a token oriented compare on strings.
 This class may be instantiated by clients but is not intended to be subclassed.
- Since:
- 3.4
- 
Constructor SummaryConstructorsConstructorDescriptionTokenComparator(String text) Creates aTokenComparatorfor the given string.
- 
Method SummaryModifier and TypeMethodDescriptionintReturns the number of comparable entities.intgetTokenLength(int index) Returns the character length of the token with the given index.intgetTokenStart(int index) Returns the start character position of the token with the given index.booleanrangesEqual(int thisIndex, IRangeComparator other, int otherIndex) Returns whether the comparable entity given by the first index matches an entity specified by the otherIRangeComparatorand index.booleanskipRangeComparison(int length, int max, IRangeComparator other) Returns whether a comparison should be skipped because it would be too costly (or lengthy).
- 
Constructor Details- 
TokenComparatorCreates aTokenComparatorfor the given string.- Parameters:
- text- the string that is split into token
 
 
- 
- 
Method Details- 
getRangeCountpublic int getRangeCount()Description copied from interface:IRangeComparatorReturns the number of comparable entities.- Specified by:
- getRangeCountin interface- IRangeComparator
- Returns:
- the number of comparable entities
 
- 
getTokenStartpublic int getTokenStart(int index) 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:
- index- 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 index) 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:
- index- index of the token for which to return the start position
- Returns:
- the character length of the token with the given index
 
- 
rangesEqualDescription copied from interface:IRangeComparatorReturns whether the comparable entity given by the first index matches an entity specified by the otherIRangeComparatorand index.- Specified by:
- rangesEqualin interface- IRangeComparator
- Parameters:
- thisIndex- the index of the comparable entity within this- IRangeComparator
- other- the IRangeComparator to compare this with
- otherIndex- the index of the comparable entity within the other- IRangeComparator
- Returns:
- trueif the comparable entities are equal
 
- 
skipRangeComparisonDescription copied from interface:IRangeComparatorReturns whether a comparison should be skipped because it would be too costly (or lengthy).- Specified by:
- skipRangeComparisonin interface- IRangeComparator
- Parameters:
- length- a number on which to base the decision whether to return- trueor- false
- max- 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
 
 
-