|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.ehcache.annotations.key.AbstractCacheKeyGenerator<T>
com.googlecode.ehcache.annotations.key.AbstractDeepCacheKeyGenerator<G,T>
public abstract class AbstractDeepCacheKeyGenerator<G,T extends java.io.Serializable>
Base class for key generators that do deep inspection of the key data for generation. Arrays,
Iterable and Map are iterated over and their values recursively inspected. Also
supports reflective recursion which can be useful for objects that may not support the hashCode,
equals or other methods required by the key generation implementation.
Reflective recursion add significant overhead to the deep inspection process.
| Constructor Summary | |
|---|---|
AbstractDeepCacheKeyGenerator()
|
|
AbstractDeepCacheKeyGenerator(boolean includeMethod,
boolean includeParameterTypes)
|
|
| Method Summary | |
|---|---|
protected void |
append(G generator,
boolean[] a)
Append a boolean array. |
protected void |
append(G generator,
byte[] a)
Append a byte array. |
protected void |
append(G generator,
char[] a)
Append a char array. |
protected void |
append(G generator,
double[] a)
Append a double array. |
protected void |
append(G generator,
float[] a)
Append a float array. |
protected void |
append(G generator,
int[] a)
Append a int array. |
protected void |
append(G generator,
long[] a)
Append a long array. |
protected abstract void |
append(G generator,
java.lang.Object e)
Append an object to the key. |
protected void |
append(G generator,
short[] a)
Append a short array. |
protected abstract void |
appendGraphCycle(G generator,
java.lang.Object o)
Called if a graph cycle is detected. |
protected abstract void |
appendNull(G generator)
Called if a null value is found in the object graph |
protected void |
beginRecursion(G generator,
java.lang.Object e)
Called before each array/ Iterable/Map is handled. |
protected void |
deepHashCode(G generator,
java.lang.Iterable<?> a)
Calls deepHashCode(Object, Object) on each element in the Iterable |
protected void |
deepHashCode(G generator,
java.util.Map.Entry<?,?> e)
Calls deepHashCode(Object, Object) on both the key and the value. |
protected void |
deepHashCode(G generator,
java.lang.Object element)
Does instanceof checks to determine the correct deepHashCode(G, java.lang.Object[]) method to call or
append(Object, Object) is called if no other recursion is needed or
reflectionDeepHashCode(Object, Object) is called if setUseReflection(boolean)
is true. |
protected void |
deepHashCode(G generator,
java.lang.Object[] a)
Calls deepHashCode(Object, Object) on each element in the array. |
protected void |
endRecursion(G generator,
java.lang.Object e)
Called after each array/ Iterable/Map is handled. |
protected abstract T |
generateKey(G generator)
Generate the cache key from the generator |
T |
generateKey(java.lang.Object... data)
Called to generate the key. |
protected abstract G |
getGenerator(java.lang.Object... data)
Create the object used to generate the key. |
ReflectionHelper |
getReflectionHelper()
|
boolean |
isUseReflection()
|
protected void |
reflectionDeepHashCode(G generator,
java.lang.Object element)
Calls shouldReflect(Object) to determine if the object needs to be reflected on to
generate a good key. |
void |
setReflectionHelper(ReflectionHelper reflectionHelper)
|
void |
setUseReflection(boolean useReflection)
Determines if reflection should be used on each object that is used in key generation. |
protected boolean |
shouldReflect(java.lang.Object element)
Default implementation returns true if the Object doesn't implement hashCode or
doesn't implement equals. |
java.lang.String |
toString()
|
| Methods inherited from class com.googlecode.ehcache.annotations.key.AbstractCacheKeyGenerator |
|---|
generateKey, isCheckforCycles, isIncludeMethod, isIncludeParameterTypes, register, setCheckforCycles, setIncludeMethod, setIncludeParameterTypes, unregister |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractDeepCacheKeyGenerator()
public AbstractDeepCacheKeyGenerator(boolean includeMethod,
boolean includeParameterTypes)
| Method Detail |
|---|
public ReflectionHelper getReflectionHelper()
public void setReflectionHelper(ReflectionHelper reflectionHelper)
setReflectionHelper in interface ReflectionHelperAwarepublic final boolean isUseReflection()
public final void setUseReflection(boolean useReflection)
shouldReflect(Object) called on it. If that
returns true reflection is used to recurse on all of the fields of the object.
useReflection - Defaults to false.public final T generateKey(java.lang.Object... data)
AbstractCacheKeyGeneratorAbstractCacheKeyGenerator.setIncludeMethod(boolean) and
AbstractCacheKeyGenerator.setIncludeParameterTypes(boolean) the the appropriate parts of the Method
signature will be included in the data array.
generateKey in interface CacheKeyGenerator<T extends java.io.Serializable>generateKey in class AbstractCacheKeyGenerator<T extends java.io.Serializable>data - the objects to use when generating the key
Serializable cache key for the method invocation.
protected void deepHashCode(G generator,
java.lang.Object[] a)
deepHashCode(Object, Object) on each element in the array.
a - will never be null
protected void deepHashCode(G generator,
java.lang.Iterable<?> a)
deepHashCode(Object, Object) on each element in the Iterable
a - will never be null
protected void deepHashCode(G generator,
java.util.Map.Entry<?,?> e)
deepHashCode(Object, Object) on both the key and the value.
e - will never be null
protected final void deepHashCode(G generator,
java.lang.Object element)
deepHashCode(G, java.lang.Object[]) method to call or
append(Object, Object) is called if no other recursion is needed or
reflectionDeepHashCode(Object, Object) is called if setUseReflection(boolean)
is true.
protected final void reflectionDeepHashCode(G generator,
java.lang.Object element)
shouldReflect(Object) to determine if the object needs to be reflected on to
generate a good key. If so AccessibleObject.setAccessible(AccessibleObject[], boolean) is
used to enable access to private, protected and default fields. Each non-transient, non-static field
has deepHashCode(Object, Object) called on it.
protected boolean shouldReflect(java.lang.Object element)
Object doesn't implement hashCode or
doesn't implement equals.
element - will never be nullprotected abstract G getGenerator(java.lang.Object... data)
deepHashCode(G, java.lang.Object[]) and
append(G, java.lang.Object) call.
protected abstract T generateKey(G generator)
protected abstract void append(G generator,
java.lang.Object e)
protected abstract void appendGraphCycle(G generator,
java.lang.Object o)
o - The object that started the cycleprotected abstract void appendNull(G generator)
protected void append(G generator,
boolean[] a)
append(Object, Object) on each value in
the array. If the implementing class can handle boolean or boolean array primitives
directly this should be overridden to avoid auto-boxing each array element.
protected void append(G generator,
byte[] a)
append(Object, Object) on each value in
the array. If the implementing class can handle byte or byte array primitives
directly this should be overridden to avoid auto-boxing each array element.
protected void append(G generator,
char[] a)
append(Object, Object) on each value in
the array. If the implementing class can handle char or char array primitives
directly this should be overridden to avoid auto-boxing each array element.
protected void append(G generator,
double[] a)
append(Object, Object) on each value in
the array. If the implementing class can handle double or double array primitives
directly this should be overridden to avoid auto-boxing each array element.
protected void append(G generator,
float[] a)
append(Object, Object) on each value in
the array. If the implementing class can handle float or float array primitives
directly this should be overridden to avoid auto-boxing each array element.
protected void append(G generator,
int[] a)
append(Object, Object) on each value in
the array. If the implementing class can handle int or int array primitives
directly this should be overridden to avoid auto-boxing each array element.
protected void append(G generator,
long[] a)
append(Object, Object) on each value in
the array. If the implementing class can handle long or long array primitives
directly this should be overridden to avoid auto-boxing each array element.
protected void append(G generator,
short[] a)
append(Object, Object) on each value in
the array. If the implementing class can handle short or short array primitives
directly this should be overridden to avoid auto-boxing each array element.
protected void beginRecursion(G generator,
java.lang.Object e)
Iterable/Map is handled. Useful for sub-classes that
want to be aware of the tree structure of the object graph.
protected void endRecursion(G generator,
java.lang.Object e)
Iterable/Map is handled. Useful for sub-classes that
want to be aware of the tree structure of the object graph.
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||