protected final BeanProperty getBeanProperty()

in core/src/main/java/flex/messaging/io/BeanProxy.java [475:530]


    protected final BeanProperty getBeanProperty(Object instance, String propertyName) {
        Class c = instance.getClass();
        Map props;

        // It is faster to use the BeanProperty cache if we are going to cache it.
        if (descriptor == null && cacheProperties) {
            props = getBeanProperties(instance);
            return props == null ? null : (BeanProperty) props.get(propertyName);
        }

        // Otherwise, just build up the property we are asked for
        PropertyDescriptorCacheEntry pce = getPropertyDescriptorCacheEntry(c);
        if (pce == null)
            return null;

        Object pType = pce.propertiesByName.get(propertyName);
        if (pType == null)
            return null;

        List excludes = null;
        if (descriptor != null) {
            excludes = descriptor.getExcludesForInstance(instance);
            if (excludes == null) // For compatibility with older implementations
                excludes = descriptor.getExcludes();
        }

        if (pType instanceof PropertyDescriptor) {
            PropertyDescriptor pd = (PropertyDescriptor) pType;

            Method readMethod = pd.getReadMethod();
            Method writeMethod = pd.getWriteMethod();

            // If there's a public read method but no writeMethod and includeReadOnly
            // flag is off, then skip the property.
            if (readMethod != null && isPublicAccessor(readMethod.getModifiers()) && !getIncludeReadOnly() && writeMethod == null)
                return null;

            // Skip excluded and ignored properties as well.
            if ((excludes != null && excludes.contains(propertyName)) || isPropertyIgnored(c, propertyName))
                return null;

            return new BeanProperty(propertyName, pd.getPropertyType(), readMethod, writeMethod, null);
        } else if (pType instanceof Field) {
            Field field = (Field) pType;

            String pName = field.getName();
            int modifiers = field.getModifiers();
            if (isPublicField(modifiers) && pName.equals(propertyName)) {
                // Skip excluded and ignored properties.
                return ((excludes != null && excludes.contains(propertyName)) || isPropertyIgnored(c, propertyName)) ?
                        null : new BeanProperty(propertyName, field.getType(), null, null, field);
            }
        }

        return null;
    }