FileDocCategorySizeDatePackage
PojoComponentTuplizer.javaAPI DocHibernate 3.2.55531Tue Jul 31 08:39:46 BST 2007org.hibernate.tuple.component

PojoComponentTuplizer

public class PojoComponentTuplizer extends AbstractComponentTuplizer
A {@link ComponentTuplizer} specific to the pojo entity mode.
author
Gavin King
author
Steve Ebersole

Fields Summary
private final Class
componentClass
private org.hibernate.bytecode.ReflectionOptimizer
optimizer
private final org.hibernate.property.Getter
parentGetter
private final org.hibernate.property.Setter
parentSetter
Constructors Summary
public PojoComponentTuplizer(org.hibernate.mapping.Component component)

		super( component );

		this.componentClass = component.getComponentClass();

		String[] getterNames = new String[propertySpan];
		String[] setterNames = new String[propertySpan];
		Class[] propTypes = new Class[propertySpan];
		for ( int i = 0; i < propertySpan; i++ ) {
			getterNames[i] = getters[i].getMethodName();
			setterNames[i] = setters[i].getMethodName();
			propTypes[i] = getters[i].getReturnType();
		}

		final String parentPropertyName = component.getParentProperty();
		if ( parentPropertyName == null ) {
			parentSetter = null;
			parentGetter = null;
		}
		else {
			PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( null );
			parentSetter = pa.getSetter( componentClass, parentPropertyName );
			parentGetter = pa.getGetter( componentClass, parentPropertyName );
		}

		if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) {
			optimizer = null;
		}
		else {
			// TODO: here is why we need to make bytecode provider global :(
			// TODO : again, fix this after HHH-1907 is complete
			optimizer = Environment.getBytecodeProvider().getReflectionOptimizer(
					componentClass, getterNames, setterNames, propTypes
			);
		}
	
Methods Summary
protected org.hibernate.property.GetterbuildGetter(org.hibernate.mapping.Component component, org.hibernate.mapping.Property prop)

		return prop.getGetter( component.getComponentClass() );
	
protected org.hibernate.tuple.InstantiatorbuildInstantiator(org.hibernate.mapping.Component component)

		if ( component.isEmbedded() && ReflectHelper.isAbstractClass( component.getComponentClass() ) ) {
			return new ProxiedInstantiator( component );
		}
		if ( optimizer == null ) {
			return new PojoInstantiator( component, null );
		}
		else {
			return new PojoInstantiator( component, optimizer.getInstantiationOptimizer() );
		}
	
protected org.hibernate.property.SetterbuildSetter(org.hibernate.mapping.Component component, org.hibernate.mapping.Property prop)

		return prop.getSetter( component.getComponentClass() );
	
public java.lang.ClassgetMappedClass()

		return componentClass;
	
public java.lang.ObjectgetParent(java.lang.Object component)

		return parentGetter.get( component );
	
public java.lang.Object[]getPropertyValues(java.lang.Object component)

		if ( component == BackrefPropertyAccessor.UNKNOWN ) {
			return new Object[ propertySpan ];
		}
		if ( optimizer != null && optimizer.getAccessOptimizer() != null ) {
			return optimizer.getAccessOptimizer().getPropertyValues( component );
		}
		else {
			return super.getPropertyValues(component);
		}
	
public booleanhasParentProperty()

		return parentGetter!=null;
	
public booleanisMethodOf(java.lang.reflect.Method method)

		for ( int i=0; i<propertySpan; i++ ) {
			final Method getterMethod = getters[i].getMethod();
			if ( getterMethod!=null && getterMethod.equals(method) ) return true;
		}
		return false;
	
public voidsetParent(java.lang.Object component, java.lang.Object parent, org.hibernate.engine.SessionFactoryImplementor factory)

		parentSetter.set(component, parent, factory);
	
public voidsetPropertyValues(java.lang.Object component, java.lang.Object[] values)

		if ( optimizer != null && optimizer.getAccessOptimizer() != null ) {
				optimizer.getAccessOptimizer().setPropertyValues( component, values );
		}
		else {
			super.setPropertyValues(component, values);
		}