ptolemy.data.expr
Class UtilityFunctions.TokenComparator

java.lang.Object
  extended by ptolemy.data.expr.UtilityFunctions.TokenComparator
All Implemented Interfaces:
java.util.Comparator
Enclosing class:
UtilityFunctions

private static class UtilityFunctions.TokenComparator
extends java.lang.Object
implements java.util.Comparator

Comparator for tokens.


Field Summary
private  boolean _ascending
           
 
Constructor Summary
UtilityFunctions.TokenComparator(boolean ascending)
          Construct a new comparator.
 
Method Summary
 int compare(java.lang.Object arg0, java.lang.Object arg1)
          Return -1, 0, or 1 depending on whether the first argument is less than, equal to, or greater than the second.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

_ascending

private boolean _ascending
Constructor Detail

UtilityFunctions.TokenComparator

public UtilityFunctions.TokenComparator(boolean ascending)
Construct a new comparator.

Parameters:
ascending - True for ascending comparisons.
Method Detail

compare

public int compare(java.lang.Object arg0,
                   java.lang.Object arg1)
            throws java.lang.ClassCastException
Return -1, 0, or 1 depending on whether the first argument is less than, equal to, or greater than the second. If the argument to the constructor was false, then return the converse (to get descending sorts). The arguments are expected to be instances of Token, and in particular, to be instances of ScalarToken (except ComplexToken) or StringToken; otherwise a ClassCastException will be thrown.

Specified by:
compare in interface java.util.Comparator
Parameters:
arg0 - The first argument to compare.
arg1 - The second argument to compare.
Returns:
The result of comparison.
Throws:
java.lang.ClassCastException - If the arguments cannot be compared.