Example usage for org.apache.commons.beanutils.expression Resolver getIndex

List of usage examples for org.apache.commons.beanutils.expression Resolver getIndex

Introduction

In this page you can find the example usage for org.apache.commons.beanutils.expression Resolver getIndex.

Prototype

int getIndex(String expression);

Source Link

Document

Extract the index value from the property expression or -1.

Usage

From source file:nl.ucan.navigate.NestedPath.java

private void setProperty(PathContext pathContext, Object value) throws IllegalAccessException,
        InvocationTargetException, NoSuchMethodException, InstantiationException, IntrospectionException {
    if (pathContext.getPaths().size() > 0) {
        String lastPathElement = getLastElement(pathContext);
        Object lastPathInstance = getLastInstance(pathContext);
        Resolver resolver = pub.getResolver();
        String prop = resolver.getProperty(lastPathElement);
        if (resolver.isMapped(lastPathElement)) {
            ////from w  ww.  j av  a 2  s.co m
            // mapped property
            String key = resolver.getKey(lastPathElement);
            value = propertyValue.mapped(lastPathInstance, prop, key, value);
        } else if (resolver.isIndexed(lastPathElement)) {
            //
            // indexed property
            int idx = resolver.getIndex(lastPathElement);
            value = propertyValue.indexed(lastPathInstance, prop, idx, value);
        } else {
            //
            // simple property
            value = propertyValue.simple(lastPathInstance, lastPathElement, value);
        }
        pub.setProperty(lastPathInstance, lastPathElement, value);
    }
}