Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.util.extractor
Class AbstractExtractor

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.BitHelper
          extended by com.tangosol.util.ExternalizableHelper
              extended by com.tangosol.util.extractor.AbstractExtractor

All Implemented Interfaces:
QueryMapComparator, ValueExtractor, java.io.Serializable, java.util.Comparator
Direct Known Subclasses:
AbstractCompositeExtractor, ConditionalExtractor, EntryExtractor, IdentityExtractor, KeyExtractor, PofExtractor, ReflectionExtractor

public abstract class AbstractExtractor
extends ExternalizableHelper
implements ValueExtractor, QueryMapComparator, java.io.Serializable

Abstract base for ValueExtractor implementations. It provides common functionality that allows any extending extractor to be used as a value Comparator.

Starting with Coherence 3.5, when used to extract information that is coming from a Map, subclasses have the additional ability to operate against the Map.Entry instead of just the value. In other words, like the EntryExtractor class, this allows an extractor implementation to extract a desired value using all available information on the corresponding Map.Entry object and is intended to be used in advanced custom scenarios, when application code needs to look at both key and value at the same time or can make some very specific assumptions regarding to the implementation details of the underlying Entry object. To maintain full backwards compatibility, the default behavior remains to extract from the Value property of the Map.Entry.

Note: subclasses are responsible for initialization and POF and/or Lite serialization of the m_nTarget field.

Author:
gg 2003.09.22

Field Summary
static int KEY
          Indicates that the extractFromEntry(java.util.Map.Entry) operation should use the Entry's key.
protected  int m_nTarget
          Specifies which part of the entry should be used by the extractFromEntry(java.util.Map.Entry) operation.
static int VALUE
          Indicates that the extractFromEntry(java.util.Map.Entry) operation should use the Entry's value.

 

Constructor Summary
AbstractExtractor()
           

 

Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares its two arguments for order.
 int compareEntries(QueryMap.Entry entry1, QueryMap.Entry entry2)
          Compare two entries based on the rules specified by Comparator.
 java.lang.Object extract(java.lang.Object oTarget)
          Extract the value from the passed object.
 java.lang.Object extractFromEntry(java.util.Map.Entry entry)
          Extract the value from the passed Entry object.
 java.lang.Object extractOriginalFromEntry(MapTrigger.Entry entry)
          Extract the value from the "original value" of the passed Entry object.

 

Methods inherited from class com.tangosol.util.BitHelper
countBits, countBits, countBits, indexOfLSB, indexOfLSB, indexOfLSB, indexOfMSB, indexOfMSB, indexOfMSB, rotateLeft, rotateLeft, rotateLeft, rotateRight, rotateRight, rotateRight, toBitString, toBitString, toBitString

 

Methods inherited from interface com.tangosol.util.ValueExtractor
equals, hashCode, toString

 

Methods inherited from interface java.util.Comparator
equals

 

Field Detail

VALUE

public static final int VALUE
Indicates that the extractFromEntry(java.util.Map.Entry) operation should use the Entry's value.
Since:
Coherence 3.5
See Also:
Constant Field Values

KEY

public static final int KEY
Indicates that the extractFromEntry(java.util.Map.Entry) operation should use the Entry's key.
Since:
Coherence 3.5
See Also:
Constant Field Values

m_nTarget

protected int m_nTarget
Specifies which part of the entry should be used by the extractFromEntry(java.util.Map.Entry) operation. Legal values are VALUE (default) or KEY.

Note: subclasses are responsible for initialization and POF and/or Lite serialization of this field.

Since:
Coherence 3.5

Constructor Detail

AbstractExtractor

public AbstractExtractor()

Method Detail

extract

public java.lang.Object extract(java.lang.Object oTarget)
Extract the value from the passed object. The returned value may be null. For intrinsic types, the returned value is expected to be a standard wrapper type in the same manner that reflection works; for example, int would be returned as a java.lang.Integer.
Specified by:
extract in interface ValueExtractor
Parameters:
oTarget - an Object to retrieve the value from
Returns:
the extracted value as an Object; null is an acceptable value

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
Specified by:
compare in interface java.util.Comparator
Parameters:
o1 - the first object to be compared
o2 - the second object to be compared
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
Throws:
java.lang.ClassCastException - if the arguments' types prevent them from being compared by this Comparator.

compareEntries

public int compareEntries(QueryMap.Entry entry1,
                          QueryMap.Entry entry2)
Compare two entries based on the rules specified by Comparator.

If possible, use the extract method to optimize the value extraction process.

This method is expected to be implemented by Comparator wrappers, such as ChainedComparator and InverseComparator, which simply pass on this invocation to the wrapped Comparator objects if they too implement this interface, or to invoke their default compare method passing the actual objects (not the extracted values) obtained from the extractor using the passed entries.

This interface is also expected to be implemented by ValueExtractor implementations that implement the Comparator interface. It is expected that in most cases, the Comparator wrappers will eventually terminate at (i.e. delegate to) ValueExtractors that also implement this interface.

Specified by:
compareEntries in interface QueryMapComparator
Parameters:
entry1 - the first entry to compare values from; read-only
entry2 - the second entry to compare values from; read-only
Returns:
a negative integer, zero, or a positive integer as the first entry denotes a value that is is less than, equal to, or greater than the value denoted by the second entry

extractFromEntry

public java.lang.Object extractFromEntry(java.util.Map.Entry entry)
Extract the value from the passed Entry object. The returned value should follow the conventions outlined in the extract(java.lang.Object) method. By overriding this method, an extractor implementation is able to extract a desired value using all available information on the corresponding Map.Entry object and is intended to be used in advanced custom scenarios, when application code needs to look at both key and value at the same time or can make some very specific assumptions regarding to the implementation details of the underlying Entry object.
Parameters:
entry - an Entry object to extract a desired value from
Returns:
the extracted value
Since:
Coherence 3.5

extractOriginalFromEntry

public java.lang.Object extractOriginalFromEntry(MapTrigger.Entry entry)
Extract the value from the "original value" of the passed Entry object. This method's conventions are exactly the same as for the extractFromEntry(java.util.Map.Entry) method.
Parameters:
entry - an Entry object whose original value should be used to extract the desired value from
Returns:
the extracted value or null if the original value is not present
Since:
Coherence 3.6

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.