Show / Hide Table of Contents

Class ComparisonValueExtractor

A synthetic IValueExtractor that returns a result of comparison between two values extracted from the same target.

Inheritance
object
AbstractExtractor
AbstractCompositeExtractor
ComparisonValueExtractor
Implements
IValueExtractor
IQueryCacheComparer
IComparer
IPortableObject
Inherited Members
AbstractCompositeExtractor.Extractors
AbstractCompositeExtractor.Equals(object)
AbstractCompositeExtractor.GetHashCode()
AbstractCompositeExtractor.ToString()
AbstractCompositeExtractor.m_extractors
AbstractExtractor.Target
AbstractExtractor.Compare(object, object)
AbstractExtractor.CompareEntries(IQueryCacheEntry, IQueryCacheEntry)
AbstractExtractor.ExtractFromEntry(ICacheEntry)
AbstractExtractor.ExtractOriginalFromEntry(CacheEntry)
AbstractExtractor.VALUE
AbstractExtractor.KEY
AbstractExtractor.m_target
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: Tangosol.Util.Extractor
Assembly: Coherence.dll
Syntax
public class ComparisonValueExtractor : AbstractCompositeExtractor, IValueExtractor, IQueryCacheComparer, IComparer, IPortableObject
Remarks

In a most general case, the extracted value represents an integer value calculated accordingly to the contract of CompareTo(object) or Compare(object, object) 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 .NET type of the comparing values will dictate the .NET 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 extractDiff = new ComparisonValueExtractor(
  new ReflectionExtractor("SellPrice"),
  new ReflectionExtractor("BuyPrice"));
Filter filter = new LessFilter(extractDiff, 0.0);
ICollection entries = cache.GetEntries(filter);

Constructors

ComparisonValueExtractor()

Default constructor.

Declaration
public ComparisonValueExtractor()

ComparisonValueExtractor(string, string)

Construct a ComparisonValueExtractor based on two member names.

Declaration
public ComparisonValueExtractor(string member1, string member2)
Parameters
Type Name Description
string member1

The name of the first member to invoke via reflection.

string member2

The name of the second member to invoke via reflection.

Remarks

Note: values returned by both methods must be IComparable.

ComparisonValueExtractor(string, string, IComparer)

Construct a ComparisonValueExtractor based on two method names and a IComparer object.

Declaration
public ComparisonValueExtractor(string member1, string member2, IComparer comp)
Parameters
Type Name Description
string member1

The name of the first member to invoke via reflection.

string member2

The name of the second member to invoke via reflection.

IComparer comp

The comparer used to compare the extracted values (optional).

ComparisonValueExtractor(IValueExtractor, IValueExtractor)

Construct a ComparisonValueExtractor based on two specified extractors.

Declaration
public ComparisonValueExtractor(IValueExtractor ve1, IValueExtractor ve2)
Parameters
Type Name Description
IValueExtractor ve1

The IValueExtractor for the first value.

IValueExtractor ve2

The IValueExtractor for the second value.

Remarks

Note: values returned by both extractors must be IComparable.

ComparisonValueExtractor(IValueExtractor, IValueExtractor, IComparer)

Construct a ComparisonValueExtractor based on two specified extractors and a IComparer object.

Declaration
public ComparisonValueExtractor(IValueExtractor ve1, IValueExtractor ve2, IComparer comp)
Parameters
Type Name Description
IValueExtractor ve1

The IValueExtractor for the first value.

IValueExtractor ve2

The IValueExtractor for the second value.

IComparer comp

The comparer used to compare the extracted values (optional).

ComparisonValueExtractor(IValueExtractor[])

Construct a ComparisonValueExtractor based on a specified IValueExtractor array.

Declaration
public ComparisonValueExtractor(IValueExtractor[] extractors)
Parameters
Type Name Description
IValueExtractor[] extractors

The IValueExtractor array.

Fields

m_comparer

An underlying IComparer object (optional).

Declaration
protected IComparer m_comparer
Field Value
Type Description
IComparer

Properties

Comparer

Return an IComparer used by this extractor.

Declaration
public virtual IComparer Comparer { get; }
Property Value
Type Description
IComparer

An IComparer used by this extractor; null if the natural value comparison should be used.

Methods

Extract(object)

Extract the value from the passed object.

Declaration
public override object Extract(object obj)
Parameters
Type Name Description
object obj

An object to retrieve the value from.

Returns
Type Description
object

The extracted value as an object; null is an acceptable value.

Overrides
AbstractExtractor.Extract(object)
Remarks

The returned value may be null.

Exceptions
Type Condition
InvalidCastException

If this IValueExtractor is incompatible with the passed object to extract a value from and the implementation requires the passed object to be of a certain type.

ArgumentException

If this AbstractExtractor cannot handle the passed object for any other reason; an implementor should include a descriptive message.

GetStreamFormat(object)

Select an optimal stream format to use to store the passed object in a stream.

Declaration
protected static ComparisonValueExtractor.StreamFormat GetStreamFormat(object o)
Parameters
Type Name Description
object o

An object.

Returns
Type Description
ComparisonValueExtractor.StreamFormat

A stream format to use to store the object in a stream.

ReadExternal(IPofReader)

Restore the contents of a user type instance by reading its state using the specified IPofReader object.

Declaration
public override void ReadExternal(IPofReader reader)
Parameters
Type Name Description
IPofReader reader

The IPofReader from which to read the object's state.

Overrides
AbstractCompositeExtractor.ReadExternal(IPofReader)
Exceptions
Type Condition
IOException

If an I/O error occurs.

WriteExternal(IPofWriter)

Save the contents of a POF user type instance by writing its state using the specified IPofWriter object.

Declaration
public override void WriteExternal(IPofWriter writer)
Parameters
Type Name Description
IPofWriter writer

The IPofWriter to which to write the object's state.

Overrides
AbstractCompositeExtractor.WriteExternal(IPofWriter)
Exceptions
Type Condition
IOException

If an I/O error occurs.

Implements

IValueExtractor
IQueryCacheComparer
IComparer
IPortableObject
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.