1 package org.apache.velocity.runtime.parser.node;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.lang.reflect.InvocationTargetException;
23 import java.lang.reflect.Method;
24
25 import org.apache.velocity.runtime.log.Log;
26
27 /**
28 * Abstract class that is used to execute an arbitrary
29 * method that is in introspected. This is the superclass
30 * for the PutExecutor and SetPropertyExecutor.
31 *
32 * There really should be a superclass for this and AbstractExecutor (which should
33 * be refactored to GetExecutor) because they differ only in the execute() method.
34 *
35 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
36 * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
37 * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
38 * @version $Id: SetExecutor.java 463298 2006-10-12 16:10:32Z henning $
39 */
40 public abstract class SetExecutor
41 {
42 /** Class logger */
43 protected Log log = null;
44
45 /**
46 * Method to be executed.
47 */
48 private Method method = null;
49
50 /**
51 * Execute method against context.
52 * @param o
53 * @param value
54 * @return The result of the invocation.
55 * @throws IllegalAccessException
56 * @throws InvocationTargetException
57 */
58 public abstract Object execute(Object o, Object value)
59 throws IllegalAccessException, InvocationTargetException;
60
61 /**
62 * Tell whether the executor is alive by looking
63 * at the value of the method.
64 * @return True if the executor is alive.
65 */
66 public boolean isAlive()
67 {
68 return (method != null);
69 }
70
71 /**
72 * @return The method to invoke.
73 */
74 public Method getMethod()
75 {
76 return method;
77 }
78
79 /**
80 * @param method
81 */
82 protected void setMethod(final Method method)
83 {
84 this.method = method;
85 }
86 }