Example usage for org.springframework.beans PropertyAccessorUtils getFirstNestedPropertySeparatorIndex

List of usage examples for org.springframework.beans PropertyAccessorUtils getFirstNestedPropertySeparatorIndex

Introduction

In this page you can find the example usage for org.springframework.beans PropertyAccessorUtils getFirstNestedPropertySeparatorIndex.

Prototype

public static int getFirstNestedPropertySeparatorIndex(String propertyPath) 

Source Link

Document

Determine the first nested property separator in the given property path, ignoring dots in keys (like "map[my.key]").

Usage

From source file:org.kuali.rice.krad.web.bind.UifViewBeanWrapper.java

/**
 * Overridden to copy property editor registration to the new bean wrapper.
 *
 * {@inheritDoc}/* ww w .  j  a  v a2  s .com*/
 */
@Override
protected BeanWrapperImpl getBeanWrapperForPropertyPath(String propertyPath) {
    BeanWrapperImpl beanWrapper = super.getBeanWrapperForPropertyPath(propertyPath);

    PropertyTokenHolder tokens = getPropertyNameTokens(propertyPath);
    String canonicalName = tokens.canonicalName;

    int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(canonicalName);
    if (pos != -1) {
        canonicalName = canonicalName.substring(0, pos);
    }

    copyCustomEditorsTo(beanWrapper, canonicalName);

    return beanWrapper;
}

From source file:org.springframework.beans.AbstractNestablePropertyAccessor.java

/**
 * Recursively navigate to return a property accessor for the nested property path.
 * @param propertyPath property path, which may be nested
 * @return a property accessor for the target bean
 *///from ww w  . j  av  a2  s  .c o  m
@SuppressWarnings("unchecked") // avoid nested generic
protected AbstractNestablePropertyAccessor getPropertyAccessorForPropertyPath(String propertyPath) {
    int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath);
    // Handle nested properties recursively.
    if (pos > -1) {
        String nestedProperty = propertyPath.substring(0, pos);
        String nestedPath = propertyPath.substring(pos + 1);
        AbstractNestablePropertyAccessor nestedPa = getNestedPropertyAccessor(nestedProperty);
        return nestedPa.getPropertyAccessorForPropertyPath(nestedPath);
    } else {
        return this;
    }
}

From source file:org.springframework.beans.BeanWrapperImpl.java

/**
 * Recursively navigate to return a BeanWrapper for the nested property path.
 * @param propertyPath property property path, which may be nested
 * @return a BeanWrapper for the target bean
 *///w  w w  .  jav  a 2  s.co  m
protected BeanWrapperImpl getBeanWrapperForPropertyPath(String propertyPath) {
    int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath);
    // Handle nested properties recursively.
    if (pos > -1) {
        String nestedProperty = propertyPath.substring(0, pos);
        String nestedPath = propertyPath.substring(pos + 1);
        BeanWrapperImpl nestedBw = getNestedBeanWrapper(nestedProperty);
        return nestedBw.getBeanWrapperForPropertyPath(nestedPath);
    } else {
        return this;
    }
}