public class TokenComparator extends Object implements ITokenComparator
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.
| Constructor and Description |
|---|
TokenComparator(String text)
Creates a
TokenComparator for the given string. |
| Modifier and Type | Method and Description |
|---|---|
int |
getRangeCount()
Returns the number of comparable entities.
|
int |
getTokenLength(int index)
Returns the character length of the token with the given index.
|
int |
getTokenStart(int index)
Returns the start character position of the token with the given index.
|
boolean |
rangesEqual(int thisIndex,
IRangeComparator other,
int otherIndex)
Returns whether the comparable entity given by the first index
matches an entity specified by the other
IRangeComparator and index. |
boolean |
skipRangeComparison(int length,
int max,
IRangeComparator other)
Returns whether a comparison should be skipped because it would be too costly (or lengthy).
|
public TokenComparator(String text)
TokenComparator for the given string.text - the string that is split into tokenpublic int getRangeCount()
IRangeComparatorgetRangeCount in interface IRangeComparatorpublic int getTokenStart(int index)
ITokenComparatorgetTokenStart in interface ITokenComparatorindex - index of the token for which to return the start positionpublic int getTokenLength(int index)
ITokenComparatorgetTokenLength in interface ITokenComparatorindex - index of the token for which to return the start positionpublic boolean rangesEqual(int thisIndex,
IRangeComparator other,
int otherIndex)
IRangeComparatorIRangeComparator and index.rangesEqual in interface IRangeComparatorthisIndex - the index of the comparable entity within this IRangeComparatorother - the IRangeComparator to compare this withotherIndex - the index of the comparable entity within the other IRangeComparatortrue if the comparable entities are equalpublic boolean skipRangeComparison(int length,
int max,
IRangeComparator other)
IRangeComparatorskipRangeComparison in interface IRangeComparatorlength - a number on which to base the decision whether to return
true or falsemax - another number on which to base the decision whether to return
true or falseother - the other IRangeComparator to compare withtrue to avoid a too lengthy range comparison
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.