Java Code Examples for java.beans.IndexedPropertyDescriptor#getIndexedWriteMethod()

The following examples show how to use java.beans.IndexedPropertyDescriptor#getIndexedWriteMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Test4634390.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),
                    ipd.getReadMethod(),
                    ipd.getWriteMethod(),
                    ipd.getIndexedReadMethod(),
                    ipd.getIndexedWriteMethod());
        } else {
            return new PropertyDescriptor(
                    pd.getName(),
                    pd.getReadMethod(),
                    pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printStackTrace();
        return null;
    }
}
 
Example 2
Source File: Test4634390.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),
                    ipd.getReadMethod(),
                    ipd.getWriteMethod(),
                    ipd.getIndexedReadMethod(),
                    ipd.getIndexedWriteMethod());
        } else {
            return new PropertyDescriptor(
                    pd.getName(),
                    pd.getReadMethod(),
                    pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printStackTrace();
        return null;
    }
}
 
Example 3
Source File: Test4634390.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),
                    ipd.getReadMethod(),
                    ipd.getWriteMethod(),
                    ipd.getIndexedReadMethod(),
                    ipd.getIndexedWriteMethod());
        } else {
            return new PropertyDescriptor(
                    pd.getName(),
                    pd.getReadMethod(),
                    pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printStackTrace();
        return null;
    }
}
 
Example 4
Source File: Test4634390.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),
                    ipd.getReadMethod(),
                    ipd.getWriteMethod(),
                    ipd.getIndexedReadMethod(),
                    ipd.getIndexedWriteMethod());
        } else {
            return new PropertyDescriptor(
                    pd.getName(),
                    pd.getReadMethod(),
                    pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printStackTrace();
        return null;
    }
}
 
Example 5
Source File: Test4634390.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),
                    ipd.getReadMethod(),
                    ipd.getWriteMethod(),
                    ipd.getIndexedReadMethod(),
                    ipd.getIndexedWriteMethod());
        } else {
            return new PropertyDescriptor(
                    pd.getName(),
                    pd.getReadMethod(),
                    pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printStackTrace();
        return null;
    }
}
 
Example 6
Source File: Test4634390.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),
                    ipd.getReadMethod(),
                    ipd.getWriteMethod(),
                    ipd.getIndexedReadMethod(),
                    ipd.getIndexedWriteMethod());
        } else {
            return new PropertyDescriptor(
                    pd.getName(),
                    pd.getReadMethod(),
                    pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printStackTrace();
        return null;
    }
}
 
Example 7
Source File: Test4619536.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static boolean hasIPD(IndexedPropertyDescriptor ipd) {
    if (null == ipd.getIndexedPropertyType()) {
        return false;
    }
    return (null != ipd.getIndexedReadMethod())
        || (null != ipd.getIndexedWriteMethod());
}
 
Example 8
Source File: Test4619536.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean hasIPD(IndexedPropertyDescriptor ipd) {
    if (null == ipd.getIndexedPropertyType()) {
        return false;
    }
    return (null != ipd.getIndexedReadMethod())
        || (null != ipd.getIndexedWriteMethod());
}
 
Example 9
Source File: Test4918902.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testIndexedPropertyDescriptor(Class type, Class read, Class write) {
    IndexedPropertyDescriptor ipd = BeanUtils.getIndexedPropertyDescriptor(type, "foo");
    if (!read.equals(ipd.getIndexedReadMethod().getDeclaringClass())) {
        throw new Error("unexpected read method: " + ipd.getIndexedReadMethod());
    }
    if (!write.equals(ipd.getIndexedWriteMethod().getDeclaringClass())) {
        throw new Error("unexpected write method: " + ipd.getIndexedWriteMethod());
    }
}
 
Example 10
Source File: Test4918902.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void testIndexedPropertyDescriptor(Class type, Class read, Class write) {
    IndexedPropertyDescriptor ipd = BeanUtils.getIndexedPropertyDescriptor(type, "foo");
    if (!read.equals(ipd.getIndexedReadMethod().getDeclaringClass())) {
        throw new Error("unexpected read method: " + ipd.getIndexedReadMethod());
    }
    if (!write.equals(ipd.getIndexedWriteMethod().getDeclaringClass())) {
        throw new Error("unexpected write method: " + ipd.getIndexedWriteMethod());
    }
}
 
Example 11
Source File: Test4619536.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static boolean hasIPD(IndexedPropertyDescriptor ipd) {
    if (null == ipd.getIndexedPropertyType()) {
        return false;
    }
    return (null != ipd.getIndexedReadMethod())
        || (null != ipd.getIndexedWriteMethod());
}
 
Example 12
Source File: Test4918902.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void testIndexedPropertyDescriptor(Class type, Class read, Class write) {
    IndexedPropertyDescriptor ipd = BeanUtils.getIndexedPropertyDescriptor(type, "foo");
    if (!read.equals(ipd.getIndexedReadMethod().getDeclaringClass())) {
        throw new Error("unexpected read method: " + ipd.getIndexedReadMethod());
    }
    if (!write.equals(ipd.getIndexedWriteMethod().getDeclaringClass())) {
        throw new Error("unexpected write method: " + ipd.getIndexedWriteMethod());
    }
}
 
Example 13
Source File: Test4918902.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void testIndexedPropertyDescriptor(Class type, Class read, Class write) {
    IndexedPropertyDescriptor ipd = BeanUtils.getIndexedPropertyDescriptor(type, "foo");
    if (!read.equals(ipd.getIndexedReadMethod().getDeclaringClass())) {
        throw new Error("unexpected read method: " + ipd.getIndexedReadMethod());
    }
    if (!write.equals(ipd.getIndexedWriteMethod().getDeclaringClass())) {
        throw new Error("unexpected write method: " + ipd.getIndexedWriteMethod());
    }
}
 
Example 14
Source File: Test4918902.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void testIndexedPropertyDescriptor(Class type, Class read, Class write) {
    IndexedPropertyDescriptor ipd = BeanUtils.getIndexedPropertyDescriptor(type, "foo");
    if (!read.equals(ipd.getIndexedReadMethod().getDeclaringClass())) {
        throw new Error("unexpected read method: " + ipd.getIndexedReadMethod());
    }
    if (!write.equals(ipd.getIndexedWriteMethod().getDeclaringClass())) {
        throw new Error("unexpected write method: " + ipd.getIndexedWriteMethod());
    }
}
 
Example 15
Source File: Test4918902.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testIndexedPropertyDescriptor(Class type, Class read, Class write) {
    IndexedPropertyDescriptor ipd = BeanUtils.getIndexedPropertyDescriptor(type, "foo");
    if (!read.equals(ipd.getIndexedReadMethod().getDeclaringClass())) {
        throw new Error("unexpected read method: " + ipd.getIndexedReadMethod());
    }
    if (!write.equals(ipd.getIndexedWriteMethod().getDeclaringClass())) {
        throw new Error("unexpected write method: " + ipd.getIndexedWriteMethod());
    }
}
 
Example 16
Source File: Test4918902.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testIndexedPropertyDescriptor(Class type, Class read, Class write) {
    IndexedPropertyDescriptor ipd = BeanUtils.getIndexedPropertyDescriptor(type, "foo");
    if (!read.equals(ipd.getIndexedReadMethod().getDeclaringClass())) {
        throw new Error("unexpected read method: " + ipd.getIndexedReadMethod());
    }
    if (!write.equals(ipd.getIndexedWriteMethod().getDeclaringClass())) {
        throw new Error("unexpected write method: " + ipd.getIndexedWriteMethod());
    }
}
 
Example 17
Source File: ValueUtils.java    From commons-jxpath with Apache License 2.0 5 votes vote down vote up
/**
 * Modifies the index'th element of the bean's property represented by
 * the supplied property descriptor. Converts the value to the required
 * type if necessary.
 * @param bean to edit
 * @param propertyDescriptor indicating what to set
 * @param index int
 * @param value to set
 */
public static void setValue(Object bean,
        PropertyDescriptor propertyDescriptor, int index, Object value) {
    if (propertyDescriptor instanceof IndexedPropertyDescriptor) {
        try {
            IndexedPropertyDescriptor ipd =
                (IndexedPropertyDescriptor) propertyDescriptor;
            Method method = ipd.getIndexedWriteMethod();
            if (method != null) {
                method.invoke(
                    bean,
                        new Integer(index),
                        convert(value, ipd.getIndexedPropertyType()));
                return;
            }
        }
        catch (Exception ex) {
            throw new RuntimeException(
                "Cannot access property: "
                    + propertyDescriptor.getName()
                    + ", "
                    + ex.getMessage());
        }
    }
    // We will fall through if there is no indexed read
    Object collection = getValue(bean, propertyDescriptor);
    if (isCollection(collection)) {
        setValue(collection, index, value);
    }
    else if (index == 0) {
        setValue(bean, propertyDescriptor, value);
    }
    else {
        throw new RuntimeException(
            "Not a collection: " + propertyDescriptor.getName());
    }
}
 
Example 18
Source File: ExtendedBeanInfo.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public SimpleIndexedPropertyDescriptor(IndexedPropertyDescriptor original) throws IntrospectionException {
	this(original.getName(), original.getReadMethod(), original.getWriteMethod(),
			original.getIndexedReadMethod(), original.getIndexedWriteMethod());
	PropertyDescriptorUtils.copyNonMethodProperties(original, this);
}
 
Example 19
Source File: ExtendedBeanInfo.java    From java-technology-stack with MIT License 4 votes vote down vote up
public SimpleIndexedPropertyDescriptor(IndexedPropertyDescriptor original) throws IntrospectionException {
	this(original.getName(), original.getReadMethod(), original.getWriteMethod(),
			original.getIndexedReadMethod(), original.getIndexedWriteMethod());
	PropertyDescriptorUtils.copyNonMethodProperties(original, this);
}
 
Example 20
Source File: ExtendedBeanInfo.java    From blog_demos with Apache License 2.0 4 votes vote down vote up
public SimpleIndexedPropertyDescriptor(IndexedPropertyDescriptor original) throws IntrospectionException {
	this(original.getName(), original.getReadMethod(), original.getWriteMethod(),
			original.getIndexedReadMethod(), original.getIndexedWriteMethod());
	copyNonMethodProperties(original, this);
}