ehcache

net.sf.ehcache.search.attribute
Class ReflectionAttributeExtractor

java.lang.Object
  extended by 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:

  1. "key.getName()" -- call getName() on the key object
  2. "value.person.getAge()" -- get the "person" field of the value object and call getAge() on it
  3. "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

Constructor Summary
ReflectionAttributeExtractor(String expression)
          Create a new ReflectionAttributeExtractor
 
Method Summary
 Object attributeFor(Element e, String attributeName)
          Evaluate the expression for the given element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionAttributeExtractor

public ReflectionAttributeExtractor(String expression)
                             throws InvalidConfigurationException
Create a new ReflectionAttributeExtractor

Parameters:
expression -
Throws:
InvalidConfigurationException
Method Detail

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 inspect
attributeName - the name of the requested attribute
Returns:
the attribute value
Throws:
AttributeExtractorException - if there is an error in evaluating the expression

ehcache

Copyright 2001-2017, Terracotta, Inc.