Show / Hide Table of Contents

Class KeyExtractor

The KeyExtractor is a special purpose IValueExtractor implementation that serves as an indicator that a query should be run against the key objects rather than the values.

Inheritance
object
AbstractExtractor
KeyExtractor
Implements
IValueExtractor
IQueryCacheComparer
IComparer
IPortableObject
Inherited Members
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 KeyExtractor : AbstractExtractor, IValueExtractor, IQueryCacheComparer, IComparer, IPortableObject
Remarks

The major difference between the KeyExtractor and a standard ReflectionExtractor is that when used in various IFilter implementations it forces the evaluation of entry keys rather than entry values.

For example, consider a key object that consists of two properties: "FirstName" and "LastName". To retrieve all keys that have a value of the "LastName" property equal to "Smith", the following query could be used:

IValueExtractor extractor = new KeyExtractor("LastName");
ICollection keys = cache.GetKeys(new EqualsFilter(extractor, "Smith"));
As of Coherence 3.5, the same effect can be achieved for subclasses of the AbstractExtractor, for example:
IValueExtractor extractor = new ReflectionExtractor("LastName", 
null,AbstractExtractor.KEY);
ICollection keys = cache.GetKeys(new EqualsFilter(extractor, "Smith"));

Constructors

KeyExtractor()

Default constructor.

Declaration
public KeyExtractor()

KeyExtractor(string)

Construct a KeyExtractor for a specified member name.

Declaration
public KeyExtractor(string member)
Parameters
Type Name Description
string member

A member name to construct an underlying ReflectionExtractor for; this parameter can also be a dot-delimited sequence of member names which would result in a KeyExtractor based on the ChainedExtractor that is based on an array of corresponding ReflectionExtractor objects.

KeyExtractor(IValueExtractor)

Construct a KeyExtractor based on a specified IValueExtractor.

Declaration
public KeyExtractor(IValueExtractor extractor)
Parameters
Type Name Description
IValueExtractor extractor

The underlying IValueExtractor.

Fields

m_extractor

The underlying IValueExtractor.

Declaration
protected IValueExtractor m_extractor
Field Value
Type Description
IValueExtractor

Properties

Extractor

The underlying IValueExtractor.

Declaration
public virtual IValueExtractor Extractor { get; }
Property Value
Type Description
IValueExtractor

The underlying IValueExtractor.

Methods

Equals(object)

Compare the KeyExtractor with another object to determine equality.

Declaration
public override bool Equals(object o)
Parameters
Type Name Description
object o

The reference object with which to compare.

Returns
Type Description
bool

true if this KeyExtractor and the passed object are equivalent.

Overrides
object.Equals(object)
Remarks

Two KeyExtractor objects are considered equal if their underlying IValueExtractors are equal.

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.

GetHashCode()

Determine a hash value for the KeyExtractor object according to the general Object.GetHashCode contract.

Declaration
public override int GetHashCode()
Returns
Type Description
int

An integer hash value for this IValueExtractor object.

Overrides
object.GetHashCode()

ReadExternal(IPofReader)

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

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

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

Exceptions
Type Condition
IOException

If an I/O error occurs.

ToString()

Provide a human-readable description of this KeyExtractor object.

Declaration
public override string ToString()
Returns
Type Description
string

A human-readable description of this KeyExtractor object.

Overrides
object.ToString()

WriteExternal(IPofWriter)

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

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

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

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.