net.sf.jec.namedop
Class ContextComparator

java.lang.Object
  extended bynet.sf.jec.namedop.ContextComparator
All Implemented Interfaces:
java.util.Comparator

public class ContextComparator
extends java.lang.Object
implements java.util.Comparator

ContextComparator applies the Operator passed to its constructor to each Object, given its context, and compares the results. Thus the result of this comparisson is just one order relation and is not consistent with equals.

Note:this comparator imposes orderings that are inconsistent with equals

Author:
mballesteros

Constructor Summary
ContextComparator(java.lang.Object rootCtx, Operator operator)
          Creates a new ContextComparator given the Operator and context Object needed to complete the expression whose result will be compared.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares its two arguments for order.
 
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
 

Constructor Detail

ContextComparator

public ContextComparator(java.lang.Object rootCtx,
                         Operator operator)
Creates a new ContextComparator given the Operator and context Object needed to complete the expression whose result will be compared.

Parameters:
rootCtx - Context object.
operator - Operator.
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
            throws java.lang.ClassCastException
Compares its two arguments for order.

Specified by:
compare in interface java.util.Comparator
Parameters:
o1 - First argument to compare.
o2 - Second argument to compare.
Returns:
Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
Throws:
java.lang.ClassCastException - when the Operator results are not Comparable or when one EvaluationException is thrown from the evaluation of the operator.


Copyright © 2003 SourceForge. All Rights Reserved.