Oracle Coherence for C++ API
Release 3.6.1.0

E18813-01

ComparisonValueExtractor Class Reference

#include <coherence/util/extractor/ComparisonValueExtractor.hpp>

Inherits AbstractCompositeExtractor.

List of all members.


Detailed Description

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);
 
Author:
djl 2008.04.11
See also:
ChainedExtractor

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.

Parameters:
ohTarget  an Object to retrieve the value from
Returns:
the extracted value; NULL is an acceptable value
Exceptions:
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

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).

Constructor & Destructor Documentation

ComparisonValueExtractor ( ValueExtractor::View  vE1,
ValueExtractor::View  vE2,
Comparator::View  vComp = NULL  
) [protected]

Constuct a ComparisonValueExtractor based on two specified extractors and a Comparator object.

Parameters:
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

Member Function Documentation

virtual Object::Holder extract ( Object::Holder  ohTarget  )  const [virtual]

Extract the value from the passed object.

The returned value may be NULL.

Parameters:
ohTarget  an Object to retrieve the value from
Returns:
the extracted value; NULL is an acceptable value
Exceptions:
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
Exceptions:
UnsupportedOperationException  always

Reimplemented from AbstractExtractor.

virtual Comparator::View getComparator (  )  const [virtual]

Return a Comparator used by this extractor.

Returns:
a Comparator used by this extractor; null if the natural value comparison should be used

The documentation for this class was generated from the following file:
Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.