public abstract class SingleTargetClassTranslator extends Object implements DataTranslator
SingleTargetClassTranslator| Modifier and Type | Field and Description |
|---|---|
protected Class<?> |
supportedClass |
NULL_OBJECT, PRIORITY_NORMAL_SUPPORT, PRIORITY_NOT_SUPPORTED| Modifier | Constructor and Description |
|---|---|
protected |
SingleTargetClassTranslator(Class<?> supportedClass) |
| Modifier and Type | Method and Description |
|---|---|
int |
getTargetClassSupportPriority(Class<?> targetClass,
DataTranslatorContext context)
Determines whether the argument represents a class supported by this
translator.
|
String |
toString() |
protected abstract Object |
translate(Object source,
DataTranslatorContext context) |
Object |
translateToClass(Object source,
Class<?> targetClass,
DataTranslatorContext context)
Attempts to translate an arbitrary object into an instance of
targetClass. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetIdprotected final Class<?> supportedClass
protected SingleTargetClassTranslator(Class<?> supportedClass)
protected abstract Object translate(Object source, DataTranslatorContext context)
public int getTargetClassSupportPriority(Class<?> targetClass, DataTranslatorContext context)
DataTranslatorDataTranslator.PRIORITY_NOT_SUPPORTED constant.
The translator that reports the highest priority will be used for the actual translation. If there are multiple translators with the same maximum priority, the choice will be arbitrary.
getTargetClassSupportPriority in interface DataTranslatortargetClass - class of the expected result of translationcontext - context of the translationtargetClass; zero or negative value if the class is not
supportedpublic Object translateToClass(Object source, Class<?> targetClass, DataTranslatorContext context)
DataTranslatortargetClass.
If the translation couldn't be performed, null is returned.
As the translation happens while preparing configuration data, the translator receives information about the context of translation.
translateToClass in interface DataTranslatorsource - non-null object that is to be translatedtargetClass - requested target classcontext - context of the translationtargetClass; null if the translation cannot
be performed; DataTranslator.NULL_OBJECT if the result should be true null valueCopyright © 2015 Boleslav Bobcik - Auderis. All rights reserved.