FileDocCategorySizeDatePackage
Component.javaAPI DocHibernate 3.2.56854Thu Jul 13 19:09:20 BST 2006org.hibernate.mapping

Component

public class Component extends SimpleValue implements MetaAttributable
The mapping for a component, composite element, composite identifier, etc.
author
Gavin King

Fields Summary
private ArrayList
properties
private String
componentClassName
private boolean
embedded
private String
parentProperty
private PersistentClass
owner
private boolean
dynamic
private Map
metaAttributes
private String
nodeName
private boolean
isKey
private String
roleName
private Map
tuplizerImpls
private org.hibernate.type.Type
type
Constructors Summary
public Component(PersistentClass owner)


	     
		super( owner.getTable() );
		this.owner = owner;
	
public Component(Component component)

		super( component.getTable() );
		this.owner = component.getOwner();
	
public Component(Join join)

		super( join.getTable() );
		this.owner = join.getPersistentClass();
	
public Component(Collection collection)

		super( collection.getCollectionTable() );
		this.owner = collection.getOwner();
	
Methods Summary
public java.lang.Objectaccept(ValueVisitor visitor)

		return visitor.accept(this);
	
public voidaddColumn(Column column)

		throw new UnsupportedOperationException("Cant add a column to a component");
	
public voidaddProperty(Property p)

		properties.add(p);
	
public voidaddTuplizer(org.hibernate.EntityMode entityMode, java.lang.String implClassName)

		if ( tuplizerImpls == null ) {
			tuplizerImpls = new HashMap();
		}
		tuplizerImpls.put( entityMode, implClassName );
	
private org.hibernate.type.TypebuildType()

		// TODO : temporary initial step towards HHH-1907
		ComponentMetamodel metamodel = new ComponentMetamodel( this );
		if ( isEmbedded() ) {
			return new EmbeddedComponentType( metamodel );
		}
		else {
			return new ComponentType( metamodel );
		}
	
public boolean[]getColumnInsertability()

		boolean[] result = new boolean[ getColumnSpan() ];
		Iterator iter = getPropertyIterator();
		int i=0;
		while ( iter.hasNext() ) {
			Property prop = (Property) iter.next();
			boolean[] chunk = prop.getValue().getColumnInsertability();
			if ( prop.isInsertable() ) {
				System.arraycopy(chunk, 0, result, i, chunk.length);
			}
			i+=chunk.length;
		}
		return result;
	
public java.util.IteratorgetColumnIterator()

		Iterator[] iters = new Iterator[ getPropertySpan() ];
		Iterator iter = getPropertyIterator();
		int i=0;
		while ( iter.hasNext() ) {
			iters[i++] = ( (Property) iter.next() ).getColumnIterator();
		}
		return new JoinedIterator(iters);
	
public intgetColumnSpan()

		int n=0;
		Iterator iter = getPropertyIterator();
		while ( iter.hasNext() ) {
			Property p = (Property) iter.next();
			n+= p.getColumnSpan();
		}
		return n;
	
public boolean[]getColumnUpdateability()

		boolean[] result = new boolean[ getColumnSpan() ];
		Iterator iter = getPropertyIterator();
		int i=0;
		while ( iter.hasNext() ) {
			Property prop = (Property) iter.next();
			boolean[] chunk = prop.getValue().getColumnUpdateability();
			if ( prop.isUpdateable() ) {
				System.arraycopy(chunk, 0, result, i, chunk.length);
			}
			i+=chunk.length;
		}
		return result;
	
public java.lang.ClassgetComponentClass()

		try {
			return ReflectHelper.classForName(componentClassName);
		}
		catch (ClassNotFoundException cnfe) {
			throw new MappingException("component class not found: " + componentClassName, cnfe);
		}
	
public java.lang.StringgetComponentClassName()

		return componentClassName;
	
public MetaAttributegetMetaAttribute(java.lang.String attributeName)

		return metaAttributes==null?null:(MetaAttribute) metaAttributes.get(attributeName);
	
public java.util.MapgetMetaAttributes()

		return metaAttributes;
	
public java.lang.StringgetNodeName()

		return nodeName;
	
public PersistentClassgetOwner()

		return owner;
	
public java.lang.StringgetParentProperty()

		return parentProperty;
	
public PropertygetProperty(java.lang.String propertyName)

		Iterator iter = getPropertyIterator();
		while ( iter.hasNext() ) {
			Property prop = (Property) iter.next();
			if ( prop.getName().equals(propertyName) ) {
				return prop;
			}
		}
		throw new MappingException("component property not found: " + propertyName);
	
public java.util.IteratorgetPropertyIterator()

		return properties.iterator();
	
public intgetPropertySpan()

		return properties.size();
	
public java.lang.StringgetRoleName()

		return roleName;
	
public java.lang.StringgetTuplizerImplClassName(org.hibernate.EntityMode mode)

		// todo : remove this once ComponentMetamodel is complete and merged
		if ( tuplizerImpls == null ) {
			return null;
		}
		return ( String ) tuplizerImpls.get( mode );
	
public java.util.MapgetTuplizerMap()

		if ( tuplizerImpls == null ) {
			return null;
		}
		return java.util.Collections.unmodifiableMap( tuplizerImpls );
	
public org.hibernate.type.TypegetType()

		// added this caching as I noticed that getType() is being called multiple times...
		if ( type == null ) {
			type = buildType();
		}
		return type;
	
public booleanhasPojoRepresentation()

		return componentClassName!=null;
	
public booleanisDynamic()

		return dynamic;
	
public booleanisEmbedded()

		return embedded;
	
public booleanisKey()

		return isKey;
	
public voidsetComponentClassName(java.lang.String componentClass)

		this.componentClassName = componentClass;
	
public voidsetDynamic(boolean dynamic)

		this.dynamic = dynamic;
	
public voidsetEmbedded(boolean embedded)

		this.embedded = embedded;
	
public voidsetKey(boolean isKey)

		this.isKey = isKey;
	
public voidsetMetaAttributes(java.util.Map metas)

		this.metaAttributes = metas;
	
public voidsetNodeName(java.lang.String nodeName)

		this.nodeName = nodeName;
	
public voidsetOwner(PersistentClass owner)

		this.owner = owner;
	
public voidsetParentProperty(java.lang.String parentProperty)

		this.parentProperty = parentProperty;
	
public voidsetRoleName(java.lang.String roleName)

		this.roleName = roleName;
	
public voidsetTypeByReflection(java.lang.String propertyClass, java.lang.String propertyName)

public voidsetTypeUsingReflection(java.lang.String className, java.lang.String propertyName)

	
public java.lang.StringtoString()

		return getClass().getName() + '(" + properties.toString() + ')";