KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > property > EmbeddedPropertyAccessor


1 //$Id: EmbeddedPropertyAccessor.java,v 1.5 2005/07/16 22:20:47 oneovthafew Exp $
2
package org.hibernate.property;
3
4 import java.lang.reflect.Method JavaDoc;
5 import java.util.Map JavaDoc;
6
7 import org.hibernate.HibernateException;
8 import org.hibernate.PropertyNotFoundException;
9 import org.hibernate.engine.SessionImplementor;
10 import org.hibernate.engine.SessionFactoryImplementor;
11
12 /**
13  * @author Gavin King
14  */

15 public class EmbeddedPropertyAccessor implements PropertyAccessor {
16     
17     public static final class EmbeddedGetter implements Getter {
18         
19         private final Class JavaDoc clazz;
20         
21         EmbeddedGetter(Class JavaDoc clazz) {
22             this.clazz = clazz;
23         }
24         
25         public Object JavaDoc get(Object JavaDoc target) throws HibernateException {
26             return target;
27         }
28         
29         public Object JavaDoc getForInsert(Object JavaDoc target, Map JavaDoc mergeMap, SessionImplementor session) {
30             return get( target );
31         }
32
33         public Method JavaDoc getMethod() {
34             return null;
35         }
36
37         public String JavaDoc getMethodName() {
38             return null;
39         }
40
41         public Class JavaDoc getReturnType() {
42             return clazz;
43         }
44         
45         public String JavaDoc toString() {
46             return "EmbeddedGetter(" + clazz.getName() + ')';
47         }
48     }
49
50     public static final class EmbeddedSetter implements Setter {
51         
52         private final Class JavaDoc clazz;
53         
54         EmbeddedSetter(Class JavaDoc clazz) {
55             this.clazz = clazz;
56         }
57         
58         public Method JavaDoc getMethod() {
59             return null;
60         }
61
62         public String JavaDoc getMethodName() {
63             return null;
64         }
65
66         public void set(Object JavaDoc target, Object JavaDoc value, SessionFactoryImplementor factory) throws HibernateException {}
67         
68         public String JavaDoc toString() {
69             return "EmbeddedSetter(" + clazz.getName() + ')';
70         }
71     }
72
73     public Getter getGetter(Class JavaDoc theClass, String JavaDoc propertyName)
74     throws PropertyNotFoundException {
75         return new EmbeddedGetter(theClass);
76     }
77
78     public Setter getSetter(Class JavaDoc theClass, String JavaDoc propertyName)
79     throws PropertyNotFoundException {
80         return new EmbeddedSetter(theClass);
81     }
82
83 }
84
Popular Tags