KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > lifecycle > MethodNameProcedure


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 Oct 13, 2005
11  *
12  * Author Michelle Lei
13  * ZBS
14  */

15 package jfun.yan.lifecycle;
16
17 import java.io.Serializable JavaDoc;
18 import java.util.Arrays JavaDoc;
19
20 import jfun.util.StringUtils;
21
22
23 final class MethodNameProcedure implements Procedure, Serializable JavaDoc {
24   private final String JavaDoc name;
25   private final Class JavaDoc[] param_types;
26   MethodNameProcedure(String JavaDoc name, Class JavaDoc[] ptypes) {
27     this.name = name;
28     this.param_types = ptypes;
29   }
30
31   public String JavaDoc toString(){
32     return name+StringUtils.listString("(", ", ", ")", param_types);
33   }
34   
35   public boolean equals(Object JavaDoc obj) {
36     if(obj instanceof MethodNameProcedure){
37       final MethodNameProcedure other = (MethodNameProcedure)obj;
38       return name.equals(other.name) && Arrays.equals(param_types, other.param_types);
39       
40     }
41     return false;
42   }
43
44   public int hashCode() {
45     return name.hashCode();
46   }
47
48   public void invoke(Object JavaDoc self, Object JavaDoc[] args) throws Throwable JavaDoc {
49     MethodProcedure.invokeMethod(self,
50         self.getClass().getMethod(name, param_types), args);
51   }
52 }
53
Popular Tags