Examples of ObjectAccessException


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

            }

            if (bestMatchingCtor == null) {
                if (possibleCtor == null) {
                    usedDeps = 0;
                    throw new ObjectAccessException("Cannot construct "
                            + type.getName()
                            + ", none of the dependencies match any constructor's parameters");
                } else {
                    bestMatchingCtor = possibleCtor;
                    matchingDependencies.clear();
                    matchingDependencies.addAll(possibleMatchingDependencies);
                    usedDeps = possibleUsedDeps;
                }
            }
        }

        try {
            final T instance;
            if (bestMatchingCtor == null) {
                instance = type.newInstance();
            } else {
                @SuppressWarnings("unchecked")
                final T obj = (T)bestMatchingCtor.newInstance(matchingDependencies.toArray());
                instance = obj;
            }
            if (usedDependencies != null) {
                usedDependencies.clear();
                int i = 0;
                for(long l = 1; l < usedDeps; l <<= 1, ++i) {
                    if ((usedDeps & l) > 0) {
                        usedDependencies.set(i);
                    }
                }
            }

            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);
        } 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

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

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

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

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

        if (visitor.shouldVisit(name, definedIn)) {
          Object value = readMethod.invoke(object);
          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

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

  public void writeProperty(Object object, String propertyName, Object value) {
    PropertyDescriptor property = getProperty(propertyName, object.getClass());
    try {
      property.getWriteMethod().invoke(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

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

    BeanInfo beanInfo;
    try {
      beanInfo = Introspector.getBeanInfo(type, Object.class);
    } catch (IntrospectionException e) {
      throw new ObjectAccessException("Cannot get BeanInfo of type "
          + type.getName(), e);
    }

    for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) {
        nameMapBuilder.put(descriptor.getName(), descriptor);
View Full Code Here

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

        TextAttribute attribute = (TextAttribute)source;
        try {
            getName.setAccessible(true);
            return (String)getName.invoke(attribute, (Object[])null);
        } catch (IllegalAccessException e) {
            throw new ObjectAccessException("Cannot get name of TextAttribute", e);
        } catch (InvocationTargetException e) {
            throw new ObjectAccessException("Cannot get name of TextAttribute", e.getTargetException());
        }
    }
View Full Code Here

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

        instanceMap.setAccessible(true);
        Map map;
        try {
            map = (Map)instanceMap.get(null);
        } catch (IllegalAccessException e) {
            throw new ObjectAccessException("Cannot get named instance of TextAttribute " + str);
        }
        return map.get(str);
    }
View Full Code Here

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

     */
    public BeanProperty property(Class cls, String name) {
        Map properties = buildMap(cls);
        BeanProperty property = (BeanProperty) properties.get(name);
        if (property == null) {
            throw new ObjectAccessException("No such property " + cls.getName() + "." + name);
        } else {
            return property;
        }
    }
View Full Code Here

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

    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

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

            BeanProperty property = (BeanProperty) iterator.next();
            try {
                Object value = property.get(object);
                visitor.visit(property.getName(), property.getType(), value);
            } catch (IllegalArgumentException e) {
                throw new ObjectAccessException("Could not get property " + property.getClass()
                        + "." + property.getName(), e);
            } catch (IllegalAccessException e) {
                throw new ObjectAccessException("Could not get property " + property.getClass()
                        + "." + property.getName(), e);
            }
        }
    }
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.