1 package org.hibernate.mapping; 3 4 import org.hibernate.MappingException; 5 import org.hibernate.type.CollectionType; 6 import org.hibernate.type.PrimitiveType; 7 import org.hibernate.type.TypeFactory; 8 import org.hibernate.util.ReflectHelper; 9 10 15 public class Array extends List { 16 17 private String elementClassName; 18 19 23 public Array(PersistentClass owner) { 24 super(owner); 25 } 26 27 public Class getElementClass() throws MappingException { 28 if (elementClassName==null) { 29 org.hibernate.type.Type elementType = getElement().getType(); 30 return isPrimitiveArray() ? 31 ( (PrimitiveType) elementType ).getPrimitiveClass() : 32 elementType.getReturnedClass(); 33 } 34 else { 35 try { 36 return ReflectHelper.classForName(elementClassName); 37 } 38 catch (ClassNotFoundException cnfe) { 39 throw new MappingException(cnfe); 40 } 41 } 42 } 43 44 public CollectionType getDefaultCollectionType() throws MappingException { 45 return TypeFactory.array( getRole(), getReferencedPropertyName(), isEmbedded(), getElementClass() ); 46 } 47 48 public boolean isArray() { 49 return true; 50 } 51 52 55 public String getElementClassName() { 56 return elementClassName; 57 } 58 61 public void setElementClassName(String elementClassName) { 62 this.elementClassName = elementClassName; 63 } 64 65 public Object accept(ValueVisitor visitor) { 66 return visitor.accept(this); 67 } 68 } 69 | Popular Tags |