Examples of DynamicPropertyHandler


Examples of org.apache.commons.jxpath.DynamicPropertyHandler

        Object bean,
        Locale locale)
    {
        JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
        if (bi.isDynamic()) {
            DynamicPropertyHandler handler =
                ValueUtils.getDynamicPropertyHandler(
                    bi.getDynamicPropertyHandlerClass());
            return new DynamicPointer(name, bean, handler, locale);
        }
        return null;
View Full Code Here

Examples of org.apache.commons.jxpath.DynamicPropertyHandler

            return new NullPointer(parent, name);
        }

        JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
        if (bi.isDynamic()) {
            DynamicPropertyHandler handler =
                ValueUtils.getDynamicPropertyHandler(
                    bi.getDynamicPropertyHandlerClass());
            return new DynamicPointer(parent, name, bean, handler);
        }
        return null;
View Full Code Here

Examples of org.apache.commons.jxpath.DynamicPropertyHandler

     * Returns a shared instance of the dynamic property handler class
     * returned by <code>getDynamicPropertyHandlerClass()</code>.
     */
    public static DynamicPropertyHandler getDynamicPropertyHandler(Class clazz)
    {
        DynamicPropertyHandler handler =
            (DynamicPropertyHandler) dynamicPropertyHandlerMap.get(clazz);
        if (handler == null) {
            try {
                handler = (DynamicPropertyHandler) clazz.newInstance();
            }
View Full Code Here

Examples of org.apache.commons.jxpath.DynamicPropertyHandler

            final WebContinuation kont =
                (WebContinuation) ((Environment) resolver).getAttribute("kont");
           
            // Hack? I use JXPath to determine the properties of the bean object
            final JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
            DynamicPropertyHandler h = null;
            final PropertyDescriptor[] props;
            if (bi.isDynamic()) {
                Class cl = bi.getDynamicPropertyHandlerClass();
                try {
                    h = (DynamicPropertyHandler) cl.newInstance();
                } catch (Exception exc) {
                    exc.printStackTrace();
                    h = null;
                }
                props = null;
            } else {
                h = null;
                props = bi.getPropertyDescriptors();
            }
            final DynamicPropertyHandler handler = h;
           
            this.velocityContext = new Context() {
                    public Object put(String key, Object value) {
                        if (key.equals("flowContext")
                            || key.equals("continuation")) {
                            return value;
                        }
                        if (handler != null) {
                            handler.setProperty(bean, key, value);
                            return value;
                        } else {
                            for (int i = 0; i < props.length; i++) {
                                if (props[i].getName().equals(key)) {
                                    try {
                                        return props[i].getWriteMethod().invoke(bean, new Object[]{value});
                                    } catch (Exception ignored) {
                                        break;
                                    }
                                }
                            }
                            return value;
                        }
                    }
                   
                    public boolean containsKey(Object key) {
                        if (key.equals("flowContext")
                            || key.equals("continuation")) {
                            return true;
                        }
                        if (handler != null) {
                            String[] result = handler.getPropertyNames(bean);
                            for (int i = 0; i < result.length; i++) {
                                if (key.equals(result[i])) {
                                    return true;
                                }
                            }
                        } else {
                            for (int i = 0; i < props.length; i++) {
                                if (key.equals(props[i].getName())) {
                                    return true;
                                }
                            }
                        }
                        return false;
                    }
                   
                    public Object[] getKeys() {
                        Object[] result = null;
                        if (handler != null) {
                            result = handler.getPropertyNames(bean);
                        } else {
                            result = new Object[props.length];
                            for (int i = 0; i < props.length; i++) {
                                result[i] = props[i].getName();
                            }
                        }
                        Set set = new HashSet();
                        for (int i = 0; i < result.length; i++) {
                            set.add(result[i]);
                        }
                        set.add("flowContext");
                        set.add("continuation");
                        result = new Object[set.size()];
                        set.toArray(result);
                        return result;
                    }
                   
                    public Object get(String key) {
                        if (key.equals("flowContext")) {
                            return bean;
                        }
                        if (key.equals("continuation")) {
                            return kont;
                        }
                        if (handler != null) {
                            return handler.getProperty(bean, key.toString());
                        } else {
                            for (int i = 0; i < props.length; i++) {
                                if (props[i].getName().equals(key)) {
                                    try {
                                        return props[i].getReadMethod().invoke(bean, null);
View Full Code Here

Examples of org.apache.commons.jxpath.DynamicPropertyHandler

        QName name,
        Object bean,
        Locale locale) {
        JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
        if (bi.isDynamic()) {
            DynamicPropertyHandler handler =
                ValueUtils.getDynamicPropertyHandler(
                    bi.getDynamicPropertyHandlerClass());
            return new DynamicPointer(name, bean, handler, locale);
        }
        return null;
View Full Code Here

Examples of org.apache.commons.jxpath.DynamicPropertyHandler

            return new NullPointer(parent, name);
        }

        JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
        if (bi.isDynamic()) {
            DynamicPropertyHandler handler =
                ValueUtils.getDynamicPropertyHandler(
                    bi.getDynamicPropertyHandlerClass());
            return new DynamicPointer(parent, name, bean, handler);
        }
        return null;
View Full Code Here

Examples of org.apache.commons.jxpath.DynamicPropertyHandler

     * returned by <code>getDynamicPropertyHandlerClass()</code>.
     * @param clazz to handle
     * @return DynamicPropertyHandler
     */
    public static DynamicPropertyHandler getDynamicPropertyHandler(Class clazz) {
        DynamicPropertyHandler handler =
            (DynamicPropertyHandler) dynamicPropertyHandlerMap.get(clazz);
        if (handler == null) {
            try {
                handler = (DynamicPropertyHandler) clazz.newInstance();
            }
View Full Code Here

Examples of org.apache.commons.jxpath.DynamicPropertyHandler

        final JXPathBeanInfo bi =
            JXPathIntrospector.getBeanInfo(contextObject.getClass());
        if (bi.isDynamic()) {
            Class cl = bi.getDynamicPropertyHandlerClass();
            try {
                DynamicPropertyHandler h =
                    (DynamicPropertyHandler) cl.newInstance();
                String[] result = h.getPropertyNames(contextObject);
                int len = result.length;
                for (int i = 0; i < len; i++) {
                    try {
                        map.put(result[i], h.getProperty(contextObject, result[i]));
                    } catch (Exception exc) {
                        exc.printStackTrace();
                    }
                }
            } catch (Exception ignored) {
View Full Code Here

Examples of org.apache.commons.jxpath.DynamicPropertyHandler

            final WebContinuation kont = FlowHelper.getWebContinuation(objectModel);

            // Hack? I use JXPath to determine the properties of the bean object
            final JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
            DynamicPropertyHandler h = null;
            final PropertyDescriptor[] props;
            if (bi.isDynamic()) {
                Class cl = bi.getDynamicPropertyHandlerClass();
                try {
                    h = (DynamicPropertyHandler) cl.newInstance();
                } catch (Exception exc) {
                    exc.printStackTrace();
                    h = null;
                }
                props = null;
            } else {
                h = null;
                props = bi.getPropertyDescriptors();
            }
            final DynamicPropertyHandler handler = h;
           
            this.velocityContext = new Context() {
                    public Object put(String key, Object value) {
                        if (key.equals("flowContext")
                            || key.equals("continuation")) {
                            return value;
                        }
                        if (handler != null) {
                            handler.setProperty(bean, key, value);
                            return value;
                        } else {
                            for (int i = 0; i < props.length; i++) {
                                if (props[i].getName().equals(key)) {
                                    try {
                                        return props[i].getWriteMethod().invoke(bean, new Object[]{value});
                                    } catch (Exception ignored) {
                                        break;
                                    }
                                }
                            }
                            return value;
                        }
                    }
                   
                    public boolean containsKey(Object key) {
                        if (key.equals("flowContext")
                            || key.equals("continuation")) {
                            return true;
                        }
                        if (handler != null) {
                            String[] result = handler.getPropertyNames(bean);
                            for (int i = 0; i < result.length; i++) {
                                if (key.equals(result[i])) {
                                    return true;
                                }
                            }
                        } else {
                            for (int i = 0; i < props.length; i++) {
                                if (key.equals(props[i].getName())) {
                                    return true;
                                }
                            }
                        }
                        return false;
                    }
                   
                    public Object[] getKeys() {
                        Object[] result = null;
                        if (handler != null) {
                            result = handler.getPropertyNames(bean);
                        } else {
                            result = new Object[props.length];
                            for (int i = 0; i < props.length; i++) {
                                result[i] = props[i].getName();
                            }
                        }
                        Set set = new HashSet();
                        for (int i = 0; i < result.length; i++) {
                            set.add(result[i]);
                        }
                        set.add("flowContext");
                        set.add("continuation");
                        result = new Object[set.size()];
                        set.toArray(result);
                        return result;
                    }
                   
                    public Object get(String key) {
                        if (key.equals("flowContext")) {
                            return bean;
                        }
                        if (key.equals("continuation")) {
                            return kont;
                        }
                        if (handler != null) {
                            return handler.getProperty(bean, key.toString());
                        } else {
                            for (int i = 0; i < props.length; i++) {
                                if (props[i].getName().equals(key)) {
                                    try {
                                        return props[i].getReadMethod().invoke(bean, null);
View Full Code Here

Examples of org.apache.commons.jxpath.DynamicPropertyHandler

            final JXPathBeanInfo bi =
                JXPathIntrospector.getBeanInfo(contextObject.getClass());
            if (bi.isDynamic()) {
                Class cl = bi.getDynamicPropertyHandlerClass();
                try {
                    DynamicPropertyHandler h =
                        (DynamicPropertyHandler) cl.newInstance();
                    String[] result = h.getPropertyNames(contextObject);
                    int len = result.length;
                    for (int i = 0; i < len; i++) {
                        try {
                            map.put(result[i], h.getProperty(contextObject, result[i]));
                        } catch (Exception exc) {
                            exc.printStackTrace();
                        }
                    }
                } catch (Exception ignored) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.