1 55 56 package org.jboss.axis.encoding; 57 58 import org.jboss.axis.utils.Messages; 59 import org.jboss.logging.Logger; 60 import org.xml.sax.SAXException ; 61 62 import java.lang.reflect.InvocationTargetException ; 63 import java.lang.reflect.Method ; 64 65 66 68 public class MethodTarget implements Target 69 { 70 private static Logger log = Logger.getLogger(MethodTarget.class.getName()); 71 72 private Object targetObject; 73 private Method targetMethod; 74 private static final Class [] objArg = new Class []{Object .class}; 75 76 82 public MethodTarget(Object targetObject, Method targetMethod) 83 { 84 this.targetObject = targetObject; 85 this.targetMethod = targetMethod; 86 } 87 88 94 public MethodTarget(Object targetObject, String methodName) 95 throws NoSuchMethodException 96 { 97 this.targetObject = targetObject; 98 Class cls = targetObject.getClass(); 99 targetMethod = cls.getMethod(methodName, objArg); 100 } 101 102 107 public void set(Object value) throws SAXException 108 { 109 try 110 { 111 targetMethod.invoke(targetObject, new Object []{value}); 112 } 113 catch (IllegalAccessException accEx) 114 { 115 log.error(Messages.getMessage("illegalAccessException00"), 116 accEx); 117 throw new SAXException (accEx); 118 } 119 catch (IllegalArgumentException argEx) 120 { 121 log.error(Messages.getMessage("illegalArgumentException00"), 122 argEx); 123 throw new SAXException (argEx); 124 } 125 catch (InvocationTargetException targetEx) 126 { 127 log.error(Messages.getMessage("invocationTargetException00"), 128 targetEx); 129 throw new SAXException (targetEx); 130 } 131 } 132 } 133 | Popular Tags |