1 16 package org.springframework.webflow.core; 17 18 import java.util.Map ; 19 20 import ognl.OgnlException; 21 import ognl.PropertyAccessor; 22 23 import org.springframework.binding.collection.MapAdaptable; 24 import org.springframework.binding.expression.support.OgnlExpressionParser; 25 import org.springframework.webflow.core.collection.MutableAttributeMap; 26 27 33 class WebFlowOgnlExpressionParser extends OgnlExpressionParser { 34 35 38 public WebFlowOgnlExpressionParser() { 39 addPropertyAccessor(MapAdaptable.class, new MapAdaptablePropertyAccessor()); 40 addPropertyAccessor(MutableAttributeMap.class, new MutableAttributeMapPropertyAccessor()); 41 } 42 43 48 private static class MapAdaptablePropertyAccessor implements PropertyAccessor { 49 public Object getProperty(Map context, Object target, Object name) throws OgnlException { 50 return ((MapAdaptable)target).asMap().get(name); 51 } 52 53 public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { 54 throw new UnsupportedOperationException ( 55 "Cannot mutate immutable attribute collections; operation disallowed"); 56 } 57 } 58 59 64 private static class MutableAttributeMapPropertyAccessor extends MapAdaptablePropertyAccessor { 65 public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { 66 ((MutableAttributeMap)target).put((String )name, value); 67 } 68 } 69 } | Popular Tags |