1 16 17 package org.apache.axis.encoding; 18 19 import org.apache.axis.components.logger.LogFactory; 20 import org.apache.axis.utils.Messages; 21 import org.apache.commons.logging.Log; 22 import org.xml.sax.SAXException ; 23 24 import java.lang.reflect.Field ; 25 26 27 public class FieldTarget implements Target 29 { 30 protected static Log log = 31 LogFactory.getLog(FieldTarget.class.getName()); 32 33 private Object targetObject; 34 private Field targetField; 35 36 public FieldTarget(Object targetObject, Field targetField) 37 { 38 this.targetObject = targetObject; 39 this.targetField = targetField; 40 } 41 42 public FieldTarget(Object targetObject, String fieldName) 43 throws NoSuchFieldException 44 { 45 Class cls = targetObject.getClass(); 46 targetField = cls.getField(fieldName); 47 this.targetObject = targetObject; 48 } 49 50 public void set(Object value) throws SAXException { 51 try { 52 targetField.set(targetObject, value); 53 } catch (IllegalAccessException accEx) { 54 log.error(Messages.getMessage("illegalAccessException00"), 55 accEx); 56 throw new SAXException (accEx); 57 } catch (IllegalArgumentException argEx) { 58 log.error(Messages.getMessage("illegalArgumentException00"), 59 argEx); 60 throw new SAXException (argEx); 61 } 62 } 63 } 64 | Popular Tags |