1 7 package com.inversoft.beans; 8 9 10 import java.util.List ; 11 12 import com.inversoft.util.typeconverter.TypeConversionException; 13 14 15 134 public class NestedBeanProperty extends BaseBeanProperty { 135 136 JavaBean javaBean; 137 List info; 138 boolean strict; 139 BeanProperty root; 140 JavaBeanTools.PropertyInfo rootPi; 141 142 149 protected NestedBeanProperty() { 150 super(); 151 strict = false; 152 } 153 154 165 public NestedBeanProperty(String propertyName, Class beanClass) 166 throws BeanException { 167 this(propertyName, beanClass, false); } 169 170 183 public NestedBeanProperty(String propertyName, String beanClass) 184 throws BeanException { 185 this(propertyName, beanClass, false); } 187 188 202 public NestedBeanProperty(String propertyName, Class beanClass, boolean strict) 203 throws BeanException { 204 super(propertyName, beanClass); this.strict = strict; 206 } 207 208 224 public NestedBeanProperty(String propertyName, String beanClass, boolean strict) 225 throws BeanException { 226 super(propertyName, beanClass); this.strict = strict; 228 } 229 230 237 protected void initialize() throws BeanException { 238 javaBean = new JavaBean(beanClass); 239 JavaBeanTools.NameInfo ni = JavaBeanTools.splitNameFront(propertyName); 240 JavaBeanTools.PropertyInfo pi = 241 JavaBeanTools.retrievePropertyInfo(ni.localPropertyName); 242 243 root = javaBean.getBeanProperty(pi.propertyName); 244 } 245 246 249 public boolean isStrict() { 250 return strict; 251 } 252 253 256 public void setStrict(boolean value) { 257 strict = value; 258 } 259 260 267 public BeanProperty getRootProperty() { 268 return root; 269 } 270 271 276 public Class getPropertyType() { 277 Class type = null; 278 try { 279 BeanProperty bp = javaBean.getBeanProperty(propertyName); 280 if (bp != null) { 281 type = bp.getPropertyType(); 282 } 283 } catch (BeanException be) { 284 } 286 287 return type; 288 } 289 290 300 public Object getPropertyValue(final Object bean) throws BeanException { 301 return getPropertyValue(bean, (List ) null); 302 } 303 304 317 public Object getPropertyValue(final Object bean, final List indices) 318 throws BeanException { 319 320 Object value = javaBean.getPropertyValue(propertyName, bean, indices, strict); 321 if (hasPropertyListeners()) { 322 firePropertyEvent(GET, value, value, bean, indices); 323 } 324 325 return value; 326 } 327 328 341 public Object getPropertyValue(final Object bean, final int [][] indices) 342 throws BeanException { 343 List list = javaBean.convertArray(indices); 344 return getPropertyValue(bean, list); 345 } 346 347 362 public void setPropertyValue(final Object bean, Object value, 363 final boolean convert) 364 throws BeanException, TypeConversionException { 365 setPropertyValue(bean, (List ) null, value, convert); 366 } 367 368 385 public void setPropertyValue(final Object bean, final List indices, Object value, 386 final boolean convert) 387 throws BeanException, TypeConversionException { 388 389 Object oldValue = null; 390 if (hasPropertyListeners()) { 391 oldValue = javaBean.getPropertyValue(propertyName, bean, indices, strict); 392 } 393 394 javaBean.setPropertyValue(propertyName, bean, indices, value, convert, strict); 395 396 if (hasPropertyListeners()) { 397 firePropertyEvent(SET, oldValue, value, bean, indices); 398 } 399 } 400 401 418 public void setPropertyValue(final Object bean, final int[][] indices, Object value, 419 final boolean convert) 420 throws BeanException, TypeConversionException { 421 List list = javaBean.convertArray(indices); 422 setPropertyValue(bean, list, value, convert); 423 } 424 } | Popular Tags |