KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > DynamicPropertyWritingBinder


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  * Zephyr Business Solution
21  *
22  * @author Ben Yu
23  *
24  */

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