Oracle Coherence for C++ API
Release 3.7.1.0
E22845-01
#include <coherence/util/extractor/ComparisonValueExtractor.hpp>
Inherits AbstractCompositeExtractor.
A synthetic ValueExtractor that returns a result of comparison between two values extracted from the same target.
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 | ||||||||||||
| Extract the value from the passed object.
The returned value may be NULL.
|
|||||||||||||
| 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 |
|||||||||||||
| MemberView< Comparator > | m_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] |
Extract the value from the passed object.
The returned value may be NULL.
| ohTarget | an Object to retrieve the value from |
| ClassCastException | if this ValueExtractor is incompatible with the passed object to extract a value from and the implementation requires the passed object to be of a certain type | |
| Exception | if this ValueExtractor encounters an exception in the course of extracting the value | |
| IllegalArgumentException | if this ValueExtractor cannot handle the passed object for any other reason; an implementor should include a descriptive message |
| UnsupportedOperationException | always |
Reimplemented from AbstractExtractor.
| virtual Comparator::View getComparator | ( | ) | const [virtual] |
Return a Comparator used by this extractor.
The documentation for this class was generated from the following file: