KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > PropertyReader


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