net.sf.ehcache.search.attribute
Class ReflectionAttributeExtractor
java.lang.Object
net.sf.ehcache.search.attribute.ReflectionAttributeExtractor
- All Implemented Interfaces:
- Serializable, AttributeExtractor
public class ReflectionAttributeExtractor
- extends Object
- implements AttributeExtractor
Built-in search attribute extractor driven by method/value dotted expression
chains.
The expression chain must start with one of either "key", "value", or
"element". From the starting object a chain of either method calls or field
names follows. Method calls and field names can be freely mixed in the chain.
Some examples:
- "key.getName()" -- call getName() on the key object
- "value.person.getAge()" -- get the "person" field of the value object and call getAge() on it
- "element.toString()" -- call toString() on the element
The method and field name portions of the expression are case sensitive
- Author:
- teck
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ReflectionAttributeExtractor
public ReflectionAttributeExtractor(String expression)
throws InvalidConfigurationException
- Create a new ReflectionAttributeExtractor
- Parameters:
expression
-
- Throws:
InvalidConfigurationException
attributeFor
public Object attributeFor(Element e,
String attributeName)
throws AttributeExtractorException
- Evaluate the expression for the given element
- Specified by:
attributeFor
in interface AttributeExtractor
- Parameters:
e
- the cache element to inspectattributeName
- the name of the requested attribute
- Returns:
- the attribute value
- Throws:
AttributeExtractorException
- if there is an error in evaluating the expression
Copyright 2001-2016, Terracotta, Inc.