Package com.thoughtworks.xstream.converters.reflection

Examples of com.thoughtworks.xstream.converters.reflection.ObjectAccessException


            }
            Collection collection = (Collection) implicitCollections.get(fieldName);
            if (collection == null) {
                Class fieldType = mapper.defaultImplementationOf(reflectionProvider.getFieldType(result, fieldName, null));
                if (!Collection.class.isAssignableFrom(fieldType)) {
                    throw new ObjectAccessException("Field " + fieldName + " of " + result.getClass().getName() +
                            " is configured for an implicit Collection, but field is of type " + fieldType.getName());
                }
                if (pureJavaReflectionProvider == null) {
                    pureJavaReflectionProvider = new PureJavaReflectionProvider();
                }
View Full Code Here


        if (nameMap == null) {
            BeanInfo beanInfo;
            try {
                beanInfo = Introspector.getBeanInfo(type, Object.class);
            } catch (final IntrospectionException e) {
                throw new ObjectAccessException("Cannot get BeanInfo of type " + type.getName(), e);
            }
            nameMap = new LinkedHashMap<String, PropertyDescriptor>();
            final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
            for (final PropertyDescriptor descriptor : propertyDescriptors) {
                nameMap.put(descriptor.getName(), descriptor);
View Full Code Here

    @Override
    public Object newInstance(final Class<?> type) {
        try {
            return type.newInstance();
        } catch (final InstantiationException e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e);
        } catch (final IllegalAccessException e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e);
        } catch (final SecurityException e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e);
        } catch (final ExceptionInInitializerError e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e);
        }
    }
View Full Code Here

                if (visitor.shouldVisit(name, definedIn)) {
                    final Object value = readMethod.invoke(object);
                    visitor.visit(name, property.getPropertyType(), definedIn, value);
                }
            } catch (final IllegalArgumentException e) {
                throw new ObjectAccessException("Could not get property "
                    + object.getClass()
                    + "."
                    + property.getName(), e);
            } catch (final IllegalAccessException e) {
                throw new ObjectAccessException("Could not get property "
                    + object.getClass()
                    + "."
                    + property.getName(), e);
            } catch (final InvocationTargetException e) {
                throw new ObjectAccessException("Could not get property "
                    + object.getClass()
                    + "."
                    + property.getName(), e);
            }
        }
View Full Code Here

    public void writeProperty(final Object object, final String propertyName, final Object value) {
        final PropertyDescriptor property = getProperty(propertyName, object.getClass());
        try {
            property.getWriteMethod().invoke(object, new Object[]{value});
        } catch (final IllegalArgumentException e) {
            throw new ObjectAccessException("Could not set property " + object.getClass() + "." + property.getName(), e);
        } catch (final IllegalAccessException e) {
            throw new ObjectAccessException("Could not set property " + object.getClass() + "." + property.getName(), e);
        } catch (final InvocationTargetException e) {
            throw new ObjectAccessException("Could not set property " + object.getClass() + "." + property.getName(), e);
        }
    }
View Full Code Here

            } else {
                try {
                    final Method clone = o.getClass().getMethod("clone");
                    return (T)clone.invoke(o);
                } catch (final NoSuchMethodException e) {
                    throw new ObjectAccessException("Cloneable type has no clone method", e);
                } catch (final IllegalAccessException e) {
                    throw new ObjectAccessException("Cannot clone Cloneable type", e);
                } catch (final InvocationTargetException e) {
                    throw new ObjectAccessException("Exception cloning Cloneable type", e.getCause());
                }
            }
        }
        return null;
    }
View Full Code Here

        } catch (final NoSuchFieldException e) {
            final String message = "Could not access " + type.getName() + "." + name + " field: " + e.getMessage();
            throw new IllegalArgumentException(message);
        } catch (final NoClassDefFoundError e) {
            final String message = "Could not access " + type.getName() + "." + name + " field: " + e.getMessage();
            throw new ObjectAccessException(message);
        }
    }
View Full Code Here

    public static void write(final Field field, final Object instance, final Object value) {
        try {
            field.set(instance, value);
        } catch (final IllegalAccessException e) {
            final String message = "Could not write " + field.getType().getName() + "." + field.getName() + " field";
            throw new ObjectAccessException(message, e);
        } catch (final NoClassDefFoundError e) {
            final String message = "Could not write " + field.getType().getName() + "." + field.getName() + " field";
            throw new ObjectAccessException(message, e);
        }
    }
View Full Code Here

    public static Object read(final Field field, final Object instance) {
        try {
            return field.get(instance);
        } catch (final IllegalAccessException e) {
            final String message = "Could not read " + field.getType().getName() + "." + field.getName() + " field";
            throw new ObjectAccessException(message, e);
        } catch (final NoClassDefFoundError e) {
            final String message = "Could not read " + field.getType().getName() + "." + field.getName() + " field";
            throw new ObjectAccessException(message, e);
        }
    }
View Full Code Here

            @Override
            public PropertyEditor newInstance() {
                try {
                    return editorType.newInstance();
                } catch (final InstantiationException e) {
                    throw new ObjectAccessException("Could not call default constructor of " + editorType.getName(), e);
                } catch (final IllegalAccessException e) {
                    throw new ObjectAccessException("Could not call default constructor of " + editorType.getName(), e);
                }
            }

        });
    }
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.converters.reflection.ObjectAccessException

Copyright © 2018 www.massapicom. 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.