org.carrot2.util.attribute
Class AttributeBinder.AttributeTransformerFromString

java.lang.Object
  extended by org.carrot2.util.attribute.AttributeBinder.AttributeTransformerFromString
All Implemented Interfaces:
AttributeBinder.IAttributeTransformer
Enclosing class:
AttributeBinder

public static class AttributeBinder.AttributeTransformerFromString
extends Object
implements AttributeBinder.IAttributeTransformer

Transforms String attribute values to the types required by the target field by:

  1. Leaving non-String typed values unchanged.
  2. Looking for a static valueOf(String) in the target type and using it for conversion.
  3. If the method is not available, trying to load a class named as the value of the attribute, so that this class can be further coerced to the class instance.
  4. If the class cannot be loaded, leaving the the value unchanged.


Field Summary
static AttributeBinder.AttributeTransformerFromString INSTANCE
          Shared instance of the transformer.
 
Method Summary
 Object transform(Object value, String key, Field field, Class<? extends Annotation> bindingDirectionAnnotation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final AttributeBinder.AttributeTransformerFromString INSTANCE
Shared instance of the transformer.

Method Detail

transform

public Object transform(Object value,
                        String key,
                        Field field,
                        Class<? extends Annotation> bindingDirectionAnnotation)
Specified by:
transform in interface AttributeBinder.IAttributeTransformer


Copyright (c) Dawid Weiss, Stanislaw Osinski