01: //$Id: Any.java 4905 2004-12-07 09:59:56Z maxcsaucdk $
02: package org.hibernate.mapping;
03:
04: import java.util.Map;
05:
06: import org.hibernate.MappingException;
07: import org.hibernate.type.MetaType;
08: import org.hibernate.type.AnyType;
09: import org.hibernate.type.Type;
10: import org.hibernate.type.TypeFactory;
11:
12: /**
13: * A Hibernate "any" type (ie. polymorphic association to
14: * one-of-several tables).
15: * @author Gavin King
16: */
17: public class Any extends SimpleValue {
18:
19: private String identifierTypeName;
20: private String metaTypeName = "string";
21: private Map metaValues;
22:
23: public Any(Table table) {
24: super (table);
25: }
26:
27: public String getIdentifierType() {
28: return identifierTypeName;
29: }
30:
31: public void setIdentifierType(String identifierType) {
32: this .identifierTypeName = identifierType;
33: }
34:
35: public Type getType() throws MappingException {
36: return new AnyType(metaValues == null ? TypeFactory
37: .heuristicType(metaTypeName) : new MetaType(metaValues,
38: TypeFactory.heuristicType(metaTypeName)), TypeFactory
39: .heuristicType(identifierTypeName));
40: }
41:
42: public void setTypeByReflection(String propertyClass,
43: String propertyName) {
44: }
45:
46: public String getMetaType() {
47: return metaTypeName;
48: }
49:
50: public void setMetaType(String type) {
51: metaTypeName = type;
52: }
53:
54: public Map getMetaValues() {
55: return metaValues;
56: }
57:
58: public void setMetaValues(Map metaValues) {
59: this .metaValues = metaValues;
60: }
61:
62: public void setTypeUsingReflection(String className,
63: String propertyName) throws MappingException {
64: }
65:
66: public Object accept(ValueVisitor visitor) {
67: return visitor.accept(this);
68: }
69: }
|