public NodePointer createNodePointer(QName name, Object bean, Locale locale) { JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass()); return new BeanPointer(name, bean, bi, locale); }
protected boolean stream(ElementHandler handler) { // create an xpath context from the root element // TODO: cache the context, should work just the same // JXPathIntrospector.registerDynamicClass(ElementHandlerImpl.class, // ElementHandlerPropertyHandler.class); JXPathIntrospector.registerDynamicClass(NodeImpl.class, NodePropertyHandler.class); // ElementHandler rootHandler = // ((DocumentHandler) handlers.firstElement()).getDocumentElementHandler(); Node root = ((DocumentHandler) handlers.firstElement()).getParseNode(); JXPathContext jxpContext = JXPathContextFactory.newInstance().newContext(null, root); jxpContext.setLenient(true); Iterator itr = jxpContext.iterate(xpath); while (itr.hasNext()) { Object obj = itr.next(); if (handler.getParseNode().equals(obj)) { return true; } } return false; } }
/** * Creates and registers a JXPathBeanInfo object for the supplied class. If * the class has already been registered, returns the registered * JXPathBeanInfo object. * <p> * The process of creation of JXPathBeanInfo is as follows: * <ul> * <li>If class named <code><beanClass>XBeanInfo</code> exists, * an instance of that class is allocated. * <li>Otherwise, an instance of {@link JXPathBasicBeanInfo * JXPathBasicBeanInfo} is allocated. * </ul> * @param beanClass whose info to get * @return JXPathBeanInfo */ public static JXPathBeanInfo getBeanInfo(Class beanClass) { JXPathBeanInfo beanInfo = (JXPathBeanInfo) byClass.get(beanClass); if (beanInfo == null) { beanInfo = findDynamicBeanInfo(beanClass); if (beanInfo == null) { beanInfo = findInformant(beanClass); if (beanInfo == null) { beanInfo = new JXPathBasicBeanInfo(beanClass); } } byClass.put(beanClass, beanInfo); } return beanInfo; }
/** * find a JXPathBeanInfo instance for the specified class. * Similar to javax.beans property handler discovery; search for a * class with "XBeanInfo" appended to beanClass.name, then check * whether beanClass implements JXPathBeanInfo for itself. * Invokes the default constructor for any class it finds. * @param beanClass for which to look for an info provider * @return JXPathBeanInfo instance or null if none found */ private static synchronized JXPathBeanInfo findInformant(Class beanClass) { String name = beanClass.getName() + "XBeanInfo"; try { return (JXPathBeanInfo) instantiate(beanClass, name); } catch (Exception ex) { //NOPMD // Just drop through } // Now try checking if the bean is its own JXPathBeanInfo. try { if (JXPathBeanInfo.class.isAssignableFrom(beanClass)) { return (JXPathBeanInfo) beanClass.newInstance(); } } catch (Exception ex) { //NOPMD // Just drop through } return null; }
if (interfaces != null) { for (int i = 0; i < interfaces.length; i++) { beanInfo = findDynamicBeanInfo(interfaces[i]); if (beanInfo != null && beanInfo.isDynamic()) { return beanInfo; return beanInfo; return findDynamicBeanInfo(sup);
/** * ノードポインタを生成する。 * @param name QName * @param bean ターゲットとなるBean * @param locale ロケール * @return Beanポインタ */ @Override public NodePointer createNodePointer( QName name, Object bean, Locale locale) { JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass()); return new BeanPointerEx(name, bean, bi, locale); }
protected boolean stream(ElementHandler handler) { //create an xpath context from the root element // TODO: cache the context, should work just the same // JXPathIntrospector.registerDynamicClass(ElementHandlerImpl.class, // ElementHandlerPropertyHandler.class); JXPathIntrospector.registerDynamicClass(NodeImpl.class, NodePropertyHandler.class); // ElementHandler rootHandler = // ((DocumentHandler) handlers.firstElement()).getDocumentElementHandler(); Node root = ((DocumentHandler) handlers.firstElement()).getParseNode(); JXPathContext jxpContext = JXPathContextFactory.newInstance().newContext(null, root); jxpContext.setLenient(true); Iterator itr = jxpContext.iterate(xpath); for (; itr.hasNext();) { Object obj = itr.next(); if (handler.getParseNode().equals(obj)) { return true; } } return false; } }
public boolean isLeaf() { Object value = getNode(); return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic(); }
protected boolean stream(ElementHandler handler) { //create an xpath context from the root element // TODO: cache the context, should work just the same // JXPathIntrospector.registerDynamicClass(ElementHandlerImpl.class, // ElementHandlerPropertyHandler.class); JXPathIntrospector.registerDynamicClass(NodeImpl.class, NodePropertyHandler.class); // ElementHandler rootHandler = // ((DocumentHandler) handlers.firstElement()).getDocumentElementHandler(); Node root = ((DocumentHandler) handlers.firstElement()).getParseNode(); JXPathContext jxpContext = JXPathContextFactory.newInstance().newContext(null, root); jxpContext.setLenient(true); Iterator itr = jxpContext.iterate(xpath); for (; itr.hasNext();) { Object obj = itr.next(); if (handler.getParseNode().equals(obj)) { return true; } } return false; } }
public boolean isLeaf() { Object value = getNode(); return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic(); }
protected boolean stream(ElementHandler handler) { //create an xpath context from the root element // TODO: cache the context, should work just the same // JXPathIntrospector.registerDynamicClass(ElementHandlerImpl.class, // ElementHandlerPropertyHandler.class); JXPathIntrospector.registerDynamicClass( NodeImpl.class, NodePropertyHandler.class ); // ElementHandler rootHandler = // ((DocumentHandler) handlers.firstElement()).getDocumentElementHandler(); Node root = ((DocumentHandler)handlers.firstElement()).getParseNode(); JXPathContext jxpContext = JXPathContextFactory.newInstance().newContext(null,root); jxpContext.setLenient(true); Iterator itr = jxpContext.iterate(xpath); for (; itr.hasNext();) { Object obj = itr.next(); if (handler.getParseNode().equals(obj)) { return true; } } return false; }
@Override public boolean isLeaf() { Object value = getNode(); return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic(); }
public void initialize() throws Exception { if (enableDebugger) { if (getLogger().isDebugEnabled()) { getLogger().debug("Flow debugger enabled, creating"); } getDebugger().doBreak(); } Context context = Context.enter(); context.setOptimizationLevel(OPTIMIZATION_LEVEL); context.setCompileFunctionsWithDynamicScope(true); context.setGeneratingDebug(true); // add support for Rhino objects to JXPath JXPathIntrospector.registerDynamicClass(Scriptable.class, ScriptablePropertyHandler.class); JXPathContextReferenceImpl.addNodePointerFactory(new ScriptablePointerFactory()); try { scope = new Global(context); // Access to Cocoon internal objects FOM_Cocoon.init(scope); } catch (Exception e) { Context.exit(); throw e; } }
@Override public boolean isLeaf() { Object value = getNode(); return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic(); }
@Override public boolean isLeaf() { Object value = getNode(); return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic(); }
@Override public boolean isLeaf() { Object value = getNode(); return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic(); }
public boolean isLeaf() { Object value = getNode(); return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic(); }
public NodePointer createNodePointer(NodePointer parent, QName name, Object bean) { if (bean == null) { return new NullPointer(parent, name); } JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass()); return new BeanPointer(parent, name, bean, bi); } }
public static Iterator getAttributeNames(JXPathHelperConfiguration setup, Object contextObj) throws ConfigurationException { if (contextObj == null) { return null; } try { JXPathBeanInfo info = JXPathIntrospector.getBeanInfo(contextObj.getClass()); java.beans.PropertyDescriptor[] properties = info.getPropertyDescriptors(); List names = new LinkedList(); for (int i = 0; i < properties.length; i++) { names.add(properties[i].getName()); } return names.listIterator(); } catch (Exception e) { throw new ConfigurationException("Error retrieving attribute names for class: " + contextObj.getClass(), e); } } }
public boolean isLeaf() { Object value = getNode(); return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic(); }