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 685685 2008-08-13 21:43:27Z nbubna $ 39 * @since 1.5 40 */ 41 public abstract class SetExecutor 42 { 43 /** Class logger */ 44 protected Log log = null; 45 46 /** 47 * Method to be executed. 48 */ 49 private Method method = null; 50 51 /** 52 * Execute method against context. 53 * @param o 54 * @param value 55 * @return The result of the invocation. 56 * @throws IllegalAccessException 57 * @throws InvocationTargetException 58 */ 59 public abstract Object execute(Object o, Object value) 60 throws IllegalAccessException, InvocationTargetException; 61 62 /** 63 * Tell whether the executor is alive by looking 64 * at the value of the method. 65 * @return True if the executor is alive. 66 */ 67 public boolean isAlive() 68 { 69 return (method != null); 70 } 71 72 /** 73 * @return The method to invoke. 74 */ 75 public Method getMethod() 76 { 77 return method; 78 } 79 80 /** 81 * @param method 82 */ 83 protected void setMethod(final Method method) 84 { 85 this.method = method; 86 } 87 }