Examples of JXPathTypeConversionException


Examples of org.apache.commons.jxpath.JXPathTypeConversionException

        try {
            return TypeUtils.convert(value, type);
        }
        catch (Exception ex) {
            String string = value == null ? "null" : value.getClass().getName();
            throw new JXPathTypeConversionException(
                    "Cannot convert value of class " + string + " to type "
                            + type, ex);
        }
    }
View Full Code Here

Examples of org.apache.commons.jxpath.JXPathTypeConversionException

     */
    public Object getValue(String xpath, Expression expr, Class requiredType) {
        Object value = getValue(xpath, expr);
        if (value != null && requiredType != null) {
            if (!TypeUtils.canConvert(value, requiredType)) {
                throw new JXPathTypeConversionException(
                    "Invalid expression type. '"
                        + xpath
                        + "' returns "
                        + value.getClass().getName()
                        + ". It cannot be converted to "
View Full Code Here

Examples of org.apache.commons.jxpath.JXPathTypeConversionException

                try {
                    return useType.getConstructor(new Class[] { boolean.class })
                            .newInstance(new Object[] { object });
                }
                catch (Exception e) {
                    throw new JXPathTypeConversionException(useType.getName(), e);
                }
            }
        }
        if (object instanceof Number) {
            double value = ((Number) object).doubleValue();
            if (useType == Boolean.class) {
                return value == 0.0 ? Boolean.FALSE : Boolean.TRUE;
            }
            if (Number.class.isAssignableFrom(useType)) {
                return allocateNumber(useType, value);
            }
        }
        if (object instanceof String) {
            Object value = convertStringToPrimitive(object, useType);
            if (value != null) {
                return value;
            }
        }

        Converter converter = ConvertUtils.lookup(useType);
        if (converter != null) {
            return converter.convert(useType, object);
        }

        throw new JXPathTypeConversionException("Cannot convert "
                + object.getClass() + " to " + useType);
    }
View Full Code Here

Examples of org.apache.commons.jxpath.JXPathTypeConversionException

                        .newInstance(
                                new Object[] { allocateNumber(initialValueType,
                                        value) });
            }
            catch (Exception e) {
                throw new JXPathTypeConversionException(classname, e);
            }
        }
        return null;
    }
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.