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()
IRangeComparator
getRangeCount
in interface IRangeComparator
public int getTokenStart(int index)
ITokenComparator
getTokenStart
in interface ITokenComparator
index
- index of the token for which to return the start positionpublic int getTokenLength(int index)
ITokenComparator
getTokenLength
in interface ITokenComparator
index
- index of the token for which to return the start positionpublic boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex)
IRangeComparator
IRangeComparator
and index.rangesEqual
in interface IRangeComparator
thisIndex
- the index of the comparable entity within this IRangeComparator
other
- the IRangeComparator to compare this withotherIndex
- the index of the comparable entity within the other IRangeComparator
true
if the comparable entities are equalpublic boolean skipRangeComparison(int length, int max, IRangeComparator other)
IRangeComparator
skipRangeComparison
in interface IRangeComparator
length
- a number on which to base the decision whether to return
true
or false
max
- another number on which to base the decision whether to return
true
or false
other
- 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.