private Object retrieveSimpleField()

in src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java [165:212]


	private Object retrieveSimpleField(ClassDescriptor classDescriptor, Node node, Object initializedBean, FieldDescriptor fieldDescriptor, String fieldName, String propertyName) throws RepositoryException, ValueFormatException, PathNotFoundException {

	    Value propValue;
		if (node.hasProperty(propertyName))
		{
			propValue = node.getProperty(propertyName).getValue();
			
		}
		else if (fieldDescriptor.getJcrDefaultValue() != null)
		{
		    ValueFactory vf = node.getSession().getValueFactory();
		    propValue = vf.createValue(fieldDescriptor.getJcrDefaultValue());
		}
		else
		{
		    PropertyDefinition propDef = getPropertyDefinition(node, propertyName);
		
		    if (propDef != null && propDef.getDefaultValues() != null && propDef.getDefaultValues().length == 1)
		    {
                log.debug("retrieveSimpleField: Use default value from property definition for missing mapped property " + propertyName + " of class '" + classDescriptor.getClassName() + "'");
		        propValue = propDef.getDefaultValues()[0];
		    } else
		    {
                log.debug("retrieveSimpleField: No default value available for missing mapped property " + propertyName + " of class '" + classDescriptor.getClassName() + "'");
		        propValue = null;
		    }
		}
		
        // HINT: lazy initialize target bean - The bean can be null when it is inline
		if (initializedBean == null)
		{
		
		    // if we do not have a value, we do nothing at all and just return null
		    if (propValue == null)
		    {
		        return null;
		    }
		
		    // otherwise create the bean to set the value
		    initializedBean = ReflectionUtils.newInstance(classDescriptor.getClassName());
		}

        AtomicTypeConverter converter = getAtomicTypeConverter(fieldDescriptor, initializedBean, fieldName);
        Object fieldValue = (propValue != null) ? converter.getObject(propValue) : null;
        ReflectionUtils.setNestedProperty(initializedBean, fieldName, fieldValue);

        return initializedBean;
	}