info.magnolia.jcr.node2bean.impl
Class Node2BeanTransformerImpl

java.lang.Object
  extended by info.magnolia.jcr.node2bean.impl.Node2BeanTransformerImpl
All Implemented Interfaces:
Node2BeanTransformer
Direct Known Subclasses:
CollectionPropertyHidingTransformer, CommandTransformer, IPSecurityManagerImpl.IPSecurityManagerTransformer

public class Node2BeanTransformerImpl
extends Object
implements Node2BeanTransformer

Concrete implementation using reflection, generics and setter methods.


Constructor Summary
Node2BeanTransformerImpl()
           
Node2BeanTransformerImpl(Class<?> defaultListImpl, Class<?> defaultSetImpl, Class<?> defaultQueueImpl)
           
 
Method Summary
 Object convertPropertyValue(Class<?> propertyType, Object value)
          Transforms the simple basic jcr property value objects to more complex properties.
protected  Collection<?> createCollectionFromMap(Map<?,?> map, Class<?> clazz)
          Creates collection from map.
 javax.jcr.NodeIterator getChildren(javax.jcr.Node node)
          Returns the children of the node to be transformed.
 void initBean(TransformationState state, Map values)
          Called after all properties are set.
protected  boolean isBeanEnabled(Object bean)
           
 Object newBeanInstance(TransformationState state, Map<String,Object> values, ComponentProvider componentProvider)
          Instantiates the bean.
 TransformationState newState()
          Create a state object to share the state between the processor and transformer.
protected  TypeDescriptor onResolveType(TypeMapping typeMapping, TransformationState state, TypeDescriptor resolvedType, ComponentProvider componentProvider)
          Called once the type should have been resolved.
 TypeDescriptor resolveType(TypeMapping typeMapping, TransformationState state, ComponentProvider componentProvider)
          Resolves the class to use for the current node.
 void setProperty(TypeMapping mapping, TransformationState state, PropertyTypeDescriptor descriptor, Map<String,Object> values)
          Set this property on that bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node2BeanTransformerImpl

@Inject
public Node2BeanTransformerImpl()

Node2BeanTransformerImpl

public Node2BeanTransformerImpl(Class<?> defaultListImpl,
                                Class<?> defaultSetImpl,
                                Class<?> defaultQueueImpl)
Method Detail

newState

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

Specified by:
newState in interface Node2BeanTransformer

resolveType

public TypeDescriptor resolveType(TypeMapping typeMapping,
                                  TransformationState state,
                                  ComponentProvider componentProvider)
                           throws ClassNotFoundException,
                                  javax.jcr.RepositoryException
Description copied from interface: Node2BeanTransformer
Resolves the class to use for the current node.

Specified by:
resolveType in interface Node2BeanTransformer
Throws:
ClassNotFoundException
javax.jcr.RepositoryException

getChildren

public javax.jcr.NodeIterator getChildren(javax.jcr.Node node)
                                   throws javax.jcr.RepositoryException
Description copied from interface: Node2BeanTransformer
Returns the children of the node to be transformed. Those are normally the direct children but might differ.

Specified by:
getChildren in interface Node2BeanTransformer
Throws:
javax.jcr.RepositoryException

newBeanInstance

public Object newBeanInstance(TransformationState state,
                              Map<String,Object> values,
                              ComponentProvider componentProvider)
                       throws Node2BeanException
Description copied from interface: Node2BeanTransformer
Instantiates the bean.

Specified by:
newBeanInstance in interface Node2BeanTransformer
Throws:
Node2BeanException

initBean

public void initBean(TransformationState state,
                     Map values)
              throws Node2BeanException
Description copied from interface: Node2BeanTransformer
Called after all properties are set.

Specified by:
initBean in interface Node2BeanTransformer
Throws:
Node2BeanException

convertPropertyValue

public Object convertPropertyValue(Class<?> propertyType,
                                   Object value)
                            throws Node2BeanException
Description copied from interface: Node2BeanTransformer
Transforms the simple basic jcr property value objects to more complex properties.

Specified by:
convertPropertyValue in interface Node2BeanTransformer
Throws:
Node2BeanException

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. Every subclass should override this method.


setProperty

public void setProperty(TypeMapping mapping,
                        TransformationState state,
                        PropertyTypeDescriptor descriptor,
                        Map<String,Object> values)
                 throws javax.jcr.RepositoryException
Description copied from interface: Node2BeanTransformer
Set this property on that bean. Allows excluding of properties.

Specified by:
setProperty in interface Node2BeanTransformer
Throws:
javax.jcr.RepositoryException

isBeanEnabled

protected boolean isBeanEnabled(Object bean)

createCollectionFromMap

protected Collection<?> createCollectionFromMap(Map<?,?> map,
                                                Class<?> clazz)
                                         throws SecurityException,
                                                NoSuchMethodException,
                                                IllegalArgumentException,
                                                InstantiationException,
                                                IllegalAccessException,
                                                InvocationTargetException
Creates collection from map. Collection type depends on passed class parameter. If passed class parameter is interface, then default implementation will be used for creating collection.
By default If passed class parameter is an implementation of any collection type, then this method will create this implementation and returns it.

Parameters:
map - a map which values will be converted to a collection
clazz - collection type
Returns:
Collection of elements or null.
Throws:
SecurityException
NoSuchMethodException
IllegalArgumentException
InstantiationException
IllegalAccessException
InvocationTargetException


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