Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.util.filter
Class ComparisonFilter

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.filter.ExtractorFilter
                  extended by com.tangosol.util.filter.ComparisonFilter

All Implemented Interfaces:
ExternalizableLite, PortableObject, Filter, EntryFilter, java.io.Serializable
Direct Known Subclasses:
ContainsAllFilter, ContainsAnyFilter, ContainsFilter, EqualsFilter, GreaterEqualsFilter, GreaterFilter, InFilter, LessEqualsFilter, LessFilter, LikeFilter, NotEqualsFilter, RegexFilter

public abstract class ComparisonFilter
extends ExtractorFilter

Filter which compares the result of a method invocation with a value.

Author:
cp/gg 2002.10.27

Field Summary
protected  java.lang.Object m_oValue
          The value to compare to.

 

Fields inherited from class com.tangosol.util.filter.ExtractorFilter
EVAL_COST, m_extractor

 

Constructor Summary
ComparisonFilter()
          Default constructor (necessary for the ExternalizableLite interface).
ComparisonFilter(java.lang.String sMethod, java.lang.Object oValue)
          Construct a ComparisonFilter.
ComparisonFilter(ValueExtractor extractor, java.lang.Object oValue)
          Construct a ComparisonFilter.

 

Method Summary
static int calculateIteratorEffectiveness(int cKeys)
          Helper method to calculate effectiveness (or rather ineffectiveness) of a simple iteration against a key set that has to be performed due to an absence of corresponding index.
protected  int calculateMatchEffectiveness(java.util.Map mapIndexes, java.util.Set setKeys)
          Helper method to calculate effectiveness for ComparisonFilters that need no more than a single index match in order to retrieve all necessary keys to perform the applyIndex() operation.
protected  int calculateRangeEffectiveness(java.util.Map mapIndexes, java.util.Set setKeys)
          Helper method to calculate effectiveness for ComparisonFilters that need a range of values from an index in order to retrieve all necessary keys to perform the applyIndex() operation.
 boolean equals(java.lang.Object o)
          Compare the ComparisonFilter with another object to determine equality.
 java.lang.Object getValue()
          Get the object to compare the reflection result with.
 int hashCode()
          Determine a hash value for the ComparisonFilter object according to the general Object.hashCode() contract.
 void readExternal(java.io.DataInput in)
          Restore the contents of this object by loading the object's state from the passed DataInput object.
 void readExternal(PofReader in)
          Restore the contents of a user type instance by reading its state using the specified PofReader object.
 java.lang.String toString()
          Return a human-readable description for this Filter.
 void writeExternal(java.io.DataOutput out)
          Save the contents of this object by storing the object's state into the passed DataOutput object.
 void writeExternal(PofWriter out)
          Save the contents of a POF user type instance by writing its state using the specified PofWriter object.

 

Methods inherited from class com.tangosol.util.filter.ExtractorFilter
evaluate, evaluateEntry, evaluateExtracted, extract, getValueExtractor

 

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

 

Field Detail

m_oValue

protected java.lang.Object m_oValue
The value to compare to.

Constructor Detail

ComparisonFilter

public ComparisonFilter()
Default constructor (necessary for the ExternalizableLite interface).

ComparisonFilter

public ComparisonFilter(ValueExtractor extractor,
                        java.lang.Object oValue)
Construct a ComparisonFilter.
Parameters:
extractor - the ComparisonFilter to use by this filter
oValue - the object to compare the result with

ComparisonFilter

public ComparisonFilter(java.lang.String sMethod,
                        java.lang.Object oValue)
Construct a ComparisonFilter.
Parameters:
sMethod - the name of the method to invoke via reflection
oValue - the object to compare the result with

Method Detail

getValue

public java.lang.Object getValue()
Get the object to compare the reflection result with.
Returns:
the object to compare the reflection result with

calculateMatchEffectiveness

protected int calculateMatchEffectiveness(java.util.Map mapIndexes,
                                          java.util.Set setKeys)
Helper method to calculate effectiveness for ComparisonFilters that need no more than a single index match in order to retrieve all necessary keys to perform the applyIndex() operation. Such filters are: Contains, Equals, NotEquals.
Parameters:
mapIndexes - the available MapIndex objects keyed by the related ValueExtractor; read-only
setKeys - the set of keys that will be filtered; read-only
Returns:
an effectiveness estimate of how well this filter can use the specified indexes to filter the specified keys

calculateRangeEffectiveness

protected int calculateRangeEffectiveness(java.util.Map mapIndexes,
                                          java.util.Set setKeys)
Helper method to calculate effectiveness for ComparisonFilters that need a range of values from an index in order to retrieve all necessary keys to perform the applyIndex() operation. Such filters are: Less, LessEquals, Greater, GreaterEquals.
Parameters:
mapIndexes - the available MapIndex objects keyed by the related ValueExtractor; read-only
setKeys - the set of keys that will be filtered; read-only
Returns:
an effectiveness estimate of how well this filter can use the specified indexes to filter the specified keys

calculateIteratorEffectiveness

public static int calculateIteratorEffectiveness(int cKeys)
Helper method to calculate effectiveness (or rather ineffectiveness) of a simple iteration against a key set that has to be performed due to an absence of corresponding index.
Parameters:
cKeys - the number of keys to iterate through
Returns:
an effectiveness estimate

equals

public boolean equals(java.lang.Object o)
Compare the ComparisonFilter with another object to determine equality. Two ComparisonFilter objects are considered equal iff they belong to exactly the same class and their extractor and value are equal.
Returns:
true iff this ComparisonFilter and the passed object are equivalent ComparisonFilters

hashCode

public int hashCode()
Determine a hash value for the ComparisonFilter object according to the general Object.hashCode() contract.
Returns:
an integer hash value for this ComparisonFilter object

toString

public java.lang.String toString()
Return a human-readable description for this Filter.
Returns:
a String description of the Filter

readExternal

public void readExternal(java.io.DataInput in)
                  throws java.io.IOException
Restore the contents of this object by loading the object's state from the passed DataInput object.
Specified by:
readExternal in interface ExternalizableLite
Overrides:
readExternal in class ExtractorFilter
Parameters:
in - the DataInput stream to read data from in order to restore the state of this object
Throws:
java.io.IOException - if an I/O exception occurs
java.io.NotActiveException - if the object is not in its initial state, and therefore cannot be deserialized into

writeExternal

public void writeExternal(java.io.DataOutput out)
                   throws java.io.IOException
Save the contents of this object by storing the object's state into the passed DataOutput object.
Specified by:
writeExternal in interface ExternalizableLite
Overrides:
writeExternal in class ExtractorFilter
Parameters:
out - the DataOutput stream to write the state of this object to
Throws:
java.io.IOException - if an I/O exception occurs

readExternal

public void readExternal(PofReader in)
                  throws java.io.IOException
Restore the contents of a user type instance by reading its state using the specified PofReader object.
Specified by:
readExternal in interface PortableObject
Overrides:
readExternal in class ExtractorFilter
Parameters:
in - the PofReader from which to read the object's state
Throws:
java.io.IOException - if an I/O error occurs

writeExternal

public void writeExternal(PofWriter out)
                   throws java.io.IOException
Save the contents of a POF user type instance by writing its state using the specified PofWriter object.
Specified by:
writeExternal in interface PortableObject
Overrides:
writeExternal in class ExtractorFilter
Parameters:
out - the PofWriter to which to write the object's state
Throws:
java.io.IOException - if an I/O error occurs

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


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