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

The following examples show how to use java.beans.IndexedPropertyDescriptor#getIndexedReadMethod() . 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 jdk8u_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: ValueUtils.java    From commons-jxpath with Apache License 2.0 6 votes vote down vote up
/**
 * If there is a regular non-indexed read method for this property,
 * uses this method to obtain the collection and then returns its
 * length.
 * Otherwise, attempts to guess the length of the collection by
 * calling the indexed get method repeatedly.  The method is supposed
 * to throw an exception if the index is out of bounds.
 * @param object collection
 * @param pd IndexedPropertyDescriptor
 * @return int
 */
public static int getIndexedPropertyLength(Object object,
        IndexedPropertyDescriptor pd) {
    if (pd.getReadMethod() != null) {
        return getLength(getValue(object, pd));
    }

    Method readMethod = pd.getIndexedReadMethod();
    if (readMethod == null) {
        throw new JXPathException(
            "No indexed read method for property " + pd.getName());
    }

    for (int i = 0; i < UNKNOWN_LENGTH_MAX_COUNT; i++) {
        try {
            readMethod.invoke(object, new Integer(i));
        }
        catch (Throwable t) {
            return i;
        }
    }

    throw new JXPathException(
        "Cannot determine the length of the indexed property "
            + pd.getName());
}
 
Example 3
Source File: Test4634390.java    From openjdk-jdk8u-backup 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 jdk8u60 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 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 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 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 8
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 9
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 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-jdk8u 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-jdk8u 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 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 14
Source File: Test4619536.java    From jdk8u-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 15
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 16
Source File: ExtendedBeanInfo.java    From spring-analysis-note 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 17
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 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 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);
}
 
Example 20
Source File: ExtendedBeanInfo.java    From spring4-understanding 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());
	PropertyDescriptorUtils.copyNonMethodProperties(original, this);
}