Package net.sf.ehcache.search.attribute
Class ReflectionAttributeExtractor
- java.lang.Object
-
- net.sf.ehcache.search.attribute.ReflectionAttributeExtractor
-
- All Implemented Interfaces:
java.io.Serializable,AttributeExtractor
public class ReflectionAttributeExtractor extends java.lang.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
- Author:
- teck
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ReflectionAttributeExtractor(java.lang.String expression)Create a new ReflectionAttributeExtractor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectattributeFor(Element e, java.lang.String attributeName)Evaluate the expression for the given element
-
-
-
Constructor Detail
-
ReflectionAttributeExtractor
public ReflectionAttributeExtractor(java.lang.String expression) throws InvalidConfigurationExceptionCreate a new ReflectionAttributeExtractor- Parameters:
expression-- Throws:
InvalidConfigurationException
-
-
Method Detail
-
attributeFor
public java.lang.Object attributeFor(Element e, java.lang.String attributeName) throws AttributeExtractorException
Evaluate the expression for the given element- Specified by:
attributeForin interfaceAttributeExtractor- 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
-
-