Tokens and Types : Comparing Token Values
 
Share this page                  
Comparing Token Values
Comparison of token values must take null-valued tokens into account because there are special semantics associated with them. The methods provided in the DataFlow libraries will do this.
When the token types are statically known, the utilities of TokenUtils can be used:
IntValued left = ...;
IntValued right = ...;
int result = TokenUtil.compare(left, right);
When the token types are not statically known, a TokenComparator object must be used instead:
// Exact types unknown, but known to be comparable to each other
ScalarValued left = ...;
ScalarValued right = ...;
TokenComparator comparator = TokenComparators.getComparator(left,right);
int result = comparator.compare();
...