1 16 17 package org.apache.commons.betwixt.expression; 18 19 import org.apache.commons.beanutils.DynaBean; 20 21 29 public class DynaBeanExpression implements Expression { 30 31 32 private String propertyName; 33 34 37 public DynaBeanExpression() { 38 super(); 39 } 40 41 46 public DynaBeanExpression(String propertyName) { 47 super(); 48 setPropertyName(propertyName); 49 } 50 51 60 public Object evaluate(Context context) { 61 62 if (context.getBean() instanceof DynaBean && propertyName != null) { 63 return ((DynaBean)context.getBean()).get(propertyName); 64 } else { 65 return null; 66 } 67 } 68 69 73 public void update(Context context, String newValue) { 74 } 76 77 81 public String getPropertyName() { 82 return propertyName; 83 } 84 85 89 public void setPropertyName(String propertyName) { 90 if (propertyName == null) { 91 throw new IllegalArgumentException ("propertyName is null"); 92 } 93 this.propertyName = propertyName; 94 } 95 96 } 97 | Popular Tags |