KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > xml > DelegatingNutsFunction


1 package jfun.yan.xml;
2
3 /**
4  * This is the super class for conveniently delegating
5  * to another NutsFunction object.
6  * This class does nothing but forwarding the call
7  * to the delegate target.
8  * <p>
9  * Subclass can override any method to provide custom behavior.
10  * </p>
11  * <p>
12  * @author Ben Yu
13  * Nov 27, 2005 11:45:45 AM
14  */

15 public class DelegatingNutsFunction implements NutsFunction {
16   private final NutsFunction fun;
17
18   public String JavaDoc[] getParameterNames() {
19     return fun.getParameterNames();
20   }
21   /**
22    * To get the delegate target.
23    */

24   public NutsFunction getDelegateTarget(){
25     return fun;
26   }
27   /**
28    * Create a DelegatingNutsFunction object.
29    * @param fun the delegate target.
30    */

31   public DelegatingNutsFunction(NutsFunction fun) {
32     this.fun = fun;
33   }
34
35   public Object JavaDoc call(Object JavaDoc[] args) {
36     return fun.call(args);
37   }
38
39   public Location getLocation() {
40     return fun.getLocation();
41   }
42
43   public String JavaDoc getName() {
44     return fun.getName();
45   }
46
47   public int getParameterCount() {
48     return fun.getParameterCount();
49   }
50
51   public Class JavaDoc getReturnType() {
52     return fun.getReturnType();
53   }
54   public boolean equals(Object JavaDoc obj) {
55     if(obj instanceof DelegatingNutsFunction){
56       DelegatingNutsFunction other = (DelegatingNutsFunction)obj;
57       return fun==null?other.fun==null:fun.equals(other.fun);
58     }
59     else return false;
60   }
61   public int hashCode() {
62     return fun.hashCode();
63   }
64   public String JavaDoc toString() {
65     return fun.toString();
66   }
67   
68 }
69
Popular Tags