#include <coherence/util/extractor/ComparisonValueExtractor.hpp>
Inherits AbstractCompositeExtractor.
In a most general case, the extracted value represents an Integer value calculated accordingly to the contract of Comparable::compareTo or Comparator::compare methods. However, in more specific cases, when the compared values are of common numeric type, the ComparisonValueExtractor will return a numeric difference between those values. The type of the comparing values will dictate the type of the result.
For example, lets assume that a cache contains business objects that have two properties: SellPrice and BuyPrice (both double). Then, to query for all objects that have SellPrice less than BuyPrice we would use the following:
 ValueExtractor::View extractDiff = ComparisonValueExtractor::create(
   ReflectionExtractor::create(String::create("getSellPrice")),
   ReflectionExtractor::create(String::create("getBuyPrice")));
 Filter::View vfilter = LessFilter::create(extractDiff, Double::create(0.0));
 Set::View entries = cache->entrySet(vfilter);
 
Public Types | |
| typedef spec::Handle | Handle | 
| ComparisonValueExtractor Handle definition.  | |
| typedef spec::View | View | 
| ComparisonValueExtractor View definition.  | |
| typedef spec::Holder | Holder | 
| ComparisonValueExtractor Holder definition.  | |
Public Member Functions | |
| virtual Object::Holder | extract (Object::Holder ohTarget) const | 
|   | |
| virtual void | readExternal (PofReader::Handle hIn) | 
| virtual void | writeExternal (PofWriter::Handle hOut) const | 
| virtual Comparator::View | getComparator () const | 
| Return a Comparator used by this extractor.   | |
Protected Member Functions | |
| ComparisonValueExtractor () | |
| Construct an empty ComparisonValueExtractor (necessary for the PortableObject interface).  | |
| ComparisonValueExtractor (ValueExtractor::View vE1, ValueExtractor::View vE2, Comparator::View vComp=NULL) | |
| Constuct a ComparisonValueExtractor based on two specified extractors and a Comparator object.   | |
Protected Attributes | |
| FinalView< Comparator > | f_vComparator | 
| An underlying Comparator object (optional).  | |
| ComparisonValueExtractor | ( | ValueExtractor::View | vE1, | |
| ValueExtractor::View | vE2, | |||
| Comparator::View |  vComp = NULL | |||
| ) |  [protected] | 
        
Constuct a ComparisonValueExtractor based on two specified extractors and a Comparator object.
| vE1 | the ValueExtractor for the first value | |
| vE2 | the ValueExtractor for the second value | |
| vComp | the comparator used to compare the extracted values (optional); if NULL, the values returned by both extractors must be Comparable | 
| virtual Object::Holder extract | ( | Object::Holder | ohTarget | ) |  const [virtual] | 
        
| virtual Comparator::View getComparator | ( | ) |  const [virtual] | 
        
Return a Comparator used by this extractor.