KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > FieldNameBinder


1 package jfun.yan;
2
3
4 /**
5  * For specifying a field name without knowing the class it belongs to.
6  * <p>
7  * Zephyr Business Solution
8  *
9  * @author Ben Yu
10  *
11  */

12 final class FieldNameBinder implements ComponentBinder {
13   public Verifiable verify(Class JavaDoc type) {
14     return Components.fun(Functions
15         .field(type, null, name, suppress_security));
16   }
17   public Creator bind(Object JavaDoc v){
18     if(v==null){
19       throw new NullPointerException JavaDoc("cannot access field "
20           + name +" on null.");
21     }
22     return Components.fun(
23         Functions.field(v, name, suppress_security));
24   }
25   public Class JavaDoc bindType(Class JavaDoc t){
26     return null;
27   }
28   private final String JavaDoc name;
29   private final boolean suppress_security;
30   FieldNameBinder(final String JavaDoc mname, final boolean suppress_security) {
31     this.name = mname;
32     this.suppress_security = suppress_security;
33   }
34   
35   public boolean equals(Object JavaDoc obj) {
36     if(obj instanceof FieldNameBinder){
37       final FieldNameBinder other = (FieldNameBinder)obj;
38       return suppress_security==other.suppress_security && name.equals(other.name);
39     }
40     else return false;
41   }
42   public int hashCode() {
43     return name.hashCode();
44   }
45   public String JavaDoc toString() {
46     return name.toString();
47   }
48 }
Popular Tags