01: /**
02: * MVEL (The MVFLEX Expression Language)
03: *
04: * Copyright (C) 2007 Christopher Brock, MVFLEX/Valhalla Project and the Codehaus
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: */package org.mvel.util;
19:
20: import java.io.Serializable;
21: import java.lang.reflect.Method;
22:
23: public class MethodStub implements Serializable {
24: private Class classReference;
25: private String methodName;
26:
27: private transient Method method;
28:
29: public MethodStub() {
30: }
31:
32: public MethodStub(Method method) {
33: this .classReference = method.getDeclaringClass();
34: this .methodName = method.getName();
35: }
36:
37: public MethodStub(Class classReference, String methodName) {
38: this .classReference = classReference;
39: this .methodName = methodName;
40: }
41:
42: public Class getClassReference() {
43: return classReference;
44: }
45:
46: public void setClassReference(Class classReference) {
47: this .classReference = classReference;
48: }
49:
50: public String getMethodName() {
51: return methodName;
52: }
53:
54: public void setMethodName(String methodName) {
55: this .methodName = methodName;
56: }
57:
58: public Method getMethod() {
59: if (method == null) {
60: for (Method method : classReference.getMethods()) {
61: if (methodName.equals(method.getName()))
62: return this.method = method;
63: }
64: }
65: return method;
66: }
67: }
|