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.Field ; 63 64 65 67 public class FieldTarget implements Target 68 { 69 private static Logger log = Logger.getLogger(FieldTarget.class.getName()); 70 71 private Object targetObject; 72 private Field targetField; 73 74 public FieldTarget(Object targetObject, Field targetField) 75 { 76 this.targetObject = targetObject; 77 this.targetField = targetField; 78 } 79 80 public FieldTarget(Object targetObject, String fieldName) 81 throws NoSuchFieldException 82 { 83 Class cls = targetObject.getClass(); 84 targetField = cls.getField(fieldName); 85 this.targetObject = targetObject; 86 } 87 88 public void set(Object value) throws SAXException 89 { 90 try 91 { 92 targetField.set(targetObject, value); 93 } 94 catch (IllegalAccessException accEx) 95 { 96 log.error(Messages.getMessage("illegalAccessException00"), 97 accEx); 98 throw new SAXException (accEx); 99 } 100 catch (IllegalArgumentException argEx) 101 { 102 log.error(Messages.getMessage("illegalArgumentException00"), 103 argEx); 104 throw new SAXException (argEx); 105 } 106 } 107 } 108 | Popular Tags |