KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > IndexedPropertyReader


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 jfun.yan.function.Function;
18
19 /**
20  * Zephyr Business Solution
21  *
22  * @author Ben Yu
23  *
24  */

25 final class IndexedPropertyReader implements Function {
26   private final jfun.util.beans.Bean bean;
27   private final String JavaDoc prop;
28   private final int ind;
29   public boolean isConcrete(){
30     return false;
31   }
32   IndexedPropertyReader(final jfun.util.beans.Bean bean,
33       final String JavaDoc prop, final int ind) {
34     this.bean = bean;
35     this.prop = prop;
36     this.ind = ind;
37   }
38   
39   public Object JavaDoc call(Object JavaDoc[] args) throws Throwable JavaDoc {
40     return bean.getProperty(prop, ind);
41   }
42   public Class JavaDoc[] getParameterTypes() {
43     return Utils.no_params;
44   }
45   public Class JavaDoc getReturnType() {
46     return bean.getBeanType().getIndexedPropertyType(prop);
47   }
48   public boolean equals(Object JavaDoc obj) {
49     if(obj instanceof IndexedPropertyReader){
50       final IndexedPropertyReader other = (IndexedPropertyReader)obj;
51       return ind==other.ind && prop.equals(other.prop) &&
52       bean.equals(other.bean);
53     }
54     else return false;
55   }
56   public int hashCode() {
57     return (bean.hashCode() * 31 + prop.hashCode())*31+ind;
58   }
59   public String JavaDoc toString() {
60     return bean.toString() + "." + prop+"["+ind+"]";
61   }
62   public String JavaDoc getName(){
63     return prop;
64   }
65 }
66
Popular Tags