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

public Class ReflectionAttributeExtractor

extends Object
implements AttributeExtractor
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.search.attribute.AttributeExtractor, java.io.Serializable
Imports
java.io.Serializable, java.lang.reflect.Field, .InvocationTargetException, .Method, net.sf.ehcache.Element, net.sf.ehcache.config.InvalidConfigurationException

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
ReflectionAttributeExtractor.FieldRef

A reference to a resolved Field instance

private static class
private static class
ReflectionAttributeExtractor.MethodRef

A reference to a resolved Method instance

private static interface
ReflectionAttributeExtractor.Part

A part (method or field) of the expression

private static enum
ReflectionAttributeExtractor.StartType

The various types of the start of the expression

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private final ReflectionAttributeExtractor.Part[]
private final ReflectionAttributeExtractor.StartType
private static final String

Constructor Summary

AccessConstructor and Description
public
ReflectionAttributeExtractor(String expression)

Create a new ReflectionAttributeExtractor

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the attribute value
attributeFor
(Element
the cache element to inspect
e
,
String
the name of the requested attribute
attributeName
)

Implements net.sf.ehcache.search.attribute.AttributeExtractor.attributeFor.

Evaluate the expression for the given element
private static ReflectionAttributeExtractor.Part[]
parseExpression(String[] tokens, String expression)

private static void
verifyToken(String token, String expression)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ELEMENTback to summary
private static final String ELEMENT
KEYback to summary
private static final String KEY
partsback to summary
private final ReflectionAttributeExtractor.Part[] parts
startback to summary
private final ReflectionAttributeExtractor.StartType start
VALUEback to summary
private static final String VALUE

Constructor Detail

ReflectionAttributeExtractorback to summary
public ReflectionAttributeExtractor(String expression) throws InvalidConfigurationException

Create a new ReflectionAttributeExtractor

Method Detail

attributeForback to summary
public Object attributeFor(Element e, String attributeName) throws AttributeExtractorException

Implements net.sf.ehcache.search.attribute.AttributeExtractor.attributeFor.

Evaluate the expression for the given element

Parameters
e:Element

Doc from net.sf.ehcache.search.attribute.AttributeExtractor.attributeFor.

the cache element to inspect

attributeName:String

Doc from net.sf.ehcache.search.attribute.AttributeExtractor.attributeFor.

the name of the requested attribute

Returns:Object

the attribute value

Exceptions
AttributeExtractorException:
if there is an error in evaluating the expression
parseExpressionback to summary
private static ReflectionAttributeExtractor.Part[] parseExpression(String[] tokens, String expression)
verifyTokenback to summary
private static void verifyToken(String token, String expression)
net.sf.ehcache.search.attribute back to summary

private Class ReflectionAttributeExtractor.FieldPart

extends Object
implements Part
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.search.attribute.ReflectionAttributeExtractor.FieldPart
All Implemented Interfaces
net.sf.ehcache.search.attribute.ReflectionAttributeExtractor.Part, java.io.Serializable

A field expression part

Field Summary

Modifier and TypeField and Description
private transient volatile ReflectionAttributeExtractor.FieldRef
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private transient volatile ReflectionAttributeExtractor.FieldRef cache
fieldNameback to summary
private final String fieldName

Constructor Detail

FieldPartback to summary
public FieldPart(String field)

Method Detail

evalback to summary
public Object eval(Object target)

Implements net.sf.ehcache.search.attribute.ReflectionAttributeExtractor.Part.eval.

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

private Class ReflectionAttributeExtractor.FieldRef

extends Object
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.search.attribute.ReflectionAttributeExtractor.FieldRef

A reference to a resolved Field instance

Field Summary

Modifier and TypeField and Description
private final Field
private final Class<T>

Constructor Summary

AccessConstructor and Description
pack-priv
FieldRef(Class<T> target, Field field)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fieldback to summary
private final Field field
targetback to summary
private final Class<T> target

Constructor Detail

FieldRefback to summary
pack-priv FieldRef(Class<T> target, Field field)
net.sf.ehcache.search.attribute back to summary

private Class ReflectionAttributeExtractor.MethodPart

extends Object
implements Part
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.search.attribute.ReflectionAttributeExtractor.MethodPart
All Implemented Interfaces
net.sf.ehcache.search.attribute.ReflectionAttributeExtractor.Part, java.io.Serializable

A method expression part

Field Summary

Modifier and TypeField and Description
private transient volatile ReflectionAttributeExtractor.MethodRef
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private transient volatile ReflectionAttributeExtractor.MethodRef cache
methodNameback to summary
private final String methodName

Constructor Detail

MethodPartback to summary
public MethodPart(String method)

Method Detail

evalback to summary
public Object eval(Object target)

Implements net.sf.ehcache.search.attribute.ReflectionAttributeExtractor.Part.eval.

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

private Class ReflectionAttributeExtractor.MethodRef

extends Object
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.search.attribute.ReflectionAttributeExtractor.MethodRef

A reference to a resolved Method instance

Field Summary

Modifier and TypeField and Description
private final Method
private final Class<T>

Constructor Summary

AccessConstructor and Description
pack-priv
MethodRef(Class<T> target, Method method)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

methodback to summary
private final Method method
targetback to summary
private final Class<T> target

Constructor Detail

MethodRefback to summary
pack-priv MethodRef(Class<T> target, Method method)
net.sf.ehcache.search.attribute back to summary

private Interface ReflectionAttributeExtractor.Part

extends Serializable
Known Direct Implementers
net.sf.ehcache.search.attribute.ReflectionAttributeExtractor.FieldPart, net.sf.ehcache.search.attribute.ReflectionAttributeExtractor.MethodPart

A part (method or field) of the expression

Method Summary

Modifier and TypeMethod and Description
public Object
eval(Object target)

Method Detail

evalback to summary
public Object eval(Object target)
net.sf.ehcache.search.attribute back to summary

private final Enum ReflectionAttributeExtractor.StartType

extends Enum<ReflectionAttributeExtractor.StartType>
Class Inheritance

The various types of the start of the expression

Field Summary

Modifier and TypeField and Description
public static final ReflectionAttributeExtractor.StartType
public static final ReflectionAttributeExtractor.StartType
public static final ReflectionAttributeExtractor.StartType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ReflectionAttributeExtractor.StartType
public static ReflectionAttributeExtractor.StartType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ELEMENTback to summary
public static final ReflectionAttributeExtractor.StartType ELEMENT
KEYback to summary
public static final ReflectionAttributeExtractor.StartType KEY
VALUEback to summary
public static final ReflectionAttributeExtractor.StartType VALUE

Constructor Detail

StartTypeback to summary
private StartType()

Method Detail

valueOfback to summary
public static ReflectionAttributeExtractor.StartType valueOf(String name)
valuesback to summary
public static ReflectionAttributeExtractor.StartType[] values()