info.magnolia.jcr.node2bean.impl
Class Node2BeanProcessorImpl

java.lang.Object
  extended by info.magnolia.jcr.node2bean.impl.Node2BeanProcessorImpl
All Implemented Interfaces:
Node2BeanProcessor

@Singleton
public class Node2BeanProcessorImpl
extends Object
implements Node2BeanProcessor

Contains the logic for traversing the hierarchy and do the calls to the transformer.


Constructor Summary
Node2BeanProcessorImpl(TypeMapping typeMapping, Node2BeanTransformer transformer)
           
 
Method Summary
 boolean isForceCreation()
           
protected  Node2BeanTransformer resolveTransformer(TypeDescriptor type, Node2BeanTransformer transformer)
           
 void setForceCreation(boolean forceCreation)
           
protected  void setProperties(Map<String,Object> values, Node2BeanTransformer transformer, TransformationState state)
          Populates the properties of the bean with values from the map.
 Object setProperties(Object bean, javax.jcr.Node node, boolean recursive, Node2BeanTransformer transformer, ComponentProvider componentProvider)
          Similar to toBean() but uses a passed bean as the root bean.
 Object toBean(javax.jcr.Node node)
          Transforms given node to bean.
 Object toBean(javax.jcr.Node node, boolean recursive, Node2BeanTransformer transformer, ComponentProvider componentProvider)
          Transforms the node to a bean using the passed transformer and component provider.
protected  Object toBean(javax.jcr.Node node, boolean recursive, Node2BeanTransformer transformer, TransformationState state, ComponentProvider componentProvider)
           
 Object toBean(javax.jcr.Node node, Class<?> defaultClass)
          Transforms given node to bean.
protected  Map<String,Object> toMap(javax.jcr.Node node, boolean recursive, Node2BeanTransformer transformer, TransformationState state, ComponentProvider componentProvider)
          Transforms the children of provided content into a map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node2BeanProcessorImpl

@Inject
public Node2BeanProcessorImpl(TypeMapping typeMapping,
                                     Node2BeanTransformer transformer)
Method Detail

toBean

public Object toBean(javax.jcr.Node node)
              throws Node2BeanException,
                     javax.jcr.RepositoryException
Description copied from interface: Node2BeanProcessor
Transforms given node to bean.

Specified by:
toBean in interface Node2BeanProcessor
Parameters:
node - which will be transformed to bean
Returns:
bean object
Throws:
Node2BeanException
javax.jcr.RepositoryException

toBean

public Object toBean(javax.jcr.Node node,
                     Class<?> defaultClass)
              throws Node2BeanException,
                     javax.jcr.RepositoryException
Description copied from interface: Node2BeanProcessor
Transforms given node to bean. Class parameter will be used in transformer as default type.

Specified by:
toBean in interface Node2BeanProcessor
Parameters:
node - which will be transformed to bean
defaultClass - default type
Returns:
bean object
Throws:
Node2BeanException
javax.jcr.RepositoryException

toBean

public Object toBean(javax.jcr.Node node,
                     boolean recursive,
                     Node2BeanTransformer transformer,
                     ComponentProvider componentProvider)
              throws Node2BeanException,
                     javax.jcr.RepositoryException
Description copied from interface: Node2BeanProcessor
Transforms the node to a bean using the passed transformer and component provider.

Specified by:
toBean in interface Node2BeanProcessor
Parameters:
node - which will be transformed to bean
recursive - if set to true then all subnodes will be transformed as well
Returns:
bean object
Throws:
Node2BeanException
javax.jcr.RepositoryException

toBean

protected Object toBean(javax.jcr.Node node,
                        boolean recursive,
                        Node2BeanTransformer transformer,
                        TransformationState state,
                        ComponentProvider componentProvider)
                 throws Node2BeanException,
                        javax.jcr.RepositoryException
Throws:
Node2BeanException
javax.jcr.RepositoryException

setProperties

public Object setProperties(Object bean,
                            javax.jcr.Node node,
                            boolean recursive,
                            Node2BeanTransformer transformer,
                            ComponentProvider componentProvider)
                     throws Node2BeanException,
                            javax.jcr.RepositoryException
Description copied from interface: Node2BeanProcessor
Similar to toBean() but uses a passed bean as the root bean.

Specified by:
setProperties in interface Node2BeanProcessor
Throws:
Node2BeanException
javax.jcr.RepositoryException

toMap

protected Map<String,Object> toMap(javax.jcr.Node node,
                                   boolean recursive,
                                   Node2BeanTransformer transformer,
                                   TransformationState state,
                                   ComponentProvider componentProvider)
                            throws Node2BeanException,
                                   javax.jcr.RepositoryException
Transforms the children of provided content into a map.

Throws:
Node2BeanException
javax.jcr.RepositoryException

setProperties

protected void setProperties(Map<String,Object> values,
                             Node2BeanTransformer transformer,
                             TransformationState state)
                      throws Node2BeanException,
                             javax.jcr.RepositoryException
Populates the properties of the bean with values from the map. TODO in case the bean is a map / collection the transfomer.setProperty() method should be called too TODO if the bean has not a certain property but a value is present, transformer.setProperty() should be called with a fake property descriptor

Throws:
Node2BeanException
javax.jcr.RepositoryException

resolveTransformer

protected Node2BeanTransformer resolveTransformer(TypeDescriptor type,
                                                  Node2BeanTransformer transformer)

isForceCreation

public boolean isForceCreation()

setForceCreation

public void setForceCreation(boolean forceCreation)


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