1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.util;
16  
17  import java.io.Serializable;
18  
19  import java.lang.reflect.Method;
20  
21  import java.util.Arrays;
22  
23  /**
24   * <a href="MethodWrapper.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author     Brian Wing Shun Chan
27   * @deprecated
28   */
29  public class MethodWrapper implements Serializable {
30  
31      public MethodWrapper(String className, String methodName) {
32          this(className, methodName, new Object[0]);
33      }
34  
35      public MethodWrapper(String className, String methodName, Object argument) {
36          this(className, methodName, new Object[] {argument});
37      }
38  
39      public MethodWrapper(
40          String className, String methodName, Object[] arguments) {
41  
42          _className = className;
43          _methodName = methodName;
44          _arguments = arguments;
45      }
46  
47      public MethodWrapper(Method method, Object[] arguments) {
48          this(method.getDeclaringClass().getName(), method.getName(), arguments);
49  
50          _argumentClassNames = new String[arguments.length];
51  
52          Class<?>[] parameterTypes = method.getParameterTypes();
53  
54          for (int i = 0; i < parameterTypes.length; i++) {
55              _argumentClassNames[i] = parameterTypes[i].getName();
56          }
57      }
58  
59      public String getClassName() {
60          return _className;
61      }
62  
63      public String getMethodName() {
64          return _methodName;
65      }
66  
67      /**
68       * @deprecated Use <code>getArguments</code>.
69       */
70      public Object[] getArgs() {
71          return getArguments();
72      }
73  
74      public String[] getArgumentClassNames() {
75          return _argumentClassNames;
76      }
77  
78      public Object[] getArguments() {
79          Object[] arguments = new Object[_arguments.length];
80  
81          System.arraycopy(_arguments, 0, arguments, 0, _arguments.length);
82  
83          return arguments;
84      }
85  
86      public String toString() {
87          StringBundler sb = new StringBundler(9);
88  
89          sb.append("{className=");
90          sb.append(_className);
91          sb.append(", methodName=");
92          sb.append(_methodName);
93  
94          if (_argumentClassNames != null) {
95              sb.append(", argumentClassNames=");
96              sb.append(Arrays.toString(_argumentClassNames));
97          }
98  
99          sb.append(", arguments=");
100         sb.append(Arrays.toString(_arguments));
101         sb.append("}");
102 
103         return sb.toString();
104     }
105 
106     private String _className;
107     private String _methodName;
108     private String[] _argumentClassNames;
109     private Object[] _arguments;
110 
111 }