1 16 package org.apache.commons.jxpath.ri.model.dynamic; 17 18 import java.util.Locale ; 19 20 import org.apache.commons.jxpath.DynamicPropertyHandler; 21 import org.apache.commons.jxpath.JXPathBeanInfo; 22 import org.apache.commons.jxpath.JXPathIntrospector; 23 import org.apache.commons.jxpath.ri.QName; 24 import org.apache.commons.jxpath.ri.model.NodePointer; 25 import org.apache.commons.jxpath.ri.model.NodePointerFactory; 26 import org.apache.commons.jxpath.ri.model.beans.NullPointer; 27 import org.apache.commons.jxpath.util.ValueUtils; 28 29 35 public class DynamicPointerFactory implements NodePointerFactory { 36 37 public static final int DYNAMIC_POINTER_FACTORY_ORDER = 800; 38 39 public int getOrder() { 40 return DYNAMIC_POINTER_FACTORY_ORDER; 41 } 42 43 public NodePointer createNodePointer( 44 QName name, 45 Object bean, 46 Locale locale) 47 { 48 JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass()); 49 if (bi.isDynamic()) { 50 DynamicPropertyHandler handler = 51 ValueUtils.getDynamicPropertyHandler( 52 bi.getDynamicPropertyHandlerClass()); 53 return new DynamicPointer(name, bean, handler, locale); 54 } 55 return null; 56 } 57 58 public NodePointer createNodePointer( 59 NodePointer parent, 60 QName name, 61 Object bean) 62 { 63 if (bean == null) { 64 return new NullPointer(parent, name); 65 } 66 67 JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass()); 68 if (bi.isDynamic()) { 69 DynamicPropertyHandler handler = 70 ValueUtils.getDynamicPropertyHandler( 71 bi.getDynamicPropertyHandlerClass()); 72 return new DynamicPointer(parent, name, bean, handler); 73 } 74 return null; 75 } 76 } | Popular Tags |