KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > DynamicIndexedPropertyWritingBinder


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 DynamicIndexedPropertyWritingBinder<T> implements ComponentBinder<T,T> {
26   private final String JavaDoc prop;
27   private final int ind;
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.indexed_setter(type, null, prop, ind);
35     }
36     catch(IntrospectionException JavaDoc e){
37       throw new InvalidPropertyException(type, prop, e.getMessage());
38     }
39   }
40   public Creator<T> bind(T v)
41   throws IntrospectionException JavaDoc {
42     return Components.indexed_setter(v, prop, ind);
43   }
44   DynamicIndexedPropertyWritingBinder(final String JavaDoc prop, final int ind) {
45     this.prop = prop;
46     this.ind = ind;
47   }
48   
49   public boolean equals(Object JavaDoc obj) {
50     if(obj instanceof DynamicIndexedPropertyWritingBinder){
51       final DynamicIndexedPropertyWritingBinder other =
52         (DynamicIndexedPropertyWritingBinder)obj;
53       return ind == other.ind && prop.equals(other.prop);
54     }
55     else return false;
56   }
57   public int hashCode() {
58     return prop.hashCode()*31+ind;
59   }
60   public String JavaDoc toString() {
61     return prop.toString()+"["+ind+"]=";
62   }
63 }
64
Popular Tags