1 28 29 package com.caucho.config; 30 31 import com.caucho.util.L10N; 32 33 import java.lang.reflect.Method ; 34 35 38 public class ObjectAttributeStrategy extends AttributeStrategy { 39 static L10N L = new L10N(ObjectAttributeStrategy.class); 40 41 private final Method _setter; 42 private String _name; 43 44 public ObjectAttributeStrategy(Method setter, String name, Class type) 45 throws BeanBuilderException 46 { 47 _setter = setter; 48 _name = name; 49 } 50 51 public void setString(Object bean, String value) 52 throws BeanBuilderException 53 { 54 try { 55 if (value == null) { 56 setNull(bean); 57 return; 58 } 59 60 _setter.invoke(bean, new Object [] { _name, evalString(value) }); 61 } catch (Exception e) { 62 throw new BeanBuilderException(e); 63 } 64 } 65 66 private void setNull(Object bean) 67 throws Exception 68 { 69 _setter.invoke(bean, new Object [] { _name, null }); 70 } 71 72 public String toString() 73 { 74 return "ObjectAttributeStrategy[" + _setter + "]"; 75 } 76 } 77 | Popular Tags |