Package com.thoughtworks.xstream.converters.reflection

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


    public void writeProperty(Object object, String propertyName, Object value) {
        BeanProperty property = propertyDictionary.property(object.getClass(), propertyName);
        try {
            property.set(object, value);
        } catch (IllegalArgumentException e) {
            throw new ObjectAccessException("Could not set property " + object.getClass() + "."
                    + property.getName(), e);
        } catch (IllegalAccessException e) {
            throw new ObjectAccessException("Could not set property " + object.getClass() + "."
                    + property.getName(), e);
        }
    }
View Full Code Here


            if (bestMatchingCtor == null) {
                if (possibleCtor == null) {
                    for (int j = usedDependencies.length(); j-- > 0;) {
                        usedDependencies.clear(j); // JDK 1.3, BitSet.clear() is JDK 1.4
                    }
                    throw new ObjectAccessException("Cannot construct "
                        + type.getName()
                        + ", none of the dependencies match any constructor's parameters");
                } else {
                    bestMatchingCtor = possibleCtor;
                }
            }
        }

        try {
            final Object instance;
            if (bestMatchingCtor == null) {
                instance = type.newInstance();
            } else {
                instance = bestMatchingCtor.newInstance(matchingDependencies.toArray());
            }
            return instance;
        } 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 InvocationTargetException e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e);
        }
    }
View Full Code Here

            XmlFriendlyNameCoder coder = (XmlFriendlyNameCoder)super.clone();
            coder.readResolve();
            return coder;

        } catch (CloneNotSupportedException e) {
            throw new ObjectAccessException("Cannot clone XmlFriendlyNameCoder", e);
        }
    }
View Full Code Here

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

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

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

                converter = new SingleValueConverterWrapper(svc);
            } else {
                converter = (Converter)type.getConstructor().newInstance();
            }
        } catch (InvocationTargetException e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e
                .getCause());
        } catch (InstantiationException e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e);
        } catch (IllegalAccessException e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e);
        } catch (NoSuchMethodException e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e);
        }
        return converter;
    }
View Full Code Here

    public Object newInstance(Class type) {
        try {
            return getDefaultConstrutor(type).newInstance(NO_PARAMS);
        } catch (InstantiationException e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e);
        } catch (IllegalAccessException e) {
            throw new ObjectAccessException("Cannot construct " + type.getName(), e);
        } catch (InvocationTargetException e) {
            if (e.getTargetException() instanceof RuntimeException) {
                throw (RuntimeException)e.getTargetException();
            } else if (e.getTargetException() instanceof Error) {
                throw (Error)e.getTargetException();
            } else {
                throw new ObjectAccessException("Constructor for "
                    + type.getName()
                    + " threw an exception", e);
            }
        }
    }
View Full Code Here

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

    public void writeProperty(Object object, String propertyName, Object value) {
        PropertyDescriptor property = getProperty(propertyName, object.getClass());
        try {
            property.getWriteMethod().invoke(object, new Object[]{value});
        } catch (IllegalArgumentException e) {
            throw new ObjectAccessException("Could not set property "
                + object.getClass()
                + "."
                + property.getName(), e);
        } catch (IllegalAccessException e) {
            throw new ObjectAccessException("Could not set property "
                + object.getClass()
                + "."
                + property.getName(), e);
        } catch (InvocationTargetException e) {
            throw new ObjectAccessException("Could not set property "
                + object.getClass()
                + "."
                + property.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.