1 24 package org.riotfamily.forms.support; 25 26 import java.util.Map ; 27 28 import org.riotfamily.common.beans.MapWrapper; 29 import org.riotfamily.common.beans.ObjectWrapper; 30 import org.riotfamily.common.beans.ProtectedBeanWrapper; 31 import org.springframework.beans.BeansException; 32 import org.springframework.beans.PropertyValue; 33 import org.springframework.beans.PropertyValues; 34 35 public class MapOrBeanWrapper implements ObjectWrapper { 36 37 private ObjectWrapper wrapper; 38 39 public MapOrBeanWrapper(Class objectClass) { 40 if (Map .class.isAssignableFrom(objectClass)) { 41 wrapper = new MapWrapper(objectClass); 42 } 43 else { 44 wrapper = new ProtectedBeanWrapper(objectClass); 45 } 46 } 47 48 51 public MapOrBeanWrapper(Object object) { 52 if (object instanceof Map ) { 53 wrapper = new MapWrapper((Map ) object); 54 } 55 else { 56 wrapper = new ProtectedBeanWrapper(object); 57 } 58 } 59 60 public Class getPropertyType(String propertyName) throws BeansException { 61 return this.wrapper.getPropertyType(propertyName); 62 } 63 64 public Object getPropertyValue(String propertyName) throws BeansException { 65 return this.wrapper.getPropertyValue(propertyName); 66 } 67 68 public Class getObjectClass() { 69 return this.wrapper.getObjectClass(); 70 } 71 72 public Object getObject() { 73 return this.wrapper.getObject(); 74 } 75 76 public boolean isReadableProperty(String propertyName) throws BeansException { 77 return this.wrapper.isReadableProperty(propertyName); 78 } 79 80 public boolean isWritableProperty(String propertyName) throws BeansException { 81 return this.wrapper.isWritableProperty(propertyName); 82 } 83 84 public void setPropertyValue(PropertyValue pv) throws BeansException { 85 this.wrapper.setPropertyValue(pv); 86 } 87 88 public void setPropertyValue(String propertyName, Object value) throws BeansException { 89 this.wrapper.setPropertyValue(propertyName, value); 90 } 91 92 public void setPropertyValues(Map map) throws BeansException { 93 this.wrapper.setPropertyValues(map); 94 } 95 96 public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid) throws BeansException { 97 this.wrapper.setPropertyValues(pvs, ignoreUnknown, ignoreInvalid); 98 } 99 100 public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown) throws BeansException { 101 this.wrapper.setPropertyValues(pvs, ignoreUnknown); 102 } 103 104 public void setPropertyValues(PropertyValues pvs) throws BeansException { 105 this.wrapper.setPropertyValues(pvs); 106 } 107 108 public void setObject(Object object) { 109 this.wrapper.setObject(object); 110 } 111 112 } 113 | Popular Tags |