Top Description Inners Fields Constructors Methods
net.sf.ehcache.search.expression

public abstract Class ComparableValue

extends BaseCriteria
Class Inheritance
Known Direct Subclasses
net.sf.ehcache.search.expression.GreaterThan, net.sf.ehcache.search.expression.GreaterThanOrEqual, net.sf.ehcache.search.expression.LessThan, net.sf.ehcache.search.expression.LessThanOrEqual, net.sf.ehcache.search.expression.Between
Imports
java.io.Serializable, java.util.Collections, .Comparator, .Map, .Set, net.sf.ehcache.Element, net.sf.ehcache.search.Attribute, .SearchException, net.sf.ehcache.search.attribute.AttributeExtractor, .AttributeType

Abstract base class for criteria involving java.lang.Comparable values
Author
teck

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ComparableValue.LuceneCaseAgnosticStringComparator

A Lucene compatible case insensitive string comparator.

Field Summary

Modifier and TypeField and Description
private final String
private static final Comparator<String>
private final AttributeType

Constructor Summary

AccessConstructor and Description
public
ComparableValue(String
attribute name
attributeName
,
Object
comparable value (used to infer type)
value
)

Constructor

public
ComparableValue(String
attribute name
attributeName
,
AttributeType
the expeceted type for values evaluated by this criteria
type
)

Constructor

Method Summary

Modifier and TypeMethod and Description
public boolean
execute(Element
cache element
e
,
Map<String, AttributeExtractor>
map of attribute extractors to attribute value names
attributeExtractors
)

Implements net.sf.ehcache.search.expression.Criteria.execute.

Test this criteria against a cache element
protected abstract boolean

Returns:

true if criteria is met
executeComparable
(Comparable<T>
Comparable attribute value
attributeValue
)

Execute this criteria for the given Comparable attribute value

protected abstract boolean

Returns:

true if criteria is met
executeComparableString
(Comparable<T>
Comparable attribute value
attributeValue
)

Execute this criteria for the given Comparable strin type attribute value

public String

Returns:

name
getAttributeName
()

Attribute name.

public Set<Attribute<?>>
getAttributes()

Implements abstract net.sf.ehcache.search.expression.BaseCriteria.getAttributes.

Returns all search attributes referenced by this instance
public AttributeType

Returns:

type
getType
()

Attribute type.

protected static int

Returns:

the comparison result
luceneStringCompare
(String
first string
s1
,
String
second string
s2
)

Perform a Lucene compatible case insensitive string comparison.

Inherited from net.sf.ehcache.search.expression.BaseCriteria:
andgetExtractornotor

Field Detail

attributeNameback to summary
private final String attributeName
LUCENE_STRING_COMPARATORback to summary
private static final Comparator<String> LUCENE_STRING_COMPARATOR
typeback to summary
private final AttributeType type

Constructor Detail

ComparableValueback to summary
public ComparableValue(String attributeName, Object value)

Constructor

Parameters
attributeName:String

attribute name

value:Object

comparable value (used to infer type)

ComparableValueback to summary
public ComparableValue(String attributeName, AttributeType type)

Constructor

Parameters
attributeName:String

attribute name

type:AttributeType

the expeceted type for values evaluated by this criteria

Method Detail

executeback to summary
public boolean execute(Element e, Map<String, AttributeExtractor> attributeExtractors)

Implements net.sf.ehcache.search.expression.Criteria.execute.

Doc from net.sf.ehcache.search.expression.Criteria.execute.

Test this criteria against a cache element

Parameters
e:Element

cache element

attributeExtractors:Map<String, AttributeExtractor>

map of attribute extractors to attribute value names

Returns:boolean

true if the criteria matches this element

executeComparableback to summary
protected abstract boolean executeComparable(Comparable<T> attributeValue)

Execute this criteria for the given Comparable attribute value

Parameters
attributeValue:Comparable<T>

Comparable attribute value

Returns:boolean

true if criteria is met

executeComparableStringback to summary
protected abstract boolean executeComparableString(Comparable<T> attributeValue)

Execute this criteria for the given Comparable strin type attribute value

Parameters
attributeValue:Comparable<T>

Comparable attribute value

Returns:boolean

true if criteria is met

getAttributeNameback to summary
public String getAttributeName()

Attribute name.

Returns:String

name

getAttributesback to summary
public Set<Attribute<?>> getAttributes()

Implements abstract net.sf.ehcache.search.expression.BaseCriteria.getAttributes.

Doc from net.sf.ehcache.search.expression.BaseCriteria.getAttributes.

Returns all search attributes referenced by this instance

Annotations
@Override
getTypeback to summary
public AttributeType getType()

Attribute type.

Returns:AttributeType

type

luceneStringCompareback to summary
protected static int luceneStringCompare(String s1, String s2)

Perform a Lucene compatible case insensitive string comparison.

Parameters
s1:String

first string

s2:String

second string

Returns:int

the comparison result

net.sf.ehcache.search.expression back to summary

private Class ComparableValue.LuceneCaseAgnosticStringComparator

extends Object
implements Comparator<String>, Serializable
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.search.expression.ComparableValue.LuceneCaseAgnosticStringComparator
All Implemented Interfaces
java.io.Serializable, java.util.Comparator

A Lucene compatible case insensitive string comparator.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(String
the first object to be compared.
s1
,
String
the second object to be compared.
s2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

LuceneCaseAgnosticStringComparatorback to summary
private LuceneCaseAgnosticStringComparator()

Method Detail

compareback to summary
public int compare(String s1, String s2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

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.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
s1:String

the first object to be compared.

s2:String

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.