info.magnolia.content2bean.impl
Class Content2BeanTransformerImpl

java.lang.Object
  extended by info.magnolia.content2bean.impl.Content2BeanTransformerImpl
All Implemented Interfaces:
Content.ContentFilter, Content2BeanTransformer
Direct Known Subclasses:
CollectionPropertyHidingTransformer, Content2BeanUtil.DefaultClassTransformer, Content2BeanUtil.ToMapTransformer

@Singleton
public class Content2BeanTransformerImpl
extends Object
implements Content2BeanTransformer, Content.ContentFilter

Concrete implementation using reflection and adder methods.

Version:
$Id$
Author:
philipp

Nested Class Summary
 
Nested classes/interfaces inherited from interface info.magnolia.content2bean.Content2BeanTransformer
Content2BeanTransformer.Factory
 
Constructor Summary
Content2BeanTransformerImpl()
           
 
Method Summary
 boolean accept(Content content)
          Process all nodes except MetaData and nodes with names prefixed by "jcr:".
 Object convertPropertyValue(Class<?> propertyType, Object value)
          Most of the conversion is done by the BeanUtils.
 Collection<Content> getChildren(Content node)
          Returns the children of the node to be transformed.
 TypeMapping getTypeMapping()
          Deprecated. since 4.5, do not use.
 void initBean(TransformationState state, Map properties)
          Initializes bean by calling its init method if present.
 Object newBeanInstance(TransformationState state, Map properties, ComponentProvider componentProvider)
          Use the factory util to instantiate.
 TransformationState newState()
          Create a state object to share the state between the processor and transformer.
protected  TypeDescriptor onResolveType(TransformationState state, TypeDescriptor resolvedType, ComponentProvider componentProvider)
          Deprecated. since 4.5, use onResolveType(info.magnolia.content2bean.TypeMapping, info.magnolia.content2bean.TransformationState, info.magnolia.content2bean.TypeDescriptor, info.magnolia.objectfactory.ComponentProvider)
protected  TypeDescriptor onResolveType(TypeMapping typeMapping, TransformationState state, TypeDescriptor resolvedType, ComponentProvider componentProvider)
          Called once the type should have been resolved.
 TypeDescriptor resolveType(TransformationState state)
          Deprecated. 
 TypeDescriptor resolveType(TypeMapping typeMapping, TransformationState state, ComponentProvider componentProvider)
          Resolves the TypeDescriptor from current transformation state.
 void setProperty(TransformationState state, PropertyTypeDescriptor descriptor, Map<String,Object> values)
           
 void setProperty(TypeMapping mapping, TransformationState state, PropertyTypeDescriptor descriptor, Map<String,Object> values)
          Do not set class property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Content2BeanTransformerImpl

public Content2BeanTransformerImpl()
Method Detail

resolveType

@Deprecated
public TypeDescriptor resolveType(TransformationState state)
                           throws ClassNotFoundException
Deprecated. 

Specified by:
resolveType in interface Content2BeanTransformer
Throws:
ClassNotFoundException

resolveType

public TypeDescriptor resolveType(TypeMapping typeMapping,
                                  TransformationState state,
                                  ComponentProvider componentProvider)
                           throws ClassNotFoundException
Resolves the TypeDescriptor from current transformation state. Resolving happens in the following order:

Specified by:
resolveType in interface Content2BeanTransformer
Throws:
ClassNotFoundException

onResolveType

protected TypeDescriptor onResolveType(TypeMapping typeMapping,
                                       TransformationState state,
                                       TypeDescriptor resolvedType,
                                       ComponentProvider componentProvider)
Called once the type should have been resolved. The resolvedType might be null if no type has been resolved. After the call the FactoryUtil and custom transformers are used to get the final type. TODO - check javadoc


onResolveType

protected TypeDescriptor onResolveType(TransformationState state,
                                       TypeDescriptor resolvedType,
                                       ComponentProvider componentProvider)
Deprecated. since 4.5, use onResolveType(info.magnolia.content2bean.TypeMapping, info.magnolia.content2bean.TransformationState, info.magnolia.content2bean.TypeDescriptor, info.magnolia.objectfactory.ComponentProvider)


getChildren

public Collection<Content> getChildren(Content node)
Description copied from interface: Content2BeanTransformer
Returns the children of the node to be transformed. Those are normally the direct children but might differ.

Specified by:
getChildren in interface Content2BeanTransformer

accept

public boolean accept(Content content)
Process all nodes except MetaData and nodes with names prefixed by "jcr:".

Specified by:
accept in interface Content.ContentFilter
Returns:
if true this will be a part of collection

setProperty

public void setProperty(TransformationState state,
                        PropertyTypeDescriptor descriptor,
                        Map<String,Object> values)
Specified by:
setProperty in interface Content2BeanTransformer

setProperty

public void setProperty(TypeMapping mapping,
                        TransformationState state,
                        PropertyTypeDescriptor descriptor,
                        Map<String,Object> values)
Do not set class property. In case of a map/collection try to use adder method.

Specified by:
setProperty in interface Content2BeanTransformer

convertPropertyValue

public Object convertPropertyValue(Class<?> propertyType,
                                   Object value)
                            throws Content2BeanException
Most of the conversion is done by the BeanUtils. TODO don't use bean utils conversion since it can't be used for the adder methods

Specified by:
convertPropertyValue in interface Content2BeanTransformer
Throws:
Content2BeanException

newBeanInstance

public Object newBeanInstance(TransformationState state,
                              Map properties,
                              ComponentProvider componentProvider)
                       throws Content2BeanException
Use the factory util to instantiate. This is useful to get default implementation of interfaces

Specified by:
newBeanInstance in interface Content2BeanTransformer
Throws:
Content2BeanException

initBean

public void initBean(TransformationState state,
                     Map properties)
              throws Content2BeanException
Initializes bean by calling its init method if present.

Specified by:
initBean in interface Content2BeanTransformer
Throws:
Content2BeanException

newState

public TransformationState newState()
Description copied from interface: Content2BeanTransformer
Create a state object to share the state between the processor and transformer.

Specified by:
newState in interface Content2BeanTransformer

getTypeMapping

public TypeMapping getTypeMapping()
Deprecated. since 4.5, do not use.

Returns the default mapping.

Specified by:
getTypeMapping in interface Content2BeanTransformer


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