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:
CacheConfigurationTransformer, CollectionPropertyHidingTransformer, Content2BeanUtil.DefaultClassTransformer, IPSecurityManagerImpl.IPSecurityManagerTransformer

public class Content2BeanTransformerImpl
extends Object
implements Content2BeanTransformer, Content.ContentFilter

Concrete implementation using reflection and adder methods.

Version:
$Id: Content2BeanTransformerImpl.java 45108 2011-05-16 08:47:14Z had $
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()
          Returns the default mapping.
 void initBean(TransformationState state, Map properties)
          Initializes bean by calling its init method if present.
 Object newBeanInstance(TransformationState state, Map properties)
          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)
          Called once the type should have been resolved.
 TypeDescriptor resolveType(TransformationState state)
          Resolves the TypeDescriptor from current transformation state.
 void setProperty(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

public TypeDescriptor resolveType(TransformationState state)
                           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(TransformationState state,
                                       TypeDescriptor resolvedType)
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


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)
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)
                       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()
Returns the default mapping.

Specified by:
getTypeMapping in interface Content2BeanTransformer


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