org.infinispan.query.backend
Class KeyTransformationHandler

java.lang.Object
  extended by org.infinispan.query.backend.KeyTransformationHandler

public class KeyTransformationHandler
extends Object

This transforms arbitrary keys to a String which can be used by Lucene as a document identifier, and vice versa.

There are 2 approaches to doing so; one for SimpleKeys: Java primitives (and their object wrappers) and Strings, and one for custom, user-defined types that could be used as keys.

For SimpleKeys, users don't need to do anything, these keys are automatically transformed by this class.

For user-defined keys, two options are supported. Types annotated with @Transformable, and declaring an appropriate Transformer implementation; and types for which a Transformer has been explicitly registered through KeyTransformationHandler.registerTransformer().

Since:
4.0
Author:
Manik Surtani, Marko Luksa
See Also:
Transformable, Transformer

Constructor Summary
KeyTransformationHandler()
           
 
Method Summary
static KeyTransformationHandler getInstance(AdvancedCache<?,?> cache)
          Gets the KeyTransformationHandler instance used by the supplied cache.
 String keyToString(Object key)
           
 void registerTransformer(Class<?> keyClass, Class<? extends Transformer> transformerClass)
          Registers a Transformer for the supplied key class.
 Object stringToKey(String s, ClassLoader classLoader)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyTransformationHandler

public KeyTransformationHandler()
Method Detail

stringToKey

public Object stringToKey(String s,
                          ClassLoader classLoader)

keyToString

public String keyToString(Object key)

registerTransformer

public void registerTransformer(Class<?> keyClass,
                                Class<? extends Transformer> transformerClass)
Registers a Transformer for the supplied key class.

Parameters:
keyClass - the key class for which the supplied transformerClass should be used
transformerClass - the transformer class to use for the supplied key class

getInstance

public static KeyTransformationHandler getInstance(AdvancedCache<?,?> cache)
Gets the KeyTransformationHandler instance used by the supplied cache.

Parameters:
cache - the cache for which we want to get the KeyTransformationHandler instance
Returns:
a KeyTransformationHandler instance

-->

Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.