Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.compare.contentmergeviewer
Class TokenComparator


java.lang.Object
  extended by 
org.eclipse.compare.contentmergeviewer.TokenComparator
All Implemented Interfaces:
ITokenComparator, IRangeComparator

public class TokenComparator
extends Object
implements ITokenComparator

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 Summary
TokenComparator ( String text)
          Creates a TokenComparator for the given string.
 
Method Summary
 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).
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenComparator

public TokenComparator(
String text)
Creates a TokenComparator for the given string.

Parameters:
text - the string that is split into token
Method Detail

getRangeCount

public int getRangeCount()
Description copied from interface: IRangeComparator
Returns the number of comparable entities.

Specified by:
getRangeCount in interface IRangeComparator
Returns:
the number of comparable entities

getTokenStart

public int getTokenStart(int index)
Description copied from interface: ITokenComparator
Returns 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:
getTokenStart in 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

getTokenLength

public int getTokenLength(int index)
Description copied from interface: ITokenComparator
Returns 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:
getTokenLength in 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

rangesEqual

public boolean rangesEqual(int thisIndex,
                           
IRangeComparator other,
                           int otherIndex)
Description copied from interface: IRangeComparator
Returns whether the comparable entity given by the first index matches an entity specified by the other IRangeComparator and index.

Specified by:
rangesEqual in 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:
true if the comparable entities are equal

skipRangeComparison

public boolean skipRangeComparison(int length,
                                   int max,
                                   
IRangeComparator other)
Description copied from interface: IRangeComparator
Returns whether a comparison should be skipped because it would be too costly (or lengthy).

Specified by:
skipRangeComparison in interface IRangeComparator
Parameters:
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 with
Returns:
true to avoid a too lengthy range comparison

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire