1 16 17 package org.springframework.beans; 18 19 import java.util.LinkedList ; 20 import java.util.List ; 21 import java.util.Map ; 22 23 33 public abstract class AbstractPropertyAccessor extends PropertyEditorRegistrySupport 34 implements ConfigurablePropertyAccessor { 35 36 private boolean extractOldValueForEditor = false; 37 38 39 public void setExtractOldValueForEditor(boolean extractOldValueForEditor) { 40 this.extractOldValueForEditor = extractOldValueForEditor; 41 } 42 43 public boolean isExtractOldValueForEditor() { 44 return extractOldValueForEditor; 45 } 46 47 48 public void setPropertyValue(PropertyValue pv) throws BeansException { 49 setPropertyValue(pv.getName(), pv.getValue()); 50 } 51 52 public void setPropertyValues(Map map) throws BeansException { 53 setPropertyValues(new MutablePropertyValues(map)); 54 } 55 56 public void setPropertyValues(PropertyValues pvs) throws BeansException { 57 setPropertyValues(pvs, false, false); 58 } 59 60 public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown) throws BeansException { 61 setPropertyValues(pvs, ignoreUnknown, false); 62 } 63 64 public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid) 65 throws BeansException { 66 67 List propertyAccessExceptions = new LinkedList (); 68 PropertyValue[] pvArray = pvs.getPropertyValues(); 69 for (int i = 0; i < pvArray.length; i++) { 70 try { 71 setPropertyValue(pvArray[i]); 75 } 76 catch (NotWritablePropertyException ex) { 77 if (!ignoreUnknown) { 78 throw ex; 79 } 80 } 82 catch (NullValueInNestedPathException ex) { 83 if (!ignoreInvalid) { 84 throw ex; 85 } 86 } 88 catch (PropertyAccessException ex) { 89 propertyAccessExceptions.add(ex); 90 } 91 } 92 93 if (!propertyAccessExceptions.isEmpty()) { 95 PropertyAccessException[] paeArray = (PropertyAccessException[]) 96 propertyAccessExceptions.toArray(new PropertyAccessException[propertyAccessExceptions.size()]); 97 throw new PropertyBatchUpdateException(paeArray); 98 } 99 } 100 101 102 public Class getPropertyType(String propertyPath) { 103 return null; 104 } 105 106 115 public abstract Object getPropertyValue(String propertyName) throws BeansException; 116 117 126 public abstract void setPropertyValue(String propertyName, Object value) throws BeansException; 127 128 } 129 | Popular Tags |