Package java.beans

Examples of java.beans.IntrospectionException


        if (descriptor != null) {
            Method reader = descriptor.getReadMethod();

            if (reader == null) {
                throw new IntrospectionException("Unreadable property '"
                        + pathSegment
                        + "'");
            }

            return reader.invoke(object, (Object[]) null);
        }
        // note that Map has two traditional bean properties - 'empty' and 'class', so
        // do a check here only after descriptor lookup failed.
        else if (object instanceof Map) {
            return ((Map<?, ?>) object).get(pathSegment);
        }
        else {
            throw new IntrospectionException("No property '"
                    + pathSegment
                    + "' found in class "
                    + object.getClass().getName());
        }
    }
View Full Code Here


        if (descriptor != null) {
            Method writer = descriptor.getWriteMethod();

            if (writer == null) {
                throw new IntrospectionException("Unwritable property '"
                        + pathSegment
                        + "'");
            }

            // do basic conversions

            value = ConverterFactory.factory
                    .getConverter(descriptor.getPropertyType())
                    .convert(value, descriptor.getPropertyType());

            // set
            writer.invoke(object, value);
        }
        // note that Map has two traditional bean properties - 'empty' and 'class', so
        // do a check here only after descriptor lookup failed.
        else if (object instanceof Map) {
            ((Map<Object, Object>) object).put(pathSegment, value);
        }
        else {
            throw new IntrospectionException("No property '"
                    + pathSegment
                    + "' found in class "
                    + object.getClass().getName());
        }
    }
View Full Code Here

        PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            if (propertyName.equals(descriptors[i].getName()))
                return descriptors[i];
        }
        throw new IntrospectionException(
            "Property '" + propertyName + "' not found in bean " + bean);
    }
View Full Code Here

    Class<?> propertyType = null;

    if (readMethod != null) {
      Class<?>[] params = readMethod.getParameterTypes();
      if (params.length != 0) {
        throw new IntrospectionException("bad read method arg count: " + readMethod);
      }
      propertyType = readMethod.getReturnType();
      if (propertyType == Void.TYPE) {
        throw new IntrospectionException("read method "
            + readMethod.getName() + " returns void");
      }
    }
    if (writeMethod != null) {
      Class<?> params[] = writeMethod.getParameterTypes();
      if (params.length != 1) {
        throw new IntrospectionException("bad write method arg count: " + writeMethod);
      }
      if (propertyType != null
          && !params[0].isAssignableFrom(propertyType)) {
        throw new IntrospectionException("type mismatch between read and write methods");
      }
      propertyType = params[0];
    }
    return propertyType;
  }
View Full Code Here

    Class<?> indexedPropertyType = null;

    if (indexedReadMethod != null) {
      Class<?> params[] = indexedReadMethod.getParameterTypes();
      if (params.length != 1) {
        throw new IntrospectionException(
            "bad indexed read method arg count");
      }
      if (params[0] != Integer.TYPE) {
        throw new IntrospectionException(
            "non int index to indexed read method");
      }
      indexedPropertyType = indexedReadMethod.getReturnType();
      if (indexedPropertyType == Void.TYPE) {
        throw new IntrospectionException(
            "indexed read method returns void");
      }
    }
    if (indexedWriteMethod != null) {
      Class<?> params[] = indexedWriteMethod.getParameterTypes();
      if (params.length != 2) {
        throw new IntrospectionException(
            "bad indexed write method arg count");
      }
      if (params[0] != Integer.TYPE) {
        throw new IntrospectionException(
            "non int index to indexed write method");
      }
      if (indexedPropertyType != null && indexedPropertyType != params[1]) {
        throw new IntrospectionException(
            "type mismatch between indexed read and indexed write methods: " + name);
      }
      indexedPropertyType = params[1];
    }
    if (propertyType != null
        && (!propertyType.isArray() ||
            propertyType.getComponentType() != indexedPropertyType)) {
      throw new IntrospectionException(
          "type mismatch between indexed and non-indexed methods: " + name);
    }
    return indexedPropertyType;
  }
View Full Code Here

        PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            if (propertyName.equals(descriptors[i].getName()))
                return descriptors[i];
        }
        throw new IntrospectionException(
            "Property '" + propertyName + "' not found in bean " + bean);
    }
View Full Code Here

        PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            if (propertyName.equals(descriptors[i].getName()))
                return descriptors[i];
        }
        throw new IntrospectionException(
            "Property '" + propertyName + "' not found in bean " + bean);
    }
View Full Code Here

        if (descriptor != null) {
            Method reader = descriptor.getReadMethod();

            if (reader == null) {
                throw new IntrospectionException("Unreadable property '"
                        + pathSegment
                        + "'");
            }

            return reader.invoke(object, (Object[]) null);
        }
        // note that Map has two traditional bean properties - 'empty' and 'class', so
        // do a check here only after descriptor lookup failed.
        else if (object instanceof Map) {
            return ((Map<?, ?>) object).get(pathSegment);
        }
        else {
            throw new IntrospectionException("No property '"
                    + pathSegment
                    + "' found in class "
                    + object.getClass().getName());
        }
    }
View Full Code Here

        if (descriptor != null) {
            Method writer = descriptor.getWriteMethod();

            if (writer == null) {
                throw new IntrospectionException("Unwritable property '"
                        + pathSegment
                        + "'");
            }

            // do basic conversions

            value = ConverterFactory.factory
                    .getConverter(descriptor.getPropertyType())
                    .convert(value, descriptor.getPropertyType());

            // set
            writer.invoke(object, value);
        }
        // note that Map has two traditional bean properties - 'empty' and 'class', so
        // do a check here only after descriptor lookup failed.
        else if (object instanceof Map) {
            ((Map<Object, Object>) object).put(pathSegment, value);
        }
        else {
            throw new IntrospectionException("No property '"
                    + pathSegment
                    + "' found in class "
                    + object.getClass().getName());
        }
    }
View Full Code Here

        }
        if (m == null) {
            String msg = String.format("Accessor '%s' not found, "
                                       + "known setters are: %s, known getters are: %s", getterOrSetterName,
                                       setters.keySet(), getters.keySet());
            throw new IntrospectionException(msg);
        }
        return m.getReturnType();
    }
View Full Code Here

TOP

Related Classes of java.beans.IntrospectionException

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.