CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.util.extractor
Class AbstractExtractor

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.extractor.AbstractExtractor
All Implemented Interfaces:
QueryMapComparator, ValueExtractor, Serializable, Comparator
Direct Known Subclasses:
AbstractCompositeExtractor, IdentityExtractor, KeyExtractor, ReflectionExtractor

public abstract class AbstractExtractor
extends Base
implements ValueExtractor, QueryMapComparator, Serializable

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

Author:
gg 2003.09.22
See Also:
ChainedComparator, InverseComparator

Constructor Summary
AbstractExtractor()
           
 
Method Summary
 int compare(Object o1, 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.
abstract  Object extract(Object oTarget)
          Extract the value from the passed object.
 
Methods inherited from interface com.tangosol.util.ValueExtractor
equals, hashCode, toString
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

AbstractExtractor

public AbstractExtractor()
Method Detail

extract

public abstract Object extract(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(Object o1,
                   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 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:
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

CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation