info.magnolia.ui.form.field.transformer.basic
Class BasicTransformer<T>

java.lang.Object
  extended by info.magnolia.ui.form.field.transformer.basic.BasicTransformer<T>
Type Parameters:
T -
All Implemented Interfaces:
I18NAwareHandler, Transformer<T>
Direct Known Subclasses:
CompositeTransformer, EnabledFieldTransformer, ListToSetTransformer, ManagementFieldTransformer, MultiValueChildrenNodeTransformer, MultiValueJSONTransformer, MultiValueTransformer, NoOpCompositeTransformer, NotNullInitialStringValueTransformer

public class BasicTransformer<T>
extends Object
implements Transformer<T>

Basic implementation of a Transformer.
This handler is used for most of the basic fields (textBox, Date, ...).
His responsibility is to:
- retrieve or create a basic property from the related item
- update the item property value in case of changes performed on the related field.


Field Summary
protected  String basePropertyName
           
protected  ConfiguredFieldDefinition definition
           
protected  String i18NPropertyName
           
protected  com.vaadin.data.Item relatedFormItem
           
protected  Class<T> type
           
 
Constructor Summary
BasicTransformer(com.vaadin.data.Item relatedFormItem, ConfiguredFieldDefinition definition, Class<T> type)
           
 
Method Summary
protected  String definePropertyName()
          Based on the i18n information, define the property name to use.
 String getBasePropertyName()
           
 Locale getLocale()
           
protected
<T> com.vaadin.data.Property<T>
getOrCreateProperty(Class<T> type)
          If the desired property (propertyName) already exist in the JcrNodeAdapter, return this property
else create a new Property.
If the defaultValueString is empty or null, return a typed null value property.
 Class<T> getType()
           
 boolean hasI18NSupport()
          Return true if this Property has to support i18n.
 T readFromItem()
          Transform a specific Item values to a specified type T.
 void setI18NPropertyName(String i18nPropertyName)
           
 void setLocale(Locale locale)
           
protected  void setType(Class<T> typeFromDefinition)
          If the value type is not initialize by the field factory (UndefinedPropertyType), check if the property already exist in the Item.
If the Item has already this property, return the property value type.
Else return the default type 'String'
 void writeToItem(T newValue)
          Convert the T newValue to a specific Item format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

relatedFormItem

protected com.vaadin.data.Item relatedFormItem

definition

protected final ConfiguredFieldDefinition definition

basePropertyName

protected String basePropertyName

i18NPropertyName

protected String i18NPropertyName

type

protected Class<T> type
Constructor Detail

BasicTransformer

@Inject
public BasicTransformer(com.vaadin.data.Item relatedFormItem,
                               ConfiguredFieldDefinition definition,
                               Class<T> type)
Method Detail

writeToItem

public void writeToItem(T newValue)
Description copied from interface: Transformer
Convert the T newValue to a specific Item format.

Specified by:
writeToItem in interface Transformer<T>

readFromItem

public T readFromItem()
Description copied from interface: Transformer
Transform a specific Item values to a specified type T.

Specified by:
readFromItem in interface Transformer<T>

setType

protected void setType(Class<T> typeFromDefinition)
If the value type is not initialize by the field factory (UndefinedPropertyType), check if the property already exist in the Item.
If the Item has already this property, return the property value type.
Else return the default type 'String'


getOrCreateProperty

protected <T> com.vaadin.data.Property<T> getOrCreateProperty(Class<T> type)
If the desired property (propertyName) already exist in the JcrNodeAdapter, return this property
else create a new Property.
If the defaultValueString is empty or null, return a typed null value property.

Type Parameters:
T -

definePropertyName

protected String definePropertyName()
Based on the i18n information, define the property name to use.


setLocale

public void setLocale(Locale locale)
Specified by:
setLocale in interface I18NAwareHandler

setI18NPropertyName

public void setI18NPropertyName(String i18nPropertyName)
Specified by:
setI18NPropertyName in interface I18NAwareHandler

getLocale

public Locale getLocale()
Specified by:
getLocale in interface I18NAwareHandler

getBasePropertyName

public String getBasePropertyName()
Specified by:
getBasePropertyName in interface I18NAwareHandler

hasI18NSupport

public boolean hasI18NSupport()
Description copied from interface: Transformer
Return true if this Property has to support i18n.

Specified by:
hasI18NSupport in interface Transformer<T>

getType

public Class<T> getType()
Specified by:
getType in interface Transformer<T>
Returns:
type the type of the value. value must be assignable to this type.


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.