KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > DynamicPropertyReadingBinder


1 /*****************************************************************************
2  * Copyright (C) Zephyr Business Solution. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8
9 /*
10  * Created on Apr 22, 2005
11  *
12  * Author Ben Yu
13  * ZBS
14  */

15 package jfun.yan;
16
17 import java.beans.IntrospectionException JavaDoc;
18
19
20 /**
21  * Zephyr Business Solution
22  *
23  * @author Ben Yu
24  *
25  */

26 final class DynamicPropertyReadingBinder implements ComponentBinder {
27   private final String JavaDoc prop;
28   
29   public Class JavaDoc bindType(Class JavaDoc type) {
30     return null;
31   }
32   public Verifiable verify(Class JavaDoc type) {
33     try{
34       return Components.getter(type, null, prop);
35     }
36     catch(IntrospectionException JavaDoc e){
37       throw new InvalidPropertyException(type, prop, e.getMessage());
38     }
39   }
40   public Creator bind(Object JavaDoc v)
41   throws IntrospectionException JavaDoc {
42     return Components.getter(v, prop);
43   }
44   DynamicPropertyReadingBinder(final String JavaDoc prop) {
45     this.prop = prop;
46   }
47   
48   public boolean equals(Object JavaDoc obj) {
49     if(obj instanceof DynamicPropertyReadingBinder){
50       final DynamicPropertyReadingBinder other =
51         (DynamicPropertyReadingBinder)obj;
52       return prop.equals(other.prop);
53     }
54     else return false;
55   }
56   public int hashCode() {
57     return prop.hashCode();
58   }
59   public String JavaDoc toString() {
60     return prop.toString();
61   }
62 }
63
Popular Tags